From: Li RongQing Date: Thu, 14 Aug 2025 10:23:33 +0000 (+0800) Subject: mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0 X-Git-Tag: v6.18-rc1~130^2~258 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b322e88b3d553e85b4e15779491c70022783faa4;p=thirdparty%2Fkernel%2Fstable.git mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0 Optimize hugetlb_pages_alloc_boot() to return immediately when max_huge_pages is 0, avoiding unnecessary CPU cycles and the below log message when hugepages aren't configured in the kernel command line. [ 3.702280] HugeTLB: allocation took 0ms with hugepage_allocation_threads=32 Link: https://lkml.kernel.org/r/20250814102333.4428-1-lirongqing@baidu.com Signed-off-by: Li RongQing Reviewed-by: Dev Jain Tested-by: Dev Jain Reviewed-by: Jane Chu Acked-by: David Hildenbrand Cc: Muchun Song Cc: Oscar Salvador Cc: Signed-off-by: Andrew Morton --- diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 753f99b4c7186..514fab5a20ef8 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3654,6 +3654,9 @@ static void __init hugetlb_hstate_alloc_pages(struct hstate *h) return; } + if (!h->max_huge_pages) + return; + /* do node specific alloc */ if (hugetlb_hstate_alloc_pages_specific_nodes(h)) return;