[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231119194740.94101-7-ryncsn@gmail.com>
Date: Mon, 20 Nov 2023 03:47:22 +0800
From: Kairui Song <ryncsn@...il.com>
To: linux-mm@...ck.org
Cc: Andrew Morton <akpm@...ux-foundation.org>,
"Huang, Ying" <ying.huang@...el.com>,
David Hildenbrand <david@...hat.com>,
Hugh Dickins <hughd@...gle.com>,
Johannes Weiner <hannes@...xchg.org>,
Matthew Wilcox <willy@...radead.org>,
Michal Hocko <mhocko@...e.com>, linux-kernel@...r.kernel.org,
Kairui Song <kasong@...cent.com>
Subject: [PATCH 06/24] swap: rework swapin_no_readahead arguments
From: Kairui Song <kasong@...cent.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@...cent.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
Powered by blists - more mailing lists