]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
kmem/tracing: add kmem name to kmem_cache_alloc tracepoint
authorWander Lairson Costa <wander@redhat.com>
Mon, 25 Aug 2025 12:59:26 +0000 (09:59 -0300)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 12 Sep 2025 00:25:17 +0000 (17:25 -0700)
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>
include/trace/events/kmem.h

index 474358773abea88a10eb6202243068079fb399e6..7f93e754da5c24d124c2f36bf6938235d37ea938 100644 (file)
@@ -22,6 +22,7 @@ TRACE_EVENT(kmem_cache_alloc,
        TP_STRUCT__entry(
                __field(        unsigned long,  call_site       )
                __field(        const void *,   ptr             )
+               __string(       name,           s->name         )
                __field(        size_t,         bytes_req       )
                __field(        size_t,         bytes_alloc     )
                __field(        unsigned long,  gfp_flags       )
@@ -32,6 +33,7 @@ TRACE_EVENT(kmem_cache_alloc,
        TP_fast_assign(
                __entry->call_site      = call_site;
                __entry->ptr            = ptr;
+               __assign_str(name);
                __entry->bytes_req      = s->object_size;
                __entry->bytes_alloc    = s->size;
                __entry->gfp_flags      = (__force unsigned long)gfp_flags;
@@ -41,9 +43,10 @@ TRACE_EVENT(kmem_cache_alloc,
                                          (s->flags & SLAB_ACCOUNT)) : false;
        ),
 
-       TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d accounted=%s",
+       TP_printk("call_site=%pS ptr=%p name=%s bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d accounted=%s",
                (void *)__entry->call_site,
                __entry->ptr,
+               __get_str(name),
                __entry->bytes_req,
                __entry->bytes_alloc,
                show_gfp_flags(__entry->gfp_flags),