]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0
authorLi RongQing <lirongqing@baidu.com>
Thu, 14 Aug 2025 10:23:33 +0000 (18:23 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 12 Sep 2025 00:25:11 +0000 (17:25 -0700)
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 <lirongqing@baidu.com>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Tested-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Jane Chu <jane.chu@oracle.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/hugetlb.c

index 463fed6c9f5fa5cc190f8b2e4e40a8d6ae7d39f5..503a09b2e58bad3ea252a76e85539709f01b64ef 100644 (file)
@@ -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;