tracing: kmem: convert call_site addresses to user friendly symbols
diff mbox series

Message ID 1563589361-18337-1-git-send-email-george_davis@mentor.com
State Superseded
Headers show
Series
  • tracing: kmem: convert call_site addresses to user friendly symbols
Related show

Commit Message

George G. Davis July 20, 2019, 2:22 a.m. UTC
While attempting to debug slub freelist pointer corruption bugs
caused by a module, I discovered that the kmem call_site addresses are
not at all user friendly for modules unless you manage to save a copy
of kallsyms for the running kernel beforehand.

So convert kmem call_site addresses to user friendly symbols which is
especially helpful for module callers when you don't have a copy of
kallsyms for the running kernel.

Signed-off-by: George G. Davis <george_davis@mentor.com>
---
 include/trace/events/kmem.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Steven Rostedt July 22, 2019, 1:43 p.m. UTC | #1
Looking at the kbuild report...

On Fri, 19 Jul 2019 22:22:40 -0400
"George G. Davis" <george_davis@mentor.com> wrote:

> diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
> index eb57e3037deb..ae18e61fa1c0 100644
> --- a/include/trace/events/kmem.h
> +++ b/include/trace/events/kmem.h
> @@ -35,7 +35,7 @@ DECLARE_EVENT_CLASS(kmem_alloc,
>  		__entry->gfp_flags	= gfp_flags;
>  	),
>  
> -	TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
> +	TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",

Note, %lx expects an unsigned long, %pS expects a pointer.

>  		__entry->call_site,

You need to change the above to: (void *)__entry->call_site,

-- Steve

>  		__entry->ptr,
>  		__entry->bytes_req,
George G. Davis July 22, 2019, 9:23 p.m. UTC | #2
Hello Steve,

On Mon, Jul 22, 2019 at 09:43:43AM -0400, Steven Rostedt wrote:
> 
> Looking at the kbuild report...
> 
> On Fri, 19 Jul 2019 22:22:40 -0400
> "George G. Davis" <george_davis@mentor.com> wrote:
> 
> > diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
> > index eb57e3037deb..ae18e61fa1c0 100644
> > --- a/include/trace/events/kmem.h
> > +++ b/include/trace/events/kmem.h
> > @@ -35,7 +35,7 @@ DECLARE_EVENT_CLASS(kmem_alloc,
> >  		__entry->gfp_flags	= gfp_flags;
> >  	),
> >  
> > -	TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
> > +	TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
> 
> Note, %lx expects an unsigned long, %pS expects a pointer.
> 
> >  		__entry->call_site,
> 
> You need to change the above to: (void *)__entry->call_site,

Oops, I should have paid more attention. Fixed.

Thanks!

> 
> -- Steve
> 
> >  		__entry->ptr,
> >  		__entry->bytes_req,

Patch
diff mbox series

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index eb57e3037deb..ae18e61fa1c0 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -35,7 +35,7 @@  DECLARE_EVENT_CLASS(kmem_alloc,
 		__entry->gfp_flags	= gfp_flags;
 	),
 
-	TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
+	TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
 		__entry->call_site,
 		__entry->ptr,
 		__entry->bytes_req,
@@ -88,7 +88,7 @@  DECLARE_EVENT_CLASS(kmem_alloc_node,
 		__entry->node		= node;
 	),
 
-	TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
+	TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
 		__entry->call_site,
 		__entry->ptr,
 		__entry->bytes_req,
@@ -131,7 +131,7 @@  DECLARE_EVENT_CLASS(kmem_free,
 		__entry->ptr		= ptr;
 	),
 
-	TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
+	TP_printk("call_site=%pS ptr=%p", __entry->call_site, __entry->ptr)
 );
 
 DEFINE_EVENT(kmem_free, kfree,