Re: [PATCH v2 02/15] mm/hugetlb: compare against persistent count when freeing lowmem folios

From: Rik van Riel

Date: Mon Nov 16 2026 - 18:02:38 EST


On Mon, 2026-11-16 at 19:29 +0100, David Hildenbrand (Arm) wrote:
> try_to_free_low() gets a target number of persistent folios, but
> compares it with "nr_huge_pages", which includes surplus folios. As a
> result, it can free lowmem folios below that target.
>
> For example, with two persistent folios and one surplus folio, a
> target
> of two can still end up freeing one persistent folio.
>
> Compare against persistent_huge_pages() instead. Convert the macro to
> a
> helper function and place it before try_to_free_low().
>
> Fixes: 7893d1d505d5 ("hugetlb: Try to grow hugetlb pool for
> MAP_PRIVATE mappings")
> Cc: stable@xxxxxxxxxx
> Acked-by: Muchun Song <muchun.song@xxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>

Reviewed-by: Rik van Riel <riel@xxxxxxxxxxx>

--
All Rights Reversed.