Re: [PATCH v2] mm: Introduce free_folio_and_swap_cache() to replace free_page_and_swap_cache()
From: Matthew Wilcox
Date: Sun Apr 13 2025 - 17:34:50 EST
On Sat, Apr 12, 2025 at 09:22:21PM -0700, nifan.cxl@xxxxxxxxx wrote:
> From: Fan Ni <fan.ni@xxxxxxxxxxx>
>
> The function free_page_and_swap_cache() takes a struct page pointer as
> input parameter, but it will immediately convert it to folio and all
> operations following within use folio instead of page. It makes more
> sense to pass in folio directly.
>
> Introduce free_folio_and_swap_cache(), which takes folio as input to
> replace free_page_and_swap_cache(). And apply it to all occurrences
> where free_page_and_swap_cache() was used.
>
> Signed-off-by: Fan Ni <fan.ni@xxxxxxxxxxx>
> Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
> Acked-by: Davidlohr Bueso <dave@xxxxxxxxxxxx>
> Reviewed-by: Vishal Moola (Oracle) <vishal.moola@xxxxxxxxx>
Reviewed-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> @@ -522,8 +522,8 @@ static inline void put_swap_device(struct swap_info_struct *si)
> do { (val)->freeswap = (val)->totalswap = 0; } while (0)
> /* only sparc can not include linux/pagemap.h in this file
> * so leave put_page and release_pages undeclared... */
> -#define free_page_and_swap_cache(page) \
> - put_page(page)
> +#define free_folio_and_swap_cache(folio) \
> + folio_put(folio)
Since you're respinning this patch anyway, you can delete the comment
about sparc. This file has included pagemap.h since 4ee60ec156d9
in 2021.