linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hugetlb: skip report_hugepages() output when no hugepages configured
@ 2025-09-10  9:03 lirongqing
  2025-09-10  9:09 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: lirongqing @ 2025-09-10  9:03 UTC (permalink / raw)
  To: muchun.song, osalvador, david, akpm, linux-mm, linux-kernel; +Cc: Li RongQing

From: Li RongQing <lirongqing@baidu.com> 

Avoid unnecessary report_hugepages() output and processing when
max_huge_pages is 0. This eliminates redundant log messages for
unconfigured hugepage sizes and saves CPU cycles during boot.

Before this change, the kernel would always print registration messages
even for hugepage sizes with zero pre-allocated pages:

[    4.118953] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages
[    4.122920] HugeTLB: 28 KiB vmemmap can be freed for a 2.00 MiB page
[    4.126920] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages
[    4.130920] HugeTLB: 16380 KiB vmemmap can be freed for a 1.00 GiB page

Now these messages are suppressed when no pages are configured.

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 mm/hugetlb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index af7c36f..9fb9311 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3733,6 +3733,9 @@ static void __init report_hugepages(void)
 	for_each_hstate(h) {
 		char buf[32];
 
+		if (!h->max_huge_pages)
+			continue;
+
 		nrinvalid = hstate_boot_nrinvalid[hstate_index(h)];
 		h->max_huge_pages -= nrinvalid;
 
-- 
2.9.4



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-10  9:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-10  9:03 [PATCH] mm/hugetlb: skip report_hugepages() output when no hugepages configured lirongqing
2025-09-10  9:09 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox