Skip to content

Commit 0bde77f

Browse files
committed
mm: hugetlb: avoid fallback for specific node allocation of 1G pages
commit 6d7bc93 Author: Luiz Capitulino <[email protected]> Date: Mon Feb 10 22:48:56 2025 -0500 mm: hugetlb: avoid fallback for specific node allocation of 1G pages When using the HugeTLB kernel command-line to allocate 1G pages from a specific node, such as: default_hugepagesz=1G hugepages=1:1 If node 1 happens to not have enough memory for the requested number of 1G pages, the allocation falls back to other nodes. A quick way to reproduce this is by creating a KVM guest with a memory-less node and trying to allocate 1 1G page from it. Instead of failing, the allocation will fallback to other nodes. This defeats the purpose of node specific allocation. Also, specific node allocation for 2M pages don't have this behavior: the allocation will just fail for the pages it can't satisfy. This issue happens because HugeTLB calls memblock_alloc_try_nid_raw() for 1G boot-time allocation as this function falls back to other nodes if the allocation can't be satisfied. Use memblock_alloc_exact_nid_raw() instead, which ensures that the allocation will only be satisfied from the specified node. Link: https://lkml.kernel.org/r/[email protected] Fixes: b538908 ("hugetlbfs: extend the definition of hugepages parameter to support node allocation") Signed-off-by: Luiz Capitulino <[email protected]> Acked-by: Oscar Salvador <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: "Mike Rapoport (IBM)" <[email protected]> Cc: Muchun Song <[email protected]> Cc: Zhenguo Yao <[email protected]> Cc: Frank van der Linden <[email protected]> Signed-off-by: Andrew Morton <[email protected]> JIRA: https://issues.redhat.com/browse/RHEL-77742 Signed-off-by: Nico Pache <[email protected]>
1 parent 8bd2b2c commit 0bde77f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/hugetlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3139,7 +3139,7 @@ int __alloc_bootmem_huge_page(struct hstate *h, int nid)
31393139

31403140
/* do node specific alloc */
31413141
if (nid != NUMA_NO_NODE) {
3142-
m = memblock_alloc_try_nid_raw(huge_page_size(h), huge_page_size(h),
3142+
m = memblock_alloc_exact_nid_raw(huge_page_size(h), huge_page_size(h),
31433143
0, MEMBLOCK_ALLOC_ACCESSIBLE, nid);
31443144
if (!m)
31453145
return 0;

0 commit comments

Comments
 (0)