* [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
@ 2026-04-23 3:49 Barry Song (Xiaomi)
2026-04-23 12:36 ` David Hildenbrand (Arm)
2026-04-25 14:25 ` Zi Yan
0 siblings, 2 replies; 10+ messages in thread
From: Barry Song (Xiaomi) @ 2026-04-23 3:49 UTC (permalink / raw)
To: akpm, linux-mm
Cc: linux-kernel, Barry Song (Xiaomi), David Hildenbrand,
Lorenzo Stoakes, Zi Yan, Baolin Wang, Liam R. Howlett, Nico Pache,
Ryan Roberts, Dev Jain, Lance Yang, Chris Li, Kairui Song,
Kemeng Shi, Nhat Pham, Baoquan He, Youngjun Park
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()").
Fix this by making the description more generic.
Cc: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: Nico Pache <npache@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Chris Li <chrisl@kernel.org>
Cc: Kairui Song <kasong@tencent.com>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Youngjun Park <youngjun.park@lge.com>
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
---
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);
}
--
2.39.3 (Apple Git-146)
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
2026-04-23 3:49 [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split Barry Song (Xiaomi)
@ 2026-04-23 12:36 ` David Hildenbrand (Arm)
2026-04-26 20:42 ` Barry Song
2026-04-25 14:25 ` Zi Yan
1 sibling, 1 reply; 10+ messages in thread
From: David Hildenbrand (Arm) @ 2026-04-23 12:36 UTC (permalink / raw)
To: Barry Song (Xiaomi), akpm, linux-mm
Cc: linux-kernel, Lorenzo Stoakes, Zi Yan, Baolin Wang,
Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain, Lance Yang,
Chris Li, Kairui Song, Kemeng Shi, Nhat Pham, Baoquan He,
Youngjun Park
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).
> Fix this by making the description more generic.
>
> Cc: David Hildenbrand <david@kernel.org>
> Cc: Lorenzo Stoakes <ljs@kernel.org>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
> Cc: Nico Pache <npache@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: Chris Li <chrisl@kernel.org>
> Cc: Kairui Song <kasong@tencent.com>
> Cc: Kemeng Shi <shikemeng@huaweicloud.com>
> Cc: Nhat Pham <nphamcs@gmail.com>
> Cc: Baoquan He <bhe@redhat.com>
> Cc: Youngjun Park <youngjun.park@lge.com>
> Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
> ---
> 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@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
2026-04-23 12:36 ` David Hildenbrand (Arm)
@ 2026-04-26 20:42 ` Barry Song
2026-04-27 7:42 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 10+ messages in thread
From: Barry Song @ 2026-04-26 20:42 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: akpm, linux-mm, linux-kernel, Lorenzo Stoakes, Zi Yan,
Baolin Wang, Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Lance Yang, Chris Li, Kairui Song, Kemeng Shi, Nhat Pham,
Baoquan He, Youngjun Park
On Thu, Apr 23, 2026 at 8:36 PM David Hildenbrand (Arm)
<david@kernel.org> 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@kernel.org>
> > Cc: Lorenzo Stoakes <ljs@kernel.org>
> > Cc: Zi Yan <ziy@nvidia.com>
> > Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> > Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
> > Cc: Nico Pache <npache@redhat.com>
> > Cc: Ryan Roberts <ryan.roberts@arm.com>
> > Cc: Dev Jain <dev.jain@arm.com>
> > Cc: Lance Yang <lance.yang@linux.dev>
> > Cc: Chris Li <chrisl@kernel.org>
> > Cc: Kairui Song <kasong@tencent.com>
> > Cc: Kemeng Shi <shikemeng@huaweicloud.com>
> > Cc: Nhat Pham <nphamcs@gmail.com>
> > Cc: Baoquan He <bhe@redhat.com>
> > Cc: Youngjun Park <youngjun.park@lge.com>
> > Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
> > ---
> > 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@kernel.org>
Thanks for reviewing!
Best Regards,
Barry
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
2026-04-26 20:42 ` Barry Song
@ 2026-04-27 7:42 ` David Hildenbrand (Arm)
2026-04-28 10:05 ` Barry Song
0 siblings, 1 reply; 10+ messages in thread
From: David Hildenbrand (Arm) @ 2026-04-27 7:42 UTC (permalink / raw)
To: Barry Song
Cc: akpm, linux-mm, linux-kernel, Lorenzo Stoakes, Zi Yan,
Baolin Wang, Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Lance Yang, Chris Li, Kairui Song, Kemeng Shi, Nhat Pham,
Baoquan He, Youngjun Park
On 4/26/26 22:42, Barry Song wrote:
> On Thu, Apr 23, 2026 at 8:36 PM David Hildenbrand (Arm)
> <david@kernel.org> 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?
Better to phrase it in a way that doesn't even require these details :)
Do we even need this detail in the patch description?
--
Cheers,
David
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
2026-04-27 7:42 ` David Hildenbrand (Arm)
@ 2026-04-28 10:05 ` Barry Song
2026-04-28 10:08 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 10+ messages in thread
From: Barry Song @ 2026-04-28 10:05 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: akpm, linux-mm, linux-kernel, Lorenzo Stoakes, Zi Yan,
Baolin Wang, Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Lance Yang, Chris Li, Kairui Song, Kemeng Shi, Nhat Pham,
Baoquan He, Youngjun Park
On Mon, Apr 27, 2026 at 3:42 PM David Hildenbrand (Arm)
<david@kernel.org> wrote:
>
> On 4/26/26 22:42, Barry Song wrote:
> > On Thu, Apr 23, 2026 at 8:36 PM David Hildenbrand (Arm)
> > <david@kernel.org> 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?
>
> 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.
Best Regards
Barry
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
2026-04-28 10:05 ` Barry Song
@ 2026-04-28 10:08 ` David Hildenbrand (Arm)
2026-04-28 10:32 ` Barry Song
0 siblings, 1 reply; 10+ messages in thread
From: David Hildenbrand (Arm) @ 2026-04-28 10:08 UTC (permalink / raw)
To: Barry Song
Cc: akpm, linux-mm, linux-kernel, Lorenzo Stoakes, Zi Yan,
Baolin Wang, Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Lance Yang, Chris Li, Kairui Song, Kemeng Shi, Nhat Pham,
Baoquan He, Youngjun Park
On 4/28/26 12:05, Barry Song wrote:
> On Mon, Apr 27, 2026 at 3:42 PM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
>>
>> On 4/26/26 22:42, Barry Song wrote:
>>> On Thu, Apr 23, 2026 at 8:36 PM David Hildenbrand (Arm)
>>> <david@kernel.org> 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 :)
--
Cheers,
David
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
2026-04-28 10:08 ` David Hildenbrand (Arm)
@ 2026-04-28 10:32 ` Barry Song
2026-04-28 13:01 ` Andrew Morton
0 siblings, 1 reply; 10+ messages in thread
From: Barry Song @ 2026-04-28 10:32 UTC (permalink / raw)
To: David Hildenbrand (Arm), akpm
Cc: linux-mm, linux-kernel, Lorenzo Stoakes, Zi Yan, Baolin Wang,
Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain, Lance Yang,
Chris Li, Kairui Song, Kemeng Shi, Nhat Pham, Baoquan He,
Youngjun Park
On Tue, Apr 28, 2026 at 6:08 PM David Hildenbrand (Arm)
<david@kernel.org> wrote:
>
> On 4/28/26 12:05, Barry Song wrote:
> > On Mon, Apr 27, 2026 at 3:42 PM David Hildenbrand (Arm)
> > <david@kernel.org> wrote:
> >>
> >> On 4/26/26 22:42, Barry Song wrote:
> >>> On Thu, Apr 23, 2026 at 8:36 PM David Hildenbrand (Arm)
> >>> <david@kernel.org> 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?
Thanks
Barry
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
2026-04-28 10:32 ` Barry Song
@ 2026-04-28 13:01 ` Andrew Morton
2026-04-28 22:55 ` Barry Song
0 siblings, 1 reply; 10+ messages in thread
From: Andrew Morton @ 2026-04-28 13:01 UTC (permalink / raw)
To: Barry Song
Cc: David Hildenbrand (Arm), linux-mm, linux-kernel, Lorenzo Stoakes,
Zi Yan, Baolin Wang, Liam R. Howlett, Nico Pache, Ryan Roberts,
Dev Jain, Lance Yang, Chris Li, Kairui Song, Kemeng Shi,
Nhat Pham, Baoquan He, Youngjun Park
On Tue, 28 Apr 2026 18:32:40 +0800 Barry Song <baohua@kernel.org> wrote:
> On Tue, Apr 28, 2026 at 6:08 PM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
> >
> > On 4/28/26 12:05, Barry Song wrote:
> > > On Mon, Apr 27, 2026 at 3:42 PM David Hildenbrand (Arm)
> > > <david@kernel.org> wrote:
> > >>
> > >> On 4/26/26 22:42, Barry Song wrote:
> > >>> On Thu, Apr 23, 2026 at 8:36 PM David Hildenbrand (Arm)
> > >>> <david@kernel.org> 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@kernel.org>
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@kernel.org
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Zi Yan <ziy@nvidia.com>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Nico Pache <npache@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Chris Li <chrisl@kernel.org>
Cc: Kairui Song <kasong@tencent.com>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Youngjun Park <youngjun.park@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
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);
}
_
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
2026-04-28 13:01 ` Andrew Morton
@ 2026-04-28 22:55 ` Barry Song
0 siblings, 0 replies; 10+ messages in thread
From: Barry Song @ 2026-04-28 22:55 UTC (permalink / raw)
To: Andrew Morton
Cc: David Hildenbrand (Arm), linux-mm, linux-kernel, Lorenzo Stoakes,
Zi Yan, Baolin Wang, Liam R. Howlett, Nico Pache, Ryan Roberts,
Dev Jain, Lance Yang, Chris Li, Kairui Song, Kemeng Shi,
Nhat Pham, Baoquan He, Youngjun Park
On Tue, Apr 28, 2026 at 9:01 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Tue, 28 Apr 2026 18:32:40 +0800 Barry Song <baohua@kernel.org> wrote:
>
> > On Tue, Apr 28, 2026 at 6:08 PM David Hildenbrand (Arm)
> > <david@kernel.org> wrote:
> > >
> > > On 4/28/26 12:05, Barry Song wrote:
> > > > On Mon, Apr 27, 2026 at 3:42 PM David Hildenbrand (Arm)
> > > > <david@kernel.org> wrote:
> > > >>
> > > >> On 4/26/26 22:42, Barry Song wrote:
> > > >>> On Thu, Apr 23, 2026 at 8:36 PM David Hildenbrand (Arm)
> > > >>> <david@kernel.org> 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?
Yes, exactly.
Thanks very much!
>
> From: "Barry Song (Xiaomi)" <baohua@kernel.org>
> 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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
2026-04-23 3:49 [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split Barry Song (Xiaomi)
2026-04-23 12:36 ` David Hildenbrand (Arm)
@ 2026-04-25 14:25 ` Zi Yan
1 sibling, 0 replies; 10+ messages in thread
From: Zi Yan @ 2026-04-25 14:25 UTC (permalink / raw)
To: Barry Song (Xiaomi)
Cc: akpm, linux-mm, linux-kernel, David Hildenbrand, Lorenzo Stoakes,
Baolin Wang, Liam R. Howlett, Nico Pache, Ryan Roberts, Dev Jain,
Lance Yang, Chris Li, Kairui Song, Kemeng Shi, Nhat Pham,
Baoquan He, Youngjun Park
On 22 Apr 2026, at 23: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()").
> Fix this by making the description more generic.
>
> Cc: David Hildenbrand <david@kernel.org>
> Cc: Lorenzo Stoakes <ljs@kernel.org>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
> Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
> Cc: Nico Pache <npache@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: Chris Li <chrisl@kernel.org>
> Cc: Kairui Song <kasong@tencent.com>
> Cc: Kemeng Shi <shikemeng@huaweicloud.com>
> Cc: Nhat Pham <nphamcs@gmail.com>
> Cc: Baoquan He <bhe@redhat.com>
> Cc: Youngjun Park <youngjun.park@lge.com>
> Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
> ---
> 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);
> }
> --
> 2.39.3 (Apple Git-146)
Acked-by: Zi Yan <ziy@nvidia.com>
--
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-04-28 22:55 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 3:49 [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split Barry Song (Xiaomi)
2026-04-23 12:36 ` David Hildenbrand (Arm)
2026-04-26 20:42 ` Barry Song
2026-04-27 7:42 ` David Hildenbrand (Arm)
2026-04-28 10:05 ` Barry Song
2026-04-28 10:08 ` David Hildenbrand (Arm)
2026-04-28 10:32 ` Barry Song
2026-04-28 13:01 ` Andrew Morton
2026-04-28 22:55 ` Barry Song
2026-04-25 14:25 ` Zi Yan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox