diff mbox series

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

Message ID 20211129133803.15653-1-yaozhenguo1@gmail.com (mailing list archive)
State New
Headers show
Series [BUG] hugetlbfs: Fix issue of preallocation of gigantic pages can't work | expand

Commit Message

yaozhenguo Nov. 29, 2021, 1:38 p.m. UTC
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.

Signed-off-by: Zhenguo Yao <yaozhenguo1@gmail.com>
---
 mm/hugetlb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mike Kravetz Nov. 29, 2021, 8:58 p.m. UTC | #1
On 11/29/21 05:38, Zhenguo Yao wrote:
> 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.
> 
> Signed-off-by: Zhenguo Yao <yaozhenguo1@gmail.com>

Thank you,


Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Baolin Wang Nov. 30, 2021, 1:41 a.m. UTC | #2
Hi,

On 2021/11/29 21:38, Zhenguo Yao wrote:
> 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.
> 
> Signed-off-by: Zhenguo Yao <yaozhenguo1@gmail.com>

You should add a fixes tag, otherwise LGTM.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>

Fixes: b5389086ad7b ("hugetlbfs: extend the definition of hugepages 
parameter to support node allocation")
Muchun Song Nov. 30, 2021, 2:33 a.m. UTC | #3
On Mon, Nov 29, 2021 at 11:27 PM Zhenguo Yao <yaozhenguo1@gmail.com> wrote:
>
> 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.
>
> Signed-off-by: Zhenguo Yao <yaozhenguo1@gmail.com>

Reviewed-by: Muchun Song <songmuchun@bytedance.com>

Thanks.
Maxim Levitsky Nov. 30, 2021, 7:48 a.m. UTC | #4
On Mon, 2021-11-29 at 21:38 +0800, Zhenguo Yao wrote:
> 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.
> 
> Signed-off-by: Zhenguo Yao <yaozhenguo1@gmail.com>
> ---
>  mm/hugetlb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 60f9b6a9582e..6d1603387914 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -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!
Tested-by: Maxim Levitsky <mlevitsk@redhat.com>

Best regards,
	Maxim Levitsky
diff mbox series

Patch

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 60f9b6a9582e..6d1603387914 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -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) {