[PATCH] mm: page_alloc: add trace_mm_page_alloc to bulk allocation path

From: liuqiqi

Date: Mon Sep 07 2026 - 08:22:03 EST


From: Qiqi Liu <liuqiqi@xxxxxxxxxx>

The bulk allocation path in alloc_pages_bulk_noprof() does not fire
trace_mm_page_alloc for each allocated page, leaving bulk-allocated
pages invisible to ftrace, BPF, and perf. Only the fallback path via
__alloc_frozen_pages_noprof() is traced.

Add trace_mm_page_alloc() after set_page_refcounted() in the bulk loop
to match the standard allocation path. The tracepoint is gated by
static key, so there is no overhead when tracing is disabled.

Signed-off-by: Qiqi Liu <liuqiqi@xxxxxxxxxx>
---
mm/page_alloc.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 12fac9084c48..d17c21775cb2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5280,6 +5280,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,

prep_new_page(page, 0, gfp, ALLOC_DEFAULT);
set_page_refcounted(page);
+ trace_mm_page_alloc(page, 0, gfp, ac.migratetype);
page_array[nr_populated++] = page;
}

--
2.25.1