Re: [PATCH] mm/huge_memory: Fix outdated comment about freeing subpages in __folio_split
From: Zi Yan
Date: Sat Apr 25 2026 - 10:25:44 EST
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@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);
> }
> --
> 2.39.3 (Apple Git-146)
Acked-by: Zi Yan <ziy@xxxxxxxxxx>
--
Best Regards,
Yan, Zi