Message ID | 20231119194740.94101-7-ryncsn@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1809687vqn; Sun, 19 Nov 2023 11:48:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNZVoZM8cKfoIsKZ1DWgLzHxRcpqRCrMGMM+Aq38AxwPcgHsQ0T18Hb+8FRd/bI2ex9y8T X-Received: by 2002:a05:6a20:4401:b0:189:df1b:661a with SMTP id ce1-20020a056a20440100b00189df1b661amr3809430pzb.52.1700423330851; Sun, 19 Nov 2023 11:48:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700423330; cv=none; d=google.com; s=arc-20160816; b=H4O3OOvN0tWJgAr3irQzk/FK2Q8x647BrQM4O9SCuQYQ25AX2yWF75UW8Lax0px6W1 s0MaO06HLQEOt0yEHp1suuip/U0iltI8G4LeFGXau9od952bBah6NNlwIz+ZwIjTMdyR oYYiw9E73lfS3xrVt5gRkcLtdOpUo4Nyc6IUpBfW3kRwdShlBj+QaLM3u8IrKMIIWcpH YQ3jCNmTYSRiIMqocwQEjM84qAPvIqg4jopOfE4NyBDVkU+1gFgNzWkUz3T868Z1QD7p 6Ew8trxppb48/oFz75DYZRE+Wl0+xBhD+/byBZbtjvLt1haKlR+M97h7RyTZwkrlI+lP VdiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UpGTVr/h0gRLNFrOGvqL9Asvs1D6zvF8lBMhGssTB0o=; fh=4HE/piJoUCKuBTCCBiej4//zvvzywHdOLL9QM/KYjYM=; b=Q9RrLeqqmZctB8QUbxliz+8cr7eP4HTbGBGQPObASfZhf7X+zxkqG8Q43QcqijWYbk sIINGH1GdIlK2N2QNYP0bF1dp8q4oU/6DLILj+I/mdEU0XwFLFyTzZT6X7WrDGukgORh rOl7GEWYlRIqXaBVUFMPUUZucGcD1mxC1Q6lcNTv4XXYrqAeXv17vgRUUNz4f9hJQury HSvfTMJ3jzGaeRgRQiRExuRBT2bbRNP4Iqj6pwR7NJtfBXN9iQiD0t+Z3P86+l0sfzQU 0QinWxRXWaVr4ju01z94AGPRRoL5HvO3dnOf5JWs+efEMK8lzpBpe2cx7rCczNgilQ+n h3GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XnNMl8Ga; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o2-20020a635a02000000b005c2185da898si4608283pgb.832.2023.11.19.11.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 11:48:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XnNMl8Ga; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1550C80ABFCF; Sun, 19 Nov 2023 11:48:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231550AbjKSTsg (ORCPT <rfc822;jaysivo@gmail.com> + 29 others); Sun, 19 Nov 2023 14:48:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbjKSTsa (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 19 Nov 2023 14:48:30 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43D08D67 for <linux-kernel@vger.kernel.org>; Sun, 19 Nov 2023 11:48:22 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6c33ab26dddso3169833b3a.0 for <linux-kernel@vger.kernel.org>; Sun, 19 Nov 2023 11:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700423301; x=1701028101; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=UpGTVr/h0gRLNFrOGvqL9Asvs1D6zvF8lBMhGssTB0o=; b=XnNMl8Ga2yZtHo/rmlT8dejCkZca0iXOSyw88mV4ZxNzqnt7obnsKqxL67gT9F7mP4 stNe9RLFHjpiZPchL4n3ojUiIQaXnbHn2Oo4tcAJPfvaozdUkhcMm5kVseBWYD4PatrX it/4SaVCte/NV+BqH0IOwZECAaDm2sw6al/DdYT7mLNPYv5eavbyWLFIAHD/yv1kIxWd zOmT4ECj5Z9JBfMDdRF4tKdF/ogC6yfZwab4FSsjOp/Ht4cZ3KC9T5CV445o3L0s5sVW 0Msu/X32pj7swmQbSUuzeJJeVh9uO1ytJtp/0dcE0k3QMT9q1DJF3xi+0/gnS4R/kATu BbUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700423301; x=1701028101; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=UpGTVr/h0gRLNFrOGvqL9Asvs1D6zvF8lBMhGssTB0o=; b=nuJJ1y1Qm3xvE17ZW5aCs0+rt97ONmOzYjE16hHOrIFHsiubPCdfmSdNmbSrDrnHvT 8r4XZocPlYrut1stIvNVCZxzFzuz8m1kdNV8agyFj7dzCLzgk8NtZHY6TwuwNtZPiAcC tamCIWZ0sOoSj8XTOFqdn2VU1c/lo8ubtM/4ptn/t0PuJwUb13wBZmnyMM32SbP41s5q ieYzgz0kesnmxNZiHTqz1lP5XrVaWmEvd09/j6/mxBK1JYe++r7skTiXPA2tMU4ASchE 0KUPQyFiIcASeKeAC62AU/hvJJzjUFN8GxnUABMHC37Ke/h3teNcq9s0T12h5plowK06 5XsQ== X-Gm-Message-State: AOJu0YyzaIzwjM9x3vxbPNNVRFync1bFzFeiCqEMsO+lxFTMWAL4jL8+ 1LWtc0LCozmpbaehmdu7s1cTjUOUP/3EYKfH X-Received: by 2002:a05:6a20:b797:b0:187:8eca:8dc6 with SMTP id fh23-20020a056a20b79700b001878eca8dc6mr2490060pzb.34.1700423301416; Sun, 19 Nov 2023 11:48:21 -0800 (PST) Received: from KASONG-MB2.tencent.com ([115.171.40.79]) by smtp.gmail.com with ESMTPSA id a6-20020aa78646000000b006cb7feae74fsm1237140pfo.164.2023.11.19.11.48.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 11:48:20 -0800 (PST) From: Kairui Song <ryncsn@gmail.com> To: linux-mm@kvack.org Cc: Andrew Morton <akpm@linux-foundation.org>, "Huang, Ying" <ying.huang@intel.com>, David Hildenbrand <david@redhat.com>, Hugh Dickins <hughd@google.com>, Johannes Weiner <hannes@cmpxchg.org>, Matthew Wilcox <willy@infradead.org>, Michal Hocko <mhocko@suse.com>, linux-kernel@vger.kernel.org, Kairui Song <kasong@tencent.com> Subject: [PATCH 06/24] swap: rework swapin_no_readahead arguments Date: Mon, 20 Nov 2023 03:47:22 +0800 Message-ID: <20231119194740.94101-7-ryncsn@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119194740.94101-1-ryncsn@gmail.com> References: <20231119194740.94101-1-ryncsn@gmail.com> Reply-To: Kairui Song <kasong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 19 Nov 2023 11:48:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783023094989102166 X-GMAIL-MSGID: 1783023094989102166 |
Series |
Swapin path refactor for optimization and bugfix
|
|
Commit Message
Kairui Song
Nov. 19, 2023, 7:47 p.m. UTC
From: Kairui Song <kasong@tencent.com> Make it use alloc_pages_mpol instead of vma_alloc_folio, and accept mm_struct directly as an argument instead of taking a vmf as argument. Make its arguments similar to swap_{cluster,vma}_readahead, to make the code more aligned. Also prepare for following commits which will skip vmf for certain swapin paths. Signed-off-by: Kairui Song <kasong@tencent.com> --- mm/swap_state.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
Comments
Hi Kairui, kernel test robot noticed the following build warnings: [auto build test WARNING on akpm-mm/mm-everything] [also build test WARNING on linus/master v6.7-rc2 next-20231117] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Kairui-Song/mm-swap-fix-a-potential-undefined-behavior-issue/20231120-035926 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20231119194740.94101-7-ryncsn%40gmail.com patch subject: [PATCH 06/24] swap: rework swapin_no_readahead arguments config: i386-buildonly-randconfig-003-20231120 (https://download.01.org/0day-ci/archive/20231120/202311200826.8Nl5w3h8-lkp@intel.com/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231120/202311200826.8Nl5w3h8-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202311200826.8Nl5w3h8-lkp@intel.com/ All warnings (new ones prefixed by >>): >> mm/swap_state.c:872: warning: Function parameter or member 'mpol' not described in 'swapin_no_readahead' >> mm/swap_state.c:872: warning: Function parameter or member 'ilx' not described in 'swapin_no_readahead' >> mm/swap_state.c:872: warning: Function parameter or member 'mm' not described in 'swapin_no_readahead' >> mm/swap_state.c:872: warning: Excess function parameter 'vmf' description in 'swapin_no_readahead' vim +872 mm/swap_state.c d9bfcfdc41e8e5 Huang Ying 2017-09-06 859 19f582d2684e47 Kairui Song 2023-11-20 860 /** 19f582d2684e47 Kairui Song 2023-11-20 861 * swapin_no_readahead - swap in pages skipping swap cache and readahead 19f582d2684e47 Kairui Song 2023-11-20 862 * @entry: swap entry of this memory 19f582d2684e47 Kairui Song 2023-11-20 863 * @gfp_mask: memory allocation flags 19f582d2684e47 Kairui Song 2023-11-20 864 * @vmf: fault information 19f582d2684e47 Kairui Song 2023-11-20 865 * 19f582d2684e47 Kairui Song 2023-11-20 866 * Returns the struct page for entry and addr after the swap entry is read 19f582d2684e47 Kairui Song 2023-11-20 867 * in. 19f582d2684e47 Kairui Song 2023-11-20 868 */ 598f2616cde014 Kairui Song 2023-11-20 869 static struct page *swapin_no_readahead(swp_entry_t entry, gfp_t gfp_mask, 2538a5e96fe62f Kairui Song 2023-11-20 870 struct mempolicy *mpol, pgoff_t ilx, 2538a5e96fe62f Kairui Song 2023-11-20 871 struct mm_struct *mm) 19f582d2684e47 Kairui Song 2023-11-20 @872 { 19f582d2684e47 Kairui Song 2023-11-20 873 struct folio *folio; 2538a5e96fe62f Kairui Song 2023-11-20 874 struct page *page; 19f582d2684e47 Kairui Song 2023-11-20 875 void *shadow = NULL; 19f582d2684e47 Kairui Song 2023-11-20 876 2538a5e96fe62f Kairui Song 2023-11-20 877 page = alloc_pages_mpol(gfp_mask, 0, mpol, ilx, numa_node_id()); 2538a5e96fe62f Kairui Song 2023-11-20 878 folio = (struct folio *)page; 19f582d2684e47 Kairui Song 2023-11-20 879 if (folio) { 2538a5e96fe62f Kairui Song 2023-11-20 880 if (mem_cgroup_swapin_charge_folio(folio, mm, c2ac0dcbf9ab6a Kairui Song 2023-11-20 881 GFP_KERNEL, entry)) { 19f582d2684e47 Kairui Song 2023-11-20 882 folio_put(folio); 19f582d2684e47 Kairui Song 2023-11-20 883 return NULL; 19f582d2684e47 Kairui Song 2023-11-20 884 } c2ac0dcbf9ab6a Kairui Song 2023-11-20 885 c2ac0dcbf9ab6a Kairui Song 2023-11-20 886 __folio_set_locked(folio); c2ac0dcbf9ab6a Kairui Song 2023-11-20 887 __folio_set_swapbacked(folio); c2ac0dcbf9ab6a Kairui Song 2023-11-20 888 19f582d2684e47 Kairui Song 2023-11-20 889 mem_cgroup_swapin_uncharge_swap(entry); 19f582d2684e47 Kairui Song 2023-11-20 890 19f582d2684e47 Kairui Song 2023-11-20 891 shadow = get_shadow_from_swap_cache(entry); 19f582d2684e47 Kairui Song 2023-11-20 892 if (shadow) 19f582d2684e47 Kairui Song 2023-11-20 893 workingset_refault(folio, shadow); 19f582d2684e47 Kairui Song 2023-11-20 894 19f582d2684e47 Kairui Song 2023-11-20 895 folio_add_lru(folio); 19f582d2684e47 Kairui Song 2023-11-20 896 19f582d2684e47 Kairui Song 2023-11-20 897 /* To provide entry to swap_readpage() */ 19f582d2684e47 Kairui Song 2023-11-20 898 folio->swap = entry; 19f582d2684e47 Kairui Song 2023-11-20 899 swap_readpage(page, true, NULL); 19f582d2684e47 Kairui Song 2023-11-20 900 folio->private = NULL; 19f582d2684e47 Kairui Song 2023-11-20 901 } 19f582d2684e47 Kairui Song 2023-11-20 902 19f582d2684e47 Kairui Song 2023-11-20 903 return page; 19f582d2684e47 Kairui Song 2023-11-20 904 } 19f582d2684e47 Kairui Song 2023-11-20 905
On Sun, Nov 19, 2023 at 11:48 AM Kairui Song <ryncsn@gmail.com> wrote: > > From: Kairui Song <kasong@tencent.com> > > Make it use alloc_pages_mpol instead of vma_alloc_folio, and accept > mm_struct directly as an argument instead of taking a vmf as argument. > Make its arguments similar to swap_{cluster,vma}_readahead, to > make the code more aligned. It is unclear to me what is the value of making the swap_{cluster,vma}_readahead more aligned here. > Also prepare for following commits which will skip vmf for certain > swapin paths. The following patch 07/24 does not seem to use this patch. Can it merge with the other patch that uses it? As it is, this patch does not serve a stand alone value to justify it. Chris > > Signed-off-by: Kairui Song <kasong@tencent.com> > --- > mm/swap_state.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > diff --git a/mm/swap_state.c b/mm/swap_state.c > index fd0047ae324e..ff6756f2e8e4 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -867,17 +867,17 @@ static struct page *swap_vma_readahead(swp_entry_t targ_entry, gfp_t gfp_mask, > * in. > */ > static struct page *swapin_no_readahead(swp_entry_t entry, gfp_t gfp_mask, > - struct vm_fault *vmf) > + struct mempolicy *mpol, pgoff_t ilx, > + struct mm_struct *mm) > { > - struct vm_area_struct *vma = vmf->vma; > - struct page *page = NULL; > struct folio *folio; > + struct page *page; > void *shadow = NULL; > > - folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, > - vma, vmf->address, false); > + page = alloc_pages_mpol(gfp_mask, 0, mpol, ilx, numa_node_id()); > + folio = (struct folio *)page; > if (folio) { > - if (mem_cgroup_swapin_charge_folio(folio, vma->vm_mm, > + if (mem_cgroup_swapin_charge_folio(folio, mm, > GFP_KERNEL, entry)) { > folio_put(folio); > return NULL; > @@ -896,7 +896,6 @@ static struct page *swapin_no_readahead(swp_entry_t entry, gfp_t gfp_mask, > > /* To provide entry to swap_readpage() */ > folio->swap = entry; > - page = &folio->page; > swap_readpage(page, true, NULL); > folio->private = NULL; > } > @@ -928,7 +927,7 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask, > > mpol = get_vma_policy(vmf->vma, vmf->address, 0, &ilx); > if (swap_use_no_readahead(swp_swap_info(entry), entry)) { > - page = swapin_no_readahead(entry, gfp_mask, vmf); > + page = swapin_no_readahead(entry, gfp_mask, mpol, ilx, vmf->vma->vm_mm); > cached = false; > } else if (swap_use_vma_readahead()) { > page = swap_vma_readahead(entry, gfp_mask, mpol, ilx, vmf); > -- > 2.42.0 > >
Chris Li <chrisl@kernel.org> 于2023年11月21日周二 14:44写道: > > On Sun, Nov 19, 2023 at 11:48 AM Kairui Song <ryncsn@gmail.com> wrote: > > > > From: Kairui Song <kasong@tencent.com> > > > > Make it use alloc_pages_mpol instead of vma_alloc_folio, and accept > > mm_struct directly as an argument instead of taking a vmf as argument. > > Make its arguments similar to swap_{cluster,vma}_readahead, to > > make the code more aligned. > > It is unclear to me what is the value of making the > swap_{cluster,vma}_readahead more aligned here. > > > Also prepare for following commits which will skip vmf for certain > > swapin paths. > > The following patch 07/24 does not seem to use this patch. > Can it merge with the other patch that uses it? > > As it is, this patch does not serve a stand alone value to justify it. Yes, I'll rearrange this.
diff --git a/mm/swap_state.c b/mm/swap_state.c index fd0047ae324e..ff6756f2e8e4 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -867,17 +867,17 @@ static struct page *swap_vma_readahead(swp_entry_t targ_entry, gfp_t gfp_mask, * in. */ static struct page *swapin_no_readahead(swp_entry_t entry, gfp_t gfp_mask, - struct vm_fault *vmf) + struct mempolicy *mpol, pgoff_t ilx, + struct mm_struct *mm) { - struct vm_area_struct *vma = vmf->vma; - struct page *page = NULL; struct folio *folio; + struct page *page; void *shadow = NULL; - folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, - vma, vmf->address, false); + page = alloc_pages_mpol(gfp_mask, 0, mpol, ilx, numa_node_id()); + folio = (struct folio *)page; if (folio) { - if (mem_cgroup_swapin_charge_folio(folio, vma->vm_mm, + if (mem_cgroup_swapin_charge_folio(folio, mm, GFP_KERNEL, entry)) { folio_put(folio); return NULL; @@ -896,7 +896,6 @@ static struct page *swapin_no_readahead(swp_entry_t entry, gfp_t gfp_mask, /* To provide entry to swap_readpage() */ folio->swap = entry; - page = &folio->page; swap_readpage(page, true, NULL); folio->private = NULL; } @@ -928,7 +927,7 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask, mpol = get_vma_policy(vmf->vma, vmf->address, 0, &ilx); if (swap_use_no_readahead(swp_swap_info(entry), entry)) { - page = swapin_no_readahead(entry, gfp_mask, vmf); + page = swapin_no_readahead(entry, gfp_mask, mpol, ilx, vmf->vma->vm_mm); cached = false; } else if (swap_use_vma_readahead()) { page = swap_vma_readahead(entry, gfp_mask, mpol, ilx, vmf);