mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] tracing: kmem: convert call_site addresses to user friendly symbols
@ 2019-07-20  2:22 George G. Davis
  2019-07-21  5:26 ` kbuild test robot
  2019-07-22 13:43 ` Steven Rostedt
  0 siblings, 2 replies; 4+ messages in thread
From: George G. Davis @ 2019-07-20  2:22 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar, George G. Davis, open list

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(-)

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,
-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tracing: kmem: convert call_site addresses to user friendly symbols
  2019-07-20  2:22 [PATCH] tracing: kmem: convert call_site addresses to user friendly symbols George G. Davis
@ 2019-07-21  5:26 ` kbuild test robot
  2019-07-22 13:43 ` Steven Rostedt
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2019-07-21  5:26 UTC (permalink / raw)
  To: George G. Davis
  Cc: kbuild-all, Steven Rostedt, Ingo Molnar, George G. Davis, open list

[-- Attachment #1: Type: text/plain, Size: 5881 bytes --]

Hi "George,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.2 next-20190719]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/George-G-Davis/tracing-kmem-convert-call_site-addresses-to-user-friendly-symbols/20190721-094536
config: arm-omap2plus_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:102:0,
                    from include/trace/events/kmem.h:321,
                    from mm/slab_common.c:27:
   include/trace/events/kmem.h: In function 'trace_raw_output_kmem_alloc':
>> include/trace/events/kmem.h:38:12: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'long unsigned int' [-Wformat=]
     TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
               ^
   include/trace/trace_events.h:360:22: note: in definition of macro 'DECLARE_EVENT_CLASS'
     trace_seq_printf(s, print);     \
                         ^~~~~
>> include/trace/events/kmem.h:38:2: note: in expansion of macro 'TP_printk'
     TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
     ^~~~~~~~~
   In file included from include/trace/trace_events.h:394:0,
                    from include/trace/define_trace.h:102,
                    from include/trace/events/kmem.h:321,
                    from mm/slab_common.c:27:
   include/trace/events/kmem.h:38:24: note: format string is defined here
     TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
                          ~^
                          %ld
   In file included from include/trace/define_trace.h:102:0,
                    from include/trace/events/kmem.h:321,
                    from mm/slab_common.c:27:
   include/trace/events/kmem.h: In function 'trace_raw_output_kmem_alloc_node':
   include/trace/events/kmem.h:91:12: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'long unsigned int' [-Wformat=]
     TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
               ^
   include/trace/trace_events.h:360:22: note: in definition of macro 'DECLARE_EVENT_CLASS'
     trace_seq_printf(s, print);     \
                         ^~~~~
   include/trace/events/kmem.h:91:2: note: in expansion of macro 'TP_printk'
     TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
     ^~~~~~~~~
   In file included from include/trace/trace_events.h:394:0,
                    from include/trace/define_trace.h:102,
                    from include/trace/events/kmem.h:321,
                    from mm/slab_common.c:27:
   include/trace/events/kmem.h:91:24: note: format string is defined here
     TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
                          ~^
                          %ld
   In file included from include/trace/define_trace.h:102:0,
                    from include/trace/events/kmem.h:321,
                    from mm/slab_common.c:27:
   include/trace/events/kmem.h: In function 'trace_raw_output_kmem_free':
   include/trace/events/kmem.h:134:12: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'long unsigned int' [-Wformat=]
     TP_printk("call_site=%pS ptr=%p", __entry->call_site, __entry->ptr)
               ^
   include/trace/trace_events.h:360:22: note: in definition of macro 'DECLARE_EVENT_CLASS'
     trace_seq_printf(s, print);     \
                         ^~~~~
   include/trace/events/kmem.h:134:2: note: in expansion of macro 'TP_printk'
     TP_printk("call_site=%pS ptr=%p", __entry->call_site, __entry->ptr)
     ^~~~~~~~~
   In file included from include/trace/trace_events.h:394:0,
                    from include/trace/define_trace.h:102,
                    from include/trace/events/kmem.h:321,
                    from mm/slab_common.c:27:
   include/trace/events/kmem.h:134:24: note: format string is defined here
     TP_printk("call_site=%pS ptr=%p", __entry->call_site, __entry->ptr)
                          ~^
                          %ld

vim +38 include/trace/events/kmem.h

    13	
    14		TP_PROTO(unsigned long call_site,
    15			 const void *ptr,
    16			 size_t bytes_req,
    17			 size_t bytes_alloc,
    18			 gfp_t gfp_flags),
    19	
    20		TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
    21	
    22		TP_STRUCT__entry(
    23			__field(	unsigned long,	call_site	)
    24			__field(	const void *,	ptr		)
    25			__field(	size_t,		bytes_req	)
    26			__field(	size_t,		bytes_alloc	)
    27			__field(	gfp_t,		gfp_flags	)
    28		),
    29	
    30		TP_fast_assign(
    31			__entry->call_site	= call_site;
    32			__entry->ptr		= ptr;
    33			__entry->bytes_req	= bytes_req;
    34			__entry->bytes_alloc	= bytes_alloc;
    35			__entry->gfp_flags	= gfp_flags;
    36		),
    37	
  > 38		TP_printk("call_site=%pS ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
    39			__entry->call_site,
    40			__entry->ptr,
    41			__entry->bytes_req,
    42			__entry->bytes_alloc,
    43			show_gfp_flags(__entry->gfp_flags))
    44	);
    45	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 36715 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tracing: kmem: convert call_site addresses to user friendly symbols
  2019-07-20  2:22 [PATCH] tracing: kmem: convert call_site addresses to user friendly symbols George G. Davis
  2019-07-21  5:26 ` kbuild test robot
@ 2019-07-22 13:43 ` Steven Rostedt
  2019-07-22 21:23   ` George G. Davis
  1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2019-07-22 13:43 UTC (permalink / raw)
  To: George G. Davis; +Cc: Ingo Molnar, open list


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,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tracing: kmem: convert call_site addresses to user friendly symbols
  2019-07-22 13:43 ` Steven Rostedt
@ 2019-07-22 21:23   ` George G. Davis
  0 siblings, 0 replies; 4+ messages in thread
From: George G. Davis @ 2019-07-22 21:23 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, open list

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,

-- 
Regards,
George

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-22 21:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-20  2:22 [PATCH] tracing: kmem: convert call_site addresses to user friendly symbols George G. Davis
2019-07-21  5:26 ` kbuild test robot
2019-07-22 13:43 ` Steven Rostedt
2019-07-22 21:23   ` George G. Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome