From nobody Sat Oct 4 15:54:55 2025 Received: from baidu.com (mx24.baidu.com [111.206.215.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C8E22FB99E for ; Thu, 14 Aug 2025 10:24:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.206.215.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755167055; cv=none; b=oErBEh4HNyM70Wn70D00GyJ45GOeKlVdyBeC9kPok8HT1msyyvaClPhxQUJawNUMD43TfR2zzCH74dsw9rVQNUvj9MkgyuwyavfCvpK6R8eDiC4pNGooMvoX3i4CT689Ckx2hq3F3ivSoUyeTXL7eH2VvLvatGtxEpW2Y7PZvho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755167055; c=relaxed/simple; bh=IK6LVUsg/KB3VEB3xwNqQvU6PgFkaANaDoqj6Mh+JjQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bvL/j60cV3SOQiCZwmNOVzXSJCKXwZFasAFbOsQSF8v4gYvu+PJbY8pzBUOeGm44HNA9dpKa5gy/9NLQf3UH30nkCX0RL4aV1ubt6dhqfvBcXUM0UiK7N7pJdpOBKEpEulB1iQA3tmkXAeGvgQgJ+nHN8QbswnoOv0Bdpw6UClM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; arc=none smtp.client-ip=111.206.215.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com From: lirongqing To: , , , , , CC: Li RongQing Subject: [PATCH][v2] mm/hugetlb: early exit from hugetlb_pages_alloc_boot() when max_huge_pages=0 Date: Thu, 14 Aug 2025 18:23:33 +0800 Message-ID: <20250814102333.4428-1-lirongqing@baidu.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: bjhj-exc2.internal.baidu.com (172.31.3.12) To bjkjy-exc3.internal.baidu.com (172.31.50.47) X-FEAS-Client-IP: 172.31.50.47 X-FE-Policy-ID: 52:10:53:SYSTEM Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li RongQing 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_thread= s=3D32 Signed-off-by: Li RongQing Acked-by: David Hildenbrand Reviewed-by: Dev Jain Reviewed-by: Jane Chu Tested-by: Dev Jain --- diff with v1: adding the reduced log messages in commit header=20 mm/hugetlb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 753f99b..514fab5 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3654,6 +3654,9 @@ static void __init hugetlb_hstate_alloc_pages(struct = hstate *h) return; } =20 + if (!h->max_huge_pages) + return; + /* do node specific alloc */ if (hugetlb_hstate_alloc_pages_specific_nodes(h)) return; --=20 2.9.4