From patchwork Sun Nov 19 19:47:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13460662 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 6DC69C54FB9 for ; Sun, 19 Nov 2023 19:48:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECE0C6B036D; Sun, 19 Nov 2023 14:48:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E57276B0378; Sun, 19 Nov 2023 14:48:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF6566B037B; Sun, 19 Nov 2023 14:48:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BA99F6B036D for ; Sun, 19 Nov 2023 14:48:25 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 92A2D140331 for ; Sun, 19 Nov 2023 19:48:25 +0000 (UTC) X-FDA: 81475740570.05.4590C04 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by imf19.hostedemail.com (Postfix) with ESMTP id BAC571A000A for ; Sun, 19 Nov 2023 19:48:23 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RZZeIcyL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.177 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700423303; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UpGTVr/h0gRLNFrOGvqL9Asvs1D6zvF8lBMhGssTB0o=; b=1RBIbv0knSc5AHOHbxPPO488YkvOQZ7HoqIuzawiR8l6K/nylJEQbSzEATgTQ6hC1io2zY gNyYZOxAFDZSLkRYq81TWnUqUyvFE0otrzsZ5lTzQlhO4OnD+++Fgio1aGxkZzjhHuWAct 7gOdaBwhazfehFoXxiKuAwUVIAmuhjo= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RZZeIcyL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.215.177 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700423303; a=rsa-sha256; cv=none; b=Koiy/UlJ3/p2Mx3pRfU277fHCT5h8Wbz/v8p5dxM4/IoHQsFqi0YoQvRmKDfZZEyX0LuMU t+2AeGc4c5L1oG/om/q43bMEZRSx+5CumcCccc1Rk5hxKy9HW2uhPTRJbF+5NuAWlm+nSY xfHyA4yb3z4B04JbZTrpOQdQUFlDtNk= Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-5be30d543c4so2373383a12.2 for ; Sun, 19 Nov 2023 11:48:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700423301; x=1701028101; darn=kvack.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=RZZeIcyLV0ymUtYoy/VeUVk0DsOOju132g8/cAs70iSmQaeVysdtckfZvD64IRMdRQ nv/o00cJl9201sPiFycCw5ny4I6bjTC8HgpN3II/EbCSU4TS6h2JloV3InKzVKLmzboq jEMKbgF71Jd9C++dMcNeZk19niUmpCzi60UHwJL7cb8u5czJWog3ajU5aOXEGI7cWOqy fm/MO/4HNZedX6XOq82vtjS005u9Aywm8ZoRz4wjtqrQezr8xk4EOe1VVF6vHNfzideT GZdvi56G9XKNIod9iENraXXTYZeGQlmrNfhQ3MwKLgGI4/QicrjrEMvw5K9BRLPjU5Y/ iP4A== 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=TGB9eRi1KbuJAllu4Ntk9OsRePR8diQAXIKMzAtXEmG88lcsQq7RelwwV3jrgjumGw v3w4mEvqVxxHYKhNEqMGlgQhjNwBvWPc+i6TGCarvYf9V/r2myEkctmOimG948unypJ1 cGrM685sjybg38tmYRqetWsIYS27bl8wk3reQbPmtaSRHGVY+fjmKcWEnJrIg+rgnDqZ 72oqEuXlGYtpnGNnzMDFQTJRcJflpgjHDR55q9aOPl35p76OSx4vfZU7Ugfqbw43v+nN FqLeHYm1Yx/jQr/X+4C12AaF9Vdk0MgpAhFaLlAfPlzB4YPklXtlaW7wTRIDihE0PB1Z sgHg== X-Gm-Message-State: AOJu0YzCpJJOG0DWIEeSpTBXo6L+Da4QEAECsWnyDlw6xLZ0qONRL7gY 4wA55cQZ0D0K+6t2J2MQr5Q9TRmO/U2layxt X-Google-Smtp-Source: AGHT+IHfs1/JMlpqrq4TKTabAC0wuT2f0zXPPKJXJ4FxpJjeabGpgVADWj7Pztf6px1yswvAICZfaA== 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 To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , linux-kernel@vger.kernel.org, Kairui Song 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 MIME-Version: 1.0 X-Rspamd-Queue-Id: BAC571A000A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: isef5m3ft4yihwik71etpozpcckzfge1 X-HE-Tag: 1700423303-843922 X-HE-Meta: U2FsdGVkX18Fz1S9v9tYEI6bvVcieq7vZy0oJMxNL4VdNz1tP6pXmbYwvWjxuHAOJR3RAxWBObIImnZt0qfppQo5o1sHSBMiapDCCFHDyJyzBm7oP08+vP1J8AqX810jOJuyd39jj0ZMzmmICA9iS9MQwGaX2jW9mURv/lNbpuDj7v8jz1pCDcz2m738Bq0RkRtRnXdorZ/OPYXJQwyHcUf27d6rDtGfTuZiO5BSBT8GWsSRPBUhq0t6dWOAF1VgHlRtKg9ARkWgX8+Nm5/lwYe0mIBY5tOY/1/LyfKvpRobJSZ1CTKU/85toqrrnvDPttwpx8tC/F8T3bISDvfcGMlkJF1yMA2TtpSsNEIh7eEufj/6tzKtMbOeLY3JFiKsVLVLN1bxGjdCt6u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UApHctNcerSBgyyaNK/zRKoR7IymoxkEmkL/UU9paivY8jFvI44FvuAFsbi/E8WObvJa+BohcIqTyX1DLYxD8WULFKUFm8pqTHUctcWrCaiUMm6AbQ/qZY1pnlDCRUpsMKSEgDXY/dSzqG4VuVoqsZWLSgCjREkq1kffci3O+l1KFEqem6hrAAgv2uACQSewzGe7UY2k= 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: List-Subscribe: List-Unsubscribe: From: Kairui Song 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 --- 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);