All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf probe: Fix probe definition for inlined functions
@ 2017-06-21 16:41 Björn Töpel
  2017-06-22 10:01 ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: Björn Töpel @ 2017-06-21 16:41 UTC (permalink / raw)
  To: LKML, Masami Hiramatsu, Arnaldo Carvalho de Melo
  Cc: Björn Töpel, linux-perf-users, magnus.karlsson

From: Björn Töpel <bjorn.topel@intel.com>

In commit 613f050d68a8 ("perf probe: Fix to probe on gcc generated
functions in modules"), the offset from symbol is, incorrectly, added
to the trace point address. This leads to incorrect probe trace points
for inlined functions and when using relative line number on symbols.

Prior this patch:
  $ perf probe -m nf_nat -D in_range
  p:probe/in_range nf_nat:in_range.isra.9+0
  $ perf probe -m i40e -D i40e_clean_rx_irq
  p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+2212
  $ perf probe -m i40e -D i40e_clean_rx_irq:16
  p:probe/i40e_clean_rx_irq i40e:i40e_lan_xmit_frame+626

After:
  $ perf probe -m nf_nat -D in_range
  p:probe/in_range nf_nat:in_range.isra.9+0
  $ perf probe -m i40e -D i40e_clean_rx_irq
  p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+1106
  $ perf probe -m i40e -D i40e_clean_rx_irq:16
  p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+2665

Fixes: 613f050d68a8 ("perf probe: Fix to probe on gcc generated functions in modules")
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
---
 tools/perf/util/probe-event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 84e7e698411e..a2670e9d652d 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -619,7 +619,7 @@ static int post_process_probe_trace_point(struct probe_trace_point *tp,
 					   struct map *map, unsigned long offs)
 {
 	struct symbol *sym;
-	u64 addr = tp->address + tp->offset - offs;
+	u64 addr = tp->address - offs;
 
 	sym = map__find_symbol(map, addr);
 	if (!sym)
-- 
2.7.4

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

* Re: [PATCH] perf probe: Fix probe definition for inlined functions
  2017-06-21 16:41 [PATCH] perf probe: Fix probe definition for inlined functions Björn Töpel
@ 2017-06-22 10:01 ` Masami Hiramatsu
  2017-06-22 16:16   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Masami Hiramatsu @ 2017-06-22 10:01 UTC (permalink / raw)
  To: Björn Töpel
  Cc: LKML, Arnaldo Carvalho de Melo, Björn Töpel,
	linux-perf-users, magnus.karlsson

On Wed, 21 Jun 2017 18:41:34 +0200
Björn Töpel <bjorn.topel@gmail.com> wrote:

> From: Björn Töpel <bjorn.topel@intel.com>
> 
> In commit 613f050d68a8 ("perf probe: Fix to probe on gcc generated
> functions in modules"), the offset from symbol is, incorrectly, added
> to the trace point address. This leads to incorrect probe trace points
> for inlined functions and when using relative line number on symbols.
> 
> Prior this patch:
>   $ perf probe -m nf_nat -D in_range
>   p:probe/in_range nf_nat:in_range.isra.9+0
>   $ perf probe -m i40e -D i40e_clean_rx_irq
>   p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+2212
>   $ perf probe -m i40e -D i40e_clean_rx_irq:16
>   p:probe/i40e_clean_rx_irq i40e:i40e_lan_xmit_frame+626
> 
> After:
>   $ perf probe -m nf_nat -D in_range
>   p:probe/in_range nf_nat:in_range.isra.9+0
>   $ perf probe -m i40e -D i40e_clean_rx_irq
>   p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+1106
>   $ perf probe -m i40e -D i40e_clean_rx_irq:16
>   p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+2665

OK, I've confirmed it. This bug also affects -D option for
offline probes...

$ ./perf probe -k ~/kbin/linux.x86_64/vmlinux -vD vfs_read:11
probe-definition(0): vfs_read:11
[...]
Try to find probe point from debuginfo.
Matched function: vfs_read [28b211e]
Probe point found: vfs_read+90  <- here vfs_read+90
Found 1 probe_trace_events.
p:probe/vfs_read vfs_read+180   <- here vfs_read+180 = 90+90

So offset to be doubled...

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>

Arnaldo, this should go to urgent/stable. 

Thank you!

> 
> Fixes: 613f050d68a8 ("perf probe: Fix to probe on gcc generated functions in modules")
> Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
> ---
>  tools/perf/util/probe-event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 84e7e698411e..a2670e9d652d 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -619,7 +619,7 @@ static int post_process_probe_trace_point(struct probe_trace_point *tp,
>  					   struct map *map, unsigned long offs)
>  {
>  	struct symbol *sym;
> -	u64 addr = tp->address + tp->offset - offs;
> +	u64 addr = tp->address - offs;
>  
>  	sym = map__find_symbol(map, addr);
>  	if (!sym)
> -- 
> 2.7.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [PATCH] perf probe: Fix probe definition for inlined functions
  2017-06-22 10:01 ` Masami Hiramatsu
@ 2017-06-22 16:16   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-06-22 16:16 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Björn Töpel, LKML, Björn Töpel,
	linux-perf-users, magnus.karlsson

Em Thu, Jun 22, 2017 at 07:01:38PM +0900, Masami Hiramatsu escreveu:
> On Wed, 21 Jun 2017 18:41:34 +0200
> Björn Töpel <bjorn.topel@gmail.com> wrote:
> 
> > From: Björn Töpel <bjorn.topel@intel.com>
> > 
> > In commit 613f050d68a8 ("perf probe: Fix to probe on gcc generated
> > functions in modules"), the offset from symbol is, incorrectly, added
> > to the trace point address. This leads to incorrect probe trace points
> > for inlined functions and when using relative line number on symbols.
> > 
> > Prior this patch:
> >   $ perf probe -m nf_nat -D in_range
> >   p:probe/in_range nf_nat:in_range.isra.9+0
> >   $ perf probe -m i40e -D i40e_clean_rx_irq
> >   p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+2212
> >   $ perf probe -m i40e -D i40e_clean_rx_irq:16
> >   p:probe/i40e_clean_rx_irq i40e:i40e_lan_xmit_frame+626
> > 
> > After:
> >   $ perf probe -m nf_nat -D in_range
> >   p:probe/in_range nf_nat:in_range.isra.9+0
> >   $ perf probe -m i40e -D i40e_clean_rx_irq
> >   p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+1106
> >   $ perf probe -m i40e -D i40e_clean_rx_irq:16
> >   p:probe/i40e_clean_rx_irq i40e:i40e_napi_poll+2665
> 
> OK, I've confirmed it. This bug also affects -D option for
> offline probes...
> 
> $ ./perf probe -k ~/kbin/linux.x86_64/vmlinux -vD vfs_read:11
> probe-definition(0): vfs_read:11
> [...]
> Try to find probe point from debuginfo.
> Matched function: vfs_read [28b211e]
> Probe point found: vfs_read+90  <- here vfs_read+90
> Found 1 probe_trace_events.
> p:probe/vfs_read vfs_read+180   <- here vfs_read+180 = 90+90
> 
> So offset to be doubled...
> 
> Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
> 
> Arnaldo, this should go to urgent/stable. 

Thanks for checking, I'll get it into tools/urgent and CC stable, the
Fixes tag should be enough for stable maintainers to figure out what
kernels should get it.

- Arnaldo

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

end of thread, other threads:[~2017-06-22 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21 16:41 [PATCH] perf probe: Fix probe definition for inlined functions Björn Töpel
2017-06-22 10:01 ` Masami Hiramatsu
2017-06-22 16:16   ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.