Re: [PATCH 3/6] mm/page_io: use swap entries directly in zeromap helpers
Tal Zussman <[email protected]>
| Newsgroups | gmane.linux.kernel,gmane.linux.kernel.mm |
|---|---|
| Message-ID | <[email protected]> |
On 8/10/26 8:55 AM, Lorenzo Stoakes (ARM) wrote: > On Thu, Aug 06, 2026 at 06:55:35PM -0400, Tal Zussman wrote: >> Increment swp_entry_t::val directly instead of recomputing each entry >> with page_swap_entry(). This removes the last struct page usage in >> page_io.c and saves one call to compound_head() per page. >> >> Signed-off-by: Tal Zussman <[email protected]> > > Lord I just looked at page_swap_entry() and... yeah. This is an improvement > thanks :) > > I haven't looked at the rest of the series so maybe you already did it but I > wonder if we could remove it altogether? > Indeed we can - I have ~7 more patches which do exactly that, but they're more wide-ranging (rmap, zswap, huge_memory, swapfile, arm64 MTE), so I kept them separate from this. I believe Andrew is planning to pick this up post-rc1, so I'll probably send them out then since they rely on some of these changes. > Should we rename page_io.c to folio_io.c now? :P > > Anyway LGTM so: > > Reviewed-by: Lorenzo Stoakes (ARM) <[email protected]> > Thanks! >> --- >> mm/page_io.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/mm/page_io.c b/mm/page_io.c >> index 43b4383a4729..c6d0949b3f1e 100644 >> --- a/mm/page_io.c >> +++ b/mm/page_io.c >> @@ -159,7 +159,7 @@ static void swap_zeromap_folio_set(struct folio *folio) >> struct obj_cgroup *objcg = get_obj_cgroup_from_folio(folio); >> int nr_pages = folio_nr_pages(folio); >> struct swap_cluster_info *ci; >> - swp_entry_t entry; >> + swp_entry_t entry = folio->swap; >> unsigned int i; >> >> VM_WARN_ON_ONCE_FOLIO(!folio_test_swapcache(folio), folio); >> @@ -167,8 +167,8 @@ static void swap_zeromap_folio_set(struct folio *folio) >> >> ci = swap_cluster_get_and_lock(folio); >> for (i = 0; i < folio_nr_pages(folio); i++) { >> - entry = page_swap_entry(folio_page(folio, i)); >> __swap_table_set_zero(ci, swp_cluster_offset(entry)); >> + entry.val++; >> } >> swap_cluster_unlock(ci); >> >> @@ -182,7 +182,7 @@ static void swap_zeromap_folio_set(struct folio *folio) >> static void swap_zeromap_folio_clear(struct folio *folio) >> { >> struct swap_cluster_info *ci; >> - swp_entry_t entry; >> + swp_entry_t entry = folio->swap; >> unsigned int i; >> >> VM_WARN_ON_ONCE_FOLIO(!folio_test_swapcache(folio), folio); >> @@ -190,8 +190,8 @@ static void swap_zeromap_folio_clear(struct folio *folio) >> >> ci = swap_cluster_get_and_lock(folio); >> for (i = 0; i < folio_nr_pages(folio); i++) { >> - entry = page_swap_entry(folio_page(folio, i)); >> __swap_table_clear_zero(ci, swp_cluster_offset(entry)); >> + entry.val++; >> } >> swap_cluster_unlock(ci); >> } >> >> -- >> 2.39.5 >> > > -- > Cheers, Lorenzo >