Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kmem/tracing: add kmem name to kmem_cache_alloc tracepoint

The kmem_cache_free tracepoint includes a "name" field, which allows for
easy identification and filtering of specific kmem's. However, the
kmem_cache_alloc tracepoint lacks this field, making it difficult to pair
corresponding alloc and free events for analysis.

Add the "name" field to kmem_cache_alloc to enable consistent tracking and
correlation of kmem alloc and free events.

Link: https://lkml.kernel.org/r/20250825125927.59816-1-wander@redhat.com
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Martin Liu <liumartin@google.com>
Cc: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Wander Lairson Costa and committed by
Andrew Morton
dfd04add 46afff45

+4 -1
+4 -1
include/trace/events/kmem.h
··· 22 22 TP_STRUCT__entry( 23 23 __field( unsigned long, call_site ) 24 24 __field( const void *, ptr ) 25 + __string( name, s->name ) 25 26 __field( size_t, bytes_req ) 26 27 __field( size_t, bytes_alloc ) 27 28 __field( unsigned long, gfp_flags ) ··· 33 32 TP_fast_assign( 34 33 __entry->call_site = call_site; 35 34 __entry->ptr = ptr; 35 + __assign_str(name); 36 36 __entry->bytes_req = s->object_size; 37 37 __entry->bytes_alloc = s->size; 38 38 __entry->gfp_flags = (__force unsigned long)gfp_flags; ··· 43 41 (s->flags & SLAB_ACCOUNT)) : false; 44 42 ), 45 43 46 - TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d accounted=%s", 44 + TP_printk("call_site=%pS ptr=%p name=%s bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d accounted=%s", 47 45 (void *)__entry->call_site, 48 46 __entry->ptr, 47 + __get_str(name), 49 48 __entry->bytes_req, 50 49 __entry->bytes_alloc, 51 50 show_gfp_flags(__entry->gfp_flags),