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.
Unified · Split
| @@ -22,6 +22,7 @@ TRACE_EVENT(kmem_cache_alloc, · 21 unmodified lines | ||
| 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 ) |
| @@ -32,6 +33,7 @@ TRACE_EVENT(kmem_cache_alloc, · 4 unmodified lines | ||
| 32 | 33 | TP_fast_assign( |
| 33 | 34 | __entry->call_site = call_site; |
| 34 | 35 | __entry->ptr = ptr; |
| 36 | + __assign_str(name); | |
| 35 | 37 | __entry->bytes_req = s->object_size; |
| 36 | 38 | __entry->bytes_alloc = s->size; |
| 37 | 39 | __entry->gfp_flags = (__force unsigned long)gfp_flags; |
| @@ -41,9 +43,10 @@ TRACE_EVENT(kmem_cache_alloc, · 3 unmodified lines | ||
| 41 | 43 | (s->flags & SLAB_ACCOUNT)) : false; |
| 42 | 44 | ), |
| 43 | 45 | |
| 44 | − TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d accounted=%s", | |
| 46 | + TP_printk("call_site=%pS ptr=%p name=%s bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d accounted=%s", | |
| 45 | 47 | (void *)__entry->call_site, |
| 46 | 48 | __entry->ptr, |
| 49 | + __get_str(name), | |
| 47 | 50 | __entry->bytes_req, |
| 48 | 51 | __entry->bytes_alloc, |
| 49 | 52 | show_gfp_flags(__entry->gfp_flags), |