blob: f6795b1f01223b1b4a46be775dc788d49490006a [file] [log] [blame]
From: Frank van der Linden <fvdl@google.com>
Subject: mm/hugetlb: fix round-robin bootmem allocation
Date: Thu, 6 Feb 2025 18:50:45 +0000
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.
Link: https://lkml.kernel.org/r/20250206185109.1210657-6-fvdl@google.com
Fixes: b5389086ad7b ("hugetlbfs: extend the definition of hugepages parameter to support node allocation")
Signed-off-by: Frank van der Linden <fvdl@google.com>
Cc: Zhenguo Yao <yaozhenguo1@gmail.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Roman Gushchin (Cruise) <roman.gushchin@linux.dev>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Oscar Salvador <osalvador@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/hugetlb.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
--- a/mm/hugetlb.c~mm-hugetlb-fix-round-robin-bootmem-allocation
+++ a/mm/hugetlb.c
@@ -3156,16 +3156,13 @@ int __alloc_bootmem_huge_page(struct hst
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 @@ found:
*/
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;
_