Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
From: Andrew Morton
Date: Tue Apr 28 2026 - 09:42:04 EST
On Tue, 28 Apr 2026 18:32:40 +0800 Barry Song <baohua@xxxxxxxxxx> wrote:
> On Tue, Apr 28, 2026 at 6:08 PM David Hildenbrand (Arm)
> <david@xxxxxxxxxx> wrote:
> >
> > On 4/28/26 12:05, Barry Song wrote:
> > > On Mon, Apr 27, 2026 at 3:42 PM David Hildenbrand (Arm)
> > > <david@xxxxxxxxxx> wrote:
> > >>
> > >> On 4/26/26 22:42, Barry Song wrote:
> > >>> On Thu, Apr 23, 2026 at 8:36 PM David Hildenbrand (Arm)
> > >>> <david@xxxxxxxxxx> wrote:
> > >>>
> > >>> Thanks, david! would it make more sense to add “when
> > >>> CONFIG_PAGE_MAPCOUNT is enabled” at the end of the
> > >>> sentence?
> > >>
> > >> Better to phrase it in a way that doesn't even require these details :)
> > >>
> > >> Do we even need this detail in the patch description?
> > >
> > > What about:
> > >
> > > The comment appears to be outdated. add_to_swap() no longer exists,
> > > and the explanation of why we need to call put_page() after
> > > splitting could be made more general.
> >
> > Jup :)
>
> Thanks!
> Hi Andrew, would you like to make the change in the
> changelog, or would you prefer that I send a new version?
This?
From: "Barry Song (Xiaomi)" <baohua@xxxxxxxxxx>
Subject: mm/huge_memory: fix outdated comment about freeing subpages in __folio_split
Date: Thu, 23 Apr 2026 11:49:17 +0800
The comment appears to be outdated. add_to_swap() no longer exists,
and the explanation of why we need to call put_page() after splitting
could be made more general.
Link: https://lore.kernel.org/20260423034917.8234-1-baohua@xxxxxxxxxx
Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
Acked-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Acked-by: Zi Yan <ziy@xxxxxxxxxx>
Cc: Lorenzo Stoakes <ljs@xxxxxxxxxx>
Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>
Cc: Liam R. Howlett <liam@xxxxxxxxxxxxx>
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: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---
mm/huge_memory.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
--- a/mm/huge_memory.c~mm-huge_memory-fix-outdated-comment-about-freeing-subpages-in-__folio_split
+++ a/mm/huge_memory.c
@@ -4190,11 +4190,10 @@ fail:
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);
}
_