* [PATCH] mm: page_alloc: add nid to mm_page_alloc tracepoint
@ 2026-11-13 6:20 Ye Bin
2026-11-13 8:48 ` Vlastimil Babka (SUSE)
0 siblings, 1 reply; 3+ messages in thread
From: Ye Bin @ 2026-11-13 6:20 UTC (permalink / raw)
To: vbabka, harry, hao.li, cl, rientjes, roman.gushchin, linux-mm; +Cc: yebin10
From: Ye Bin <yebin10@huawei.com>
Add the NUMA node id to the mm_page_alloc trace event so that page
allocations can be attributed to a specific node directly from the
trace, without having to look up the pfn separately.
The nid is derived from the allocated page, or set to -1 when no page
is available (e.g. failed allocations).
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
include/trace/events/kmem.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index cd7920c81f85..8bf4e992d8bb 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -189,6 +189,7 @@ TRACE_EVENT(mm_page_alloc,
__field( unsigned int, order )
__field( unsigned long, gfp_flags )
__field( int, migratetype )
+ __field( int, nid )
),
TP_fast_assign(
@@ -196,13 +197,15 @@ TRACE_EVENT(mm_page_alloc,
__entry->order = order;
__entry->gfp_flags = (__force unsigned long)gfp_flags;
__entry->migratetype = migratetype;
+ __entry->nid = page ? page_to_nid(page) : -1;
),
- TP_printk("page=%p pfn=0x%lx order=%d migratetype=%d gfp_flags=%s",
+ TP_printk("page=%p pfn=0x%lx order=%d migratetype=%d nid=%d gfp_flags=%s",
__entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
__entry->pfn != -1UL ? __entry->pfn : 0,
__entry->order,
__entry->migratetype,
+ __entry->nid,
show_gfp_flags(__entry->gfp_flags))
);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] mm: page_alloc: add nid to mm_page_alloc tracepoint
2026-11-13 6:20 [PATCH] mm: page_alloc: add nid to mm_page_alloc tracepoint Ye Bin
@ 2026-11-13 8:48 ` Vlastimil Babka (SUSE)
2026-11-14 0:46 ` yebin (H)
0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-11-13 8:48 UTC (permalink / raw)
To: Ye Bin, harry, hao.li, cl, rientjes, roman.gushchin, linux-mm; +Cc: yebin10
On 11/13/26 07:20, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
>
> Add the NUMA node id to the mm_page_alloc trace event so that page
> allocations can be attributed to a specific node directly from the
> trace, without having to look up the pfn separately.
But is it the right tradeoff? Trace data should be as minimal as possible
for cpu and memory purposes. Anything extra that can be achieved by
postprocessing is better done that way. Matching pfn to node using
/proc/zoneinfo is simple.
> The nid is derived from the allocated page, or set to -1 when no page
> is available (e.g. failed allocations).
>
> Signed-off-by: Ye Bin <yebin10@huawei.com>
> ---
> include/trace/events/kmem.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
> index cd7920c81f85..8bf4e992d8bb 100644
> --- a/include/trace/events/kmem.h
> +++ b/include/trace/events/kmem.h
> @@ -189,6 +189,7 @@ TRACE_EVENT(mm_page_alloc,
> __field( unsigned int, order )
> __field( unsigned long, gfp_flags )
> __field( int, migratetype )
> + __field( int, nid )
> ),
>
> TP_fast_assign(
> @@ -196,13 +197,15 @@ TRACE_EVENT(mm_page_alloc,
> __entry->order = order;
> __entry->gfp_flags = (__force unsigned long)gfp_flags;
> __entry->migratetype = migratetype;
> + __entry->nid = page ? page_to_nid(page) : -1;
> ),
>
> - TP_printk("page=%p pfn=0x%lx order=%d migratetype=%d gfp_flags=%s",
> + TP_printk("page=%p pfn=0x%lx order=%d migratetype=%d nid=%d gfp_flags=%s",
> __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
> __entry->pfn != -1UL ? __entry->pfn : 0,
> __entry->order,
> __entry->migratetype,
> + __entry->nid,
> show_gfp_flags(__entry->gfp_flags))
> );
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] mm: page_alloc: add nid to mm_page_alloc tracepoint
2026-11-13 8:48 ` Vlastimil Babka (SUSE)
@ 2026-11-14 0:46 ` yebin (H)
0 siblings, 0 replies; 3+ messages in thread
From: yebin (H) @ 2026-11-14 0:46 UTC (permalink / raw)
To: Vlastimil Babka (SUSE), Ye Bin, harry, hao.li, cl, rientjes,
roman.gushchin, linux-mm
On 2026/11/13 16:48, Vlastimil Babka (SUSE) wrote:
> On 11/13/26 07:20, Ye Bin wrote:
>> From: Ye Bin <yebin10@huawei.com>
>>
>> Add the NUMA node id to the mm_page_alloc trace event so that page
>> allocations can be attributed to a specific node directly from the
>> trace, without having to look up the pfn separately.
>
> But is it the right tradeoff? Trace data should be as minimal as possible
> for cpu and memory purposes. Anything extra that can be achieved by
> postprocessing is better done that way. Matching pfn to node using
> /proc/zoneinfo is simple.
>
Hi,
I agree with the general principle that trace data should be kept minimal
and that anything computable in post-processing is better done there. But
I think the "matching pfn to node via /proc/zoneinfo is simple" part
underestimates the actual work involved, and for this particular event
the tradeoff is not as clear as it looks.Although AI can be used to analyze
data now, not all data in every scenario can be exported for post-processing
analysis. Online debugging requires speed.
Trace is a debugging facility to begin with. Enabling it already has a
performance cost by design; that's accepted when you turn it on. Adding one
int to an event that already carries pfn, order, migratetype and gfp_flags
is a marginal increase relative to that, while the benefit — direct,
unambiguous node attribution — is immediate.
So while the extra field does cost some ring buffer space and a small amount
of work in TP_fast_assign(), I think adding nid here is the more practical
tradeoff.
>> The nid is derived from the allocated page, or set to -1 when no page
>> is available (e.g. failed allocations).
>>
>> Signed-off-by: Ye Bin <yebin10@huawei.com>
>> ---
>> include/trace/events/kmem.h | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
>> index cd7920c81f85..8bf4e992d8bb 100644
>> --- a/include/trace/events/kmem.h
>> +++ b/include/trace/events/kmem.h
>> @@ -189,6 +189,7 @@ TRACE_EVENT(mm_page_alloc,
>> __field( unsigned int, order )
>> __field( unsigned long, gfp_flags )
>> __field( int, migratetype )
>> + __field( int, nid )
>> ),
>>
>> TP_fast_assign(
>> @@ -196,13 +197,15 @@ TRACE_EVENT(mm_page_alloc,
>> __entry->order = order;
>> __entry->gfp_flags = (__force unsigned long)gfp_flags;
>> __entry->migratetype = migratetype;
>> + __entry->nid = page ? page_to_nid(page) : -1;
>> ),
>>
>> - TP_printk("page=%p pfn=0x%lx order=%d migratetype=%d gfp_flags=%s",
>> + TP_printk("page=%p pfn=0x%lx order=%d migratetype=%d nid=%d gfp_flags=%s",
>> __entry->pfn != -1UL ? pfn_to_page(__entry->pfn) : NULL,
>> __entry->pfn != -1UL ? __entry->pfn : 0,
>> __entry->order,
>> __entry->migratetype,
>> + __entry->nid,
>> show_gfp_flags(__entry->gfp_flags))
>> );
>>
>
>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-14 0:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 6:20 [PATCH] mm: page_alloc: add nid to mm_page_alloc tracepoint Ye Bin
2026-11-13 8:48 ` Vlastimil Babka (SUSE)
2026-11-14 0:46 ` yebin (H)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox