Re: [PATCH 3/6] mm/page_io: use swap entries directly in zeromap helpers

"Lorenzo Stoakes (ARM)" <[email protected]>
Newsgroups org.kvack.linux-mm,org.kernel.vger.linux-kernel
Message-ID <annJiayAzNA7kA6O@lucifer>
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?

Should we rename page_io.c to folio_io.c now? :P

Anyway LGTM so:

Reviewed-by: Lorenzo Stoakes (ARM) <[email protected]>

> ---
>  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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.