Skip to contentSkip to conversation

mm-hugetlb-fix-set_max_huge_pages-when-there-are-surplus-pages.patch removed from -mm tree

merged mm-stable Andrew Morton 2 participants 3 messages Mar 17, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: mm/hugetlb: fix set_max_huge_pages() when there are surplus pages
has been removed from the -mm tree. Its filename was
mm-hugetlb-fix-set_max_huge_pages-when-there-are-surplus-pages.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Jinjiang Tu <[email protected]>
Subject: mm/hugetlb: fix set_max_huge_pages() when there are surplus pages
Date: Tue, 25 Feb 2025 22:19:33 +0800

In set_max_huge_pages(), min_count should mean the acquired persistent huge pages, but it contains surplus huge pages. It will lead to failing to free free huge pages for a node.

Steps to reproduce:
1) create 5 huge pages in Node 0
2) run a program to use all the huge pages
3) create 5 huge pages in Node 1
4) echo 0 > nr_hugepages for Node 1 to free the huge pages

The result:
Node 0 Node 1

Total     5         5
Free      0         5
Surp      5         5

With this patch, step 4) destroys the 5 huge pages in Node 1

The result with this patch:
Node 0 Node 1

Total     5         0
Free      0         0
Surp      5         0
Fixes 9a30523066cd ("hugetlb: add per node hstate attributes")
Cc Andi Kleen <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Lee Schermerhorn <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Muchun Song <[email protected]>
Cc Oscar Salvador <[email protected]>

---

 mm/hugetlb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-fix-set_max_huge_pages-when-there-are-surplus-pages +1 -1
@@ -3937,7 +3937,7 @@ static int set_max_huge_pages(struct hst
 	 * and won't grow the pool anywhere else. Not until one of the
 	 * sysctls are changed, or the surplus pages go out of use.
 	 */
-	min_count = h->resv_huge_pages + h->nr_huge_pages - h->free_huge_pages;
+	min_count = h->resv_huge_pages + persistent_huge_pages(h) - h->free_huge_pages;
 	min_count = max(count, min_count);
 	try_to_free_low(h, min_count, nodes_allowed);
 

_

Patches currently in -mm which might be from [email protected] are

mm-contig_alloc-fix-alloc_contig_range-when-__gfp_comp-and-order-max_order.patch

#1 lore raw
Quoted 7 lines · Andrew Morton

The quilt patch titled
Subject: mm/hugetlb: fix set_max_huge_pages() when there are surplus pages
has been removed from the -mm tree. Its filename was
mm-hugetlb-fix-set_max_huge_pages-when-there-are-surplus-pages.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Hi, Andrew

As I explained in https://lore.kernel.org/all/[email protected]/,
This patch fails to deal with free surplus huge pages, and will introduce another issue.

So please drop this patch from mm tree.

Thanks.

Quoted 61 lines

------------------------------------------------------
From: Jinjiang Tu <[email protected]>
Subject: mm/hugetlb: fix set_max_huge_pages() when there are surplus pages
Date: Tue, 25 Feb 2025 22:19:33 +0800

In set_max_huge_pages(), min_count should mean the acquired persistent huge pages, but it contains surplus huge pages. It will lead to failing to free free huge pages for a node.

Steps to reproduce:
1) create 5 huge pages in Node 0
2) run a program to use all the huge pages
3) create 5 huge pages in Node 1
4) echo 0 > nr_hugepages for Node 1 to free the huge pages

The result:
Node 0 Node 1

Total     5         5
Free      0         5
Surp      5         5

With this patch, step 4) destroys the 5 huge pages in Node 1

The result with this patch:
Node 0 Node 1

Total     5         0
Free      0         0
Surp      5         0
Fixes 9a30523066cd ("hugetlb: add per node hstate attributes")
Cc Andi Kleen <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Lee Schermerhorn <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Muchun Song <[email protected]>
Cc Oscar Salvador <[email protected]>

---

  mm/hugetlb.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
mm/hugetlb.c renamed from mm/hugetlb.c~mm-hugetlb-fix-set_max_huge_pages-when-there-are-surplus-pages +1 -1
@@ -3937,7 +3937,7 @@ static int set_max_huge_pages(struct hst
  	 * and won't grow the pool anywhere else. Not until one of the
  	 * sysctls are changed, or the surplus pages go out of use.
  	 */
-	min_count = h->resv_huge_pages + h->nr_huge_pages - h->free_huge_pages;
+	min_count = h->resv_huge_pages + persistent_huge_pages(h) - h->free_huge_pages;
  	min_count = max(count, min_count);
  	try_to_free_low(h, min_count, nodes_allowed);
 

_

Patches currently in -mm which might be from [email protected] are

mm-contig_alloc-fix-alloc_contig_range-when-__gfp_comp-and-order-max_order.patch

#2 lore raw
Quoted 10 lines · On Mon, 17 Mar 2025 14:29:03 +0800 Jinjiang Tu <[email protected]> wrote:
Quoted 7 lines · Andrew Morton

The quilt patch titled
Subject: mm/hugetlb: fix set_max_huge_pages() when there are surplus pages
has been removed from the -mm tree. Its filename was
mm-hugetlb-fix-set_max_huge_pages-when-there-are-surplus-pages.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Quoted 6 lines

Hi, Andrew

As I explained in https://lore.kernel.org/all/[email protected]/,
This patch fails to deal with free surplus huge pages, and will introduce another issue.

So please drop this patch from mm tree.

OK, thanks, dropped.