Skip to contentSkip to conversation

hugetlbfs: Fix issue of preallocation of gigantic pages can't work

BUG Zhenguo Yao 5 participants 5 messages Nov 29, 2021 – Nov 30, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Preallocation of gigantic pages can't work bacause of commit:b5389086ad7b (hugetlbfs: extend the definition of hugepages parameter to support node allocation). When nid is NUMA_NO_NODE(-1), alloc_bootmem_huge_page will always return without doing allocation. Fix this by adding more check.

---
 mm/hugetlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hugetlb.c +1 -1
index 60f9b6a9582e..6d1603387914 100644
@@ -2876,7 +2876,7 @@ int __alloc_bootmem_huge_page(struct hstate *h, int nid)
 	struct huge_bootmem_page *m = NULL; /* initialize for clang */
 	int nr_nodes, node;
 
-	if (nid >= nr_online_nodes)
+	if (nid != NUMA_NO_NODE && nid >= nr_online_nodes)
 		return 0;
 	/* do node specific alloc */
 	if (nid != NUMA_NO_NODE) {
Signature · 1 line
2.27.0
Reviewed-by
#1 lore raw
Quoted 6 lines · Zhenguo Yao

Preallocation of gigantic pages can't work bacause of commit:b5389086ad7b (hugetlbfs: extend the definition of hugepages parameter to support node allocation). When nid is NUMA_NO_NODE(-1), alloc_bootmem_huge_page will always return without doing allocation. Fix this by adding more check.

Thank you,

Signature · 1 line
Mike Kravetz
Quoted 18 lines
---
 mm/hugetlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hugetlb.c +1 -1
index 60f9b6a9582e..6d1603387914 100644
@@ -2876,7 +2876,7 @@ int __alloc_bootmem_huge_page(struct hstate *h, int nid)
 	struct huge_bootmem_page *m = NULL; /* initialize for clang */
 	int nr_nodes, node;
 
-	if (nid >= nr_online_nodes)
+	if (nid != NUMA_NO_NODE && nid >= nr_online_nodes)
 		return 0;
 	/* do node specific alloc */
 	if (nid != NUMA_NO_NODE) {
Reviewed-by
#2 lore raw
In reply to Zhenguo Yao

Hi,

Quoted 6 lines · Zhenguo Yao

Preallocation of gigantic pages can't work bacause of commit:b5389086ad7b (hugetlbfs: extend the definition of hugepages parameter to support node allocation). When nid is NUMA_NO_NODE(-1), alloc_bootmem_huge_page will always return without doing allocation. Fix this by adding more check.

You should add a fixes tag, otherwise LGTM.

Fixes b5389086ad7b ("hugetlbfs: extend the definition of hugepages parameter to support node allocation")
Tested-by
#4 lore raw
In reply to Zhenguo Yao
Quoted 15 lines · Zhenguo Yao

Preallocation of gigantic pages can't work bacause of commit:b5389086ad7b (hugetlbfs: extend the definition of hugepages parameter to support node allocation). When nid is NUMA_NO_NODE(-1), alloc_bootmem_huge_page will always return without doing allocation. Fix this by adding more check.

---
 mm/hugetlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hugetlb.c +0 -0
index 60f9b6a9582e..6d1603387914 100644

mm/hugetlb.c int __alloc_bootmem_huge_page(struct hstate *h, int nid) · line 2882

Quoted 8 lines
mm/hugetlb.c +1 -1
@@ -2876,7 +2876,7 @@ int __alloc_bootmem_huge_page(struct hstate *h, int nid)
 	struct huge_bootmem_page *m = NULL; /* initialize for clang */
 	int nr_nodes, node;
 
-	if (nid >= nr_online_nodes)
+	if (nid != NUMA_NO_NODE && nid >= nr_online_nodes)
 		return 0;
 	/* do node specific alloc */
 	if (nid != NUMA_NO_NODE) {

Tested, works fine.

Thanks!

Best regards,
Maxim Levitsky