Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
From: Barry Song
Date: Sun Apr 26 2026 - 16:42:24 EST
On Thu, Apr 23, 2026 at 8:36 PM David Hildenbrand (Arm)
<david@xxxxxxxxxx> wrote:
>
> On 4/23/26 05:49, Barry Song (Xiaomi) wrote:
> > The comment appears to be outdated. First, add_to_swap() no longer
> > exists after Kairui’s commit b487a2da3575 ("mm, swap: simplify folio
> > swap allocation"). Second, partially zapped folios are now always
> > split before folio_alloc_swap() to avoid extra I/O, following Ryan’s
> > commit 5ed890ce5147 ("mm: vmscan: avoid split during
> > shrink_folio_list()").
>
> Not necessarily. We have some scenarios where we have partially-mapped folios
> not detected as such as of today (with CONFIG_NO_PAGE_MAPCOUNT).
Thanks, david! would it make more sense to add “when
CONFIG_PAGE_MAPCOUNT is enabled” at the end of the
sentence? I mean:
"
following Ryan’s
commit 5ed890ce5147 ("mm: vmscan: avoid split during
shrink_folio_list()") when CONFIG_PAGE_MAPCOUNT is enabled.
"
>
> > Fix this by making the description more generic.
> >
> > Cc: David Hildenbrand <david@xxxxxxxxxx>
> > Cc: Lorenzo Stoakes <ljs@xxxxxxxxxx>
> > Cc: Zi Yan <ziy@xxxxxxxxxx>
> > Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
> > Cc: "Liam R. Howlett" <Liam.Howlett@xxxxxxxxxx>
> > Cc: Nico Pache <npache@xxxxxxxxxx>
> > Cc: Ryan Roberts <ryan.roberts@xxxxxxx>
> > Cc: Dev Jain <dev.jain@xxxxxxx>
> > Cc: Lance Yang <lance.yang@xxxxxxxxx>
> > Cc: Chris Li <chrisl@xxxxxxxxxx>
> > Cc: Kairui Song <kasong@xxxxxxxxxxx>
> > Cc: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
> > Cc: Nhat Pham <nphamcs@xxxxxxxxx>
> > Cc: Baoquan He <bhe@xxxxxxxxxx>
> > Cc: Youngjun Park <youngjun.park@xxxxxxx>
> > Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
> > ---
> > mm/huge_memory.c | 9 ++++-----
> > 1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> > index 970e077019b7..4586f3ccb133 100644
> > --- a/mm/huge_memory.c
> > +++ b/mm/huge_memory.c
> > @@ -4190,11 +4190,10 @@ static int __folio_split(struct folio *folio, unsigned int new_order,
> >
> > folio_unlock(new_folio);
> > /*
> > - * Subpages may be freed if there wasn't any mapping
> > - * like if add_to_swap() is running on a lru page that
> > - * had its mapping zapped. And freeing these pages
> > - * requires taking the lru_lock so we do the put_page
> > - * of the tail pages after the split is complete.
> > + * Subpages whose mapping has been zapped may be freed
> > + * earlier, but freeing them requires taking the
> > + * lru_lock, so we defer put_page() on tail pages until
> > + * after the split completes.
> > */
> > free_folio_and_swap_cache(new_folio);
> > }
>
> Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Thanks for reviewing!
Best Regards,
Barry