From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 949CBC05052 for ; Fri, 18 Aug 2023 07:05:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17B90940055; Fri, 18 Aug 2023 03:05:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12CA4940053; Fri, 18 Aug 2023 03:05:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01AFF940055; Fri, 18 Aug 2023 03:05:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E7CB9940053 for ; Fri, 18 Aug 2023 03:05:34 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B94F3810DE for ; Fri, 18 Aug 2023 07:05:34 +0000 (UTC) X-FDA: 81136339788.01.82F61DC Received: from out-55.mta0.migadu.com (out-55.mta0.migadu.com [91.218.175.55]) by imf02.hostedemail.com (Postfix) with ESMTP id 139DF8000D for ; Fri, 18 Aug 2023 07:05:31 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="t2VAUZ/0"; spf=pass (imf02.hostedemail.com: domain of yanjun.zhu@linux.dev designates 91.218.175.55 as permitted sender) smtp.mailfrom=yanjun.zhu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692342332; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jv+O91aJKOY8Oa1uiqnwHLxjtat+AR7MEL0TnmE0b24=; b=ou/8U5WRL6UVAklxdhHf+X1TrsK/IijytFkuKon1UVZMbyju3AMC0EB1TreFwbf0f46832 AFsgiP4YmvabIdg9aFCHCy2Ji3XQy8rJ3zGqlFqzkkCfOC3yjGGswbhbbWcKecnTZssAu7 jefYkm/0jS4zE7J0OSmbgl1b1yv8KMI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692342332; a=rsa-sha256; cv=none; b=B9ZpppfHkhrmdHpwG3LqvmRPegzdBuAa2yMX19k9Ln9OfJcS+Yz571MNKkkOm4fO1Ao1Xk c13C7BsayT9VFCyYLTZ7n3NgL6eXcJb96a8rjHmtM/2XqUVwMrhrMrwWrwmKvf9nw5zoQY MK/hU7DoeiU7mciy0/R2CXNlvZfeh2w= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="t2VAUZ/0"; spf=pass (imf02.hostedemail.com: domain of yanjun.zhu@linux.dev designates 91.218.175.55 as permitted sender) smtp.mailfrom=yanjun.zhu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1692342329; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jv+O91aJKOY8Oa1uiqnwHLxjtat+AR7MEL0TnmE0b24=; b=t2VAUZ/03p433tyvzSI/43v6e2AbSGWAj8MxYeOybMl7YnRaVl2x7cj/71xMqWMRKgtL5v gDTi48YCNm6X+Zx7LdxDdJqLYzdh7lfvVT1qlpkHtDEsYVQFpWK4DfMUfninCzwp/lvXbw 99BmTYaes3N1P4mgadXNBtLHpTk2S6Q= Date: Fri, 18 Aug 2023 15:05:14 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 03/13] scatterlist: Add sg_set_folio() To: Matthew Wilcox Cc: linux-mm@kvack.org, Andrew Morton , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org References: <20230621164557.3510324-1-willy@infradead.org> <20230621164557.3510324-4-willy@infradead.org> <40a3ab47-da3e-0d08-b3fa-b4663f3e727d@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zhu Yanjun In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Stat-Signature: t38o3ujdpnkcx3q6im7q1s3fz33jmk6t X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 139DF8000D X-Rspam-User: X-HE-Tag: 1692342331-649523 X-HE-Meta: U2FsdGVkX180M5IYVpgq2DD13mlw1jqzmNhRaX9WXdsDi9f3Rzz2Ao2Grf5XwG7Zc4L6gdAS8aZ7OgrkatYsEgjXUpkZ+iYrzH9W2cJBJJPjNkL33N8kIhbXIQGaLlYma8mjIhD69Pq+SI+RzVn/YZurSFFJ/6TdXzcIhhySmWXpbjvpNe/BUewra8qf1/UWAYREo4MO9Ne1V043VhOPxnYtMrq42BPShYnowD104MrGUZ4KSFZ/MsdQ3p7m4pyICbdZ6Nbif61V8+tYcfSYKpscyRxaOMCa0xP+QH7Zbh4eXwSYfKrl0v1z1doKkRGI4DdTbwSEzuQZdEuCxnL9mQ/bd60x8MV9JucIRT4a3C5q/JI9i/+u4Uwyeba76Hm53//Zeoz6aK4pH/50tnSEz7BYbA+dyc9EJo29BBvkle+QLBsxtCqw5oG5nZxoUOoAQQFtLgOLw9roy+MEuh9Gsr+mJ1VwefmiUrVYX37oRolxJozIs0SeY/sKEeqcxitPZBoeolC6JENkN6Iw4Uiiqspef2Q6uSjpbMw1cI0Yg1WV8Da2/LM/+YIqb9KMnKGHON6/H9K/UxvzD7UVgsOEtqXGsrhYKVqsXmyeEBlIicVLnNixbQxP9YqTr9uNpjHeI8+9Lscen33ZexrJ5yRZcnatYIJ4eCUE2sWm+yuVYtCW3n2oGRMzxKOcF2Q/VA8Ygrgm6HME0Bg4mzhT2eosC6CoaPqMB0OTFL6VzkZxnK8t/Ubw5As/6Rgr+O1Bd46/HPDZnCz1/UP7As8i2TC9H2UaMAi79vLoFBd0k3hVbeho4766mJrBmxJL6wbrneGLZAYFaARMD9RCKnSlG2tiirl8iVKIrGObEEuCMDVHwK72IlFDhOUlroTifl+hdxrEQ7s/R1izF51rOXcBlLCxoQ8CLbS3zHGOua2grUqXFxkxnsjNaoQ8iVJdSKu7dJwrlDntFycng627dS9oo+o Wa05E19P VtsOYJcnLtzGbTnvjlptY9XW7V31moAYWG5HB4Q6N6qfA1nwLCQqBNV+5OxB3WfnT/8sgg6s7tbNRM81Obm2YjMN8R8TYoNtm2X5YrvvpxYIFW8fZsqAZM7YSNV7sZ6lwvhWlzQcQ4cITQTM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 在 2023/7/31 5:42, Matthew Wilcox 写道: > On Sun, Jul 30, 2023 at 09:57:06PM +0800, Zhu Yanjun wrote: >> 在 2023/7/30 19:18, Matthew Wilcox 写道: >>> On Sun, Jul 30, 2023 at 07:01:26PM +0800, Zhu Yanjun wrote: >>>> Does the following function have folio version? >>>> >>>> " >>>> int sg_alloc_append_table_from_pages(struct sg_append_table *sgt_append, >>>> struct page **pages, unsigned int n_pages, unsigned int offset, >>>> unsigned long size, unsigned int max_segment, >>>> unsigned int left_pages, gfp_t gfp_mask) >>>> " >>> No -- I haven't needed to convert anything that uses >>> sg_alloc_append_table_from_pages() yet. It doesn't look like it should >>> be _too_ hard to add a folio version. >> In many places, this function is used. So this function needs the folio >> version. > It's not used in very many places. But the first one that I see it used > (drivers/infiniband/core/umem.c), you can't do a straightforward folio > conversion: > > pinned = pin_user_pages_fast(cur_base, > min_t(unsigned long, npages, > PAGE_SIZE / > sizeof(struct page *)), > gup_flags, page_list); > ... > ret = sg_alloc_append_table_from_pages( > &umem->sgt_append, page_list, pinned, 0, > pinned << PAGE_SHIFT, ib_dma_max_seg_size(device), > npages, GFP_KERNEL); > > That can't be converted to folios. The GUP might start in the middle of > the folio, and we have no way to communicate that. > > This particular usage really needs the phyr work that Jason is doing so > we can efficiently communicate physically contiguous ranges from GUP > to sg. Hi, Matthew Thanks. To the following function, it seems that no folio function replace vmalloc_to_page. vmalloc_to_page calls virt_to_page to get page. Finally the followings will be called. " (mem_map + ((pfn) - ARCH_PFN_OFFSET)) " And I do not find the related folio functions with vmalloc_to_page. And no folio function replaces dma_map_page. dma_map_page will call dma_map_page_attrs. Or these 2 function should not be replaced with folio functions? int irdma_map_vm_page_list(struct irdma_hw *hw, void *va, dma_addr_t *pg_dma,                            u32 pg_cnt) {         struct page *vm_page;         int i;         u8 *addr;         addr = (u8 *)(uintptr_t)va;         for (i = 0; i < pg_cnt; i++) {                 vm_page = vmalloc_to_page(addr);                 if (!vm_page)                         goto err;                 pg_dma[i] = dma_map_page(hw->device, vm_page, 0, PAGE_SIZE,                                          DMA_BIDIRECTIONAL);                 if (dma_mapping_error(hw->device, pg_dma[i]))                         goto err;                 addr += PAGE_SIZE;         }         return 0; err:         irdma_unmap_vm_page_list(hw, pg_dma, i);         return -ENOMEM; } Thanks, Zhu Yanjun >> Another problem, after folio is used, I want to know the performance after >> folio is implemented. >> >> How to make tests to get the performance? > You know what you're working on ... I wouldn't know how best to test > your code.