diff mbox series

[05/27] mm/hugetlb: fix round-robin bootmem allocation

Message ID 20250127232207.3888640-6-fvdl@google.com (mailing list archive)
State New
Headers show
Series hugetlb/CMA improvements for large systems | expand

Commit Message

Frank van der Linden Jan. 27, 2025, 11:21 p.m. UTC
Commit b5389086ad7b ("hugetlbfs: extend the definition of hugepages parameter to support node allocation")
changed the NUMA_NO_NODE round-robin allocation behavior in case of a
failure to allocate from one NUMA node. The code originally moved on to
the next node to try again, but now it immediately breaks out of the loop.

Restore the original behavior.

Fixes: b5389086ad7b ("hugetlbfs: extend the definition of hugepages parameter to support node allocation")
Cc: Zhenguo Yao <yaozhenguo1@gmail.com>
Signed-off-by: Frank van der Linden <fvdl@google.com>
---
 mm/hugetlb.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b187843e38fe..1441a3916b32 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3156,16 +3156,13 @@  int __alloc_bootmem_huge_page(struct hstate *h, int nid)
 		m = memblock_alloc_try_nid_raw(
 				huge_page_size(h), huge_page_size(h),
 				0, MEMBLOCK_ALLOC_ACCESSIBLE, node);
-		/*
-		 * Use the beginning of the huge page to store the
-		 * huge_bootmem_page struct (until gather_bootmem
-		 * puts them into the mem_map).
-		 */
-		if (!m)
-			return 0;
-		goto found;
+		if (m)
+			break;
 	}
 
+	if (!m)
+		return 0;
+
 found:
 
 	/*
@@ -3177,7 +3174,14 @@  int __alloc_bootmem_huge_page(struct hstate *h, int nid)
 	 */
 	memblock_reserved_mark_noinit(virt_to_phys((void *)m + PAGE_SIZE),
 		huge_page_size(h) - PAGE_SIZE);
-	/* Put them into a private list first because mem_map is not up yet */
+	/*
+	 * Use the beginning of the huge page to store the
+	 * huge_bootmem_page struct (until gather_bootmem
+	 * puts them into the mem_map).
+	 *
+	 * Put them into a private list first because mem_map
+	 * is not up yet.
+	 */
 	INIT_LIST_HEAD(&m->list);
 	list_add(&m->list, &huge_boot_pages[node]);
 	m->hstate = h;