Re: [PATCH 1/1] mm/hugetlb: keep max_huge_pages when dissolving surplus folios
From: Andrew Morton
Date: Fri Aug 14 2026 - 14:41:03 EST
On Fri, 14 Aug 2026 16:30:27 +0800 Longlong Xia <xialonglong2025@xxxxxxx> wrote:
> From: Longlong Xia <xialonglong@xxxxxxxxxx>
>
> dissolve_free_hugetlb_folio() can remove a free folio as surplus when
> its node has surplus pages. In that case remove_hugetlb_folio()
> decrements both nr_huge_pages and surplus_huge_pages, leaving the
> persistent pool size unchanged.
>
> Updating max_huge_pages as if a persistent folio had been removed can
> therefore corrupt the persistent pool target and underflow it when
> max_huge_pages is zero. Keep max_huge_pages unchanged for surplus
> folios, including the vmemmap restoration rollback path.
Thanks.
> Fixes: cb402bbdabca ("mm/hugetlb: fix surplus pages in dissolve_free_huge_page()")
That's a year old, so I'm assuming there's no urgency here. I'll
save the fix for later and shall await maintainer input. While at it,
please suggest whether we should backport this.
AI review might have found a couple of bugs in the surrounding code. If true,
they look rather nasty.
https://sashiko.dev/#/patchset/20260814083027.1419487-1-xialonglong2025@xxxxxxx