Re: [PATCH 0/2] mm/hugetlb: fix surplus accounting and availability checks during demotion

From: Andrew Morton

Date: Fri Aug 28 2026 - 19:10:52 EST


On Sun, 23 Aug 2026 11:43:05 +0800 Longlong Xia <xialonglong2025@xxxxxxx> wrote:

> This series fixes two problems in the hugetlb demote path.
>
> Patch 1 fixes surplus accounting in the source hstate.
> demote_pool_huge_page() removes every source folio as a persistent
> folio, but a free folio may instead account for one of the source
> hstate's surplus pages (for example after a vmemmap restoration
> failure). Removing such a folio without adjusting surplus_huge_pages
> makes the persistent count underflow, and later subtracting it from
> max_huge_pages can underflow that counter as well.
>
> Patch 2 fixes an availability overcount in the sysfs demote path. The
> sysfs trigger checks whether any page is available but then passes the
> entire request to demote_pool_huge_page(), which can remove free huge
> pages that back existing reservations. With two free pages and one
> reservation, a request for two pages removes both and leaves the
> reservation without a backing page.

Thanks. Have you created and tested reproducers for these? Gemini was
trivially able to do this for me.

If so, it would be helpful to includes the details in the
changelogging.