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

From
David Hildenbrand (Arm) <david@kernel.org>
Date
2026-11-02 12:54:16
Also in
linux-arch, linux-mm, linux-s390, lkml
Reply to
Muchun Song, 2026-10-29
On 10/29/26 04:39, Muchun Song wrote:
quoted
On Oct 29, 2026, at 04:13, David Hildenbrand (Arm) [off-list ref] 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@kernel.org
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Muchun Song <muchun.song@linux.dev>

One nit bellow.
quoted
---
mm/hugetlb.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index da5d04edf7c1..3a94ea1c9457 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1335,6 +1335,11 @@ static unsigned long available_huge_pages(struct hstate *h)
	return h->free_huge_pages - h->resv_huge_pages;
}

+static unsigned long persistent_huge_pages(struct hstate *h)
Better to make *h const?
Agreed, thanks!

-- 
Cheers,

David
Thread (39 messages) 39 messages, 5 authors, last reply 3d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help