Re: [PATCH] mm/hugetlb: Convert &folio->page to folio_page(folio, 0)
From: Matthew Wilcox
Date: Wed Apr 09 2025 - 23:49:38 EST
On Wed, Apr 09, 2025 at 03:07:50PM -0700, Fan Ni wrote:
> On Wed, Apr 09, 2025 at 04:15:30AM +0100, Matthew Wilcox wrote:
> > > */
> > > - free_page_and_swap_cache(&new_folio->page);
> > > + free_page_and_swap_cache(folio_page(new_folio, 0));
> > > }
> >
> > free_page_and_swap_cache() should be converted to be
> > free_folio_and_swap_cache().
>
> While looking into this function, I see it is defined as a macro in
> swap.h as below,
> #define free_page_and_swap_cache(page) \
> put_page(page)
>
> While checking put_page() in include/linux.mm.h, it always converts page
> to folio, is there a reason why we do not take "folio" directly?
There are a lot of places to convert!
$ git grep '[^a-zA-Z_>]put_page(' |wc -l
472
... and that's after four years of doing folio conversions.
free_folio_and_swap_cache() should call folio_put() in the !CONFIG_SWAP
case.