Re: [BUGFIX PATCH 3/6] perf/probe: Fix to probe an inline function which has no entry pc

From: Arnaldo Carvalho de Melo
Date: Fri Oct 25 2019 - 10:39:17 EST


Em Fri, Oct 25, 2019 at 11:35:13AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Oct 25, 2019 at 05:46:43PM +0900, Masami Hiramatsu escreveu:
> > Fix perf probe to probe an inlne function which has no entry pc
> > or low pc but only has ranges attribute.
> >
> > This seems very rare case, but I could find a few examples, as
> > same as probe_point_search_cb(), use die_entrypc() to get the
> > entry address in probe_point_inline_cb() too.
> >
> > Without this patch,
> > # tools/perf/perf probe -D __amd_put_nb_event_constraints
> > Failed to get entry address of __amd_put_nb_event_constraints.
> > Probe point '__amd_put_nb_event_constraints' not found.
> > Error: Failed to add events.
> >
> > With this patch,
> > # tools/perf/perf probe -D __amd_put_nb_event_constraints
> > p:probe/__amd_put_nb_event_constraints amd_put_event_constraints+43
>
> Here I got it slightly different:
>
> Before:
>
> [root@quaco ~]# perf probe -D __amd_put_nb_event_constraints
> Failed to get entry address of __amd_put_nb_event_constraints.
> Probe point '__amd_put_nb_event_constraints' not found.
> Error: Failed to add events.
> [root@quaco ~]#
>
> After:
>
> [root@quaco ~]# perf probe -D __amd_put_nb_event_constraints
> p:probe/__amd_put_nb_event_constraints _text+33789
> [root@quaco ~]#
>
>
> ----
>
> I'm now checking if this is because I applied patch 4/6 before 3/6

Nope, even then:

[root@quaco ~]# perf probe -D __amd_put_nb_event_constraints
p:probe/__amd_put_nb_event_constraints _text+33789
[root@quaco ~]# grep __amd_put_nb_event_constraints /proc/kallsyms
[root@quaco ~]#

Ok, maybe this may help:

[root@quaco ~]# perf probe -v -D __amd_put_nb_event_constraints |& grep vmlinux
Looking at the vmlinux_path (8 entries long)
Using /usr/lib/debug/lib/modules/5.2.18-200.fc30.x86_64/vmlinux for symbols
Open Debuginfo file: /usr/lib/debug/lib/modules/5.2.18-200.fc30.x86_64/vmlinux
[root@quaco ~]#

[root@quaco ~]# readelf -wi /usr/lib/debug/lib/modules/5.2.18-200.fc30.x86_64/vmlinux | grep __amd_put_nb_event_constraints -B1 -A7
<1><192640>: Abbrev Number: 123 (DW_TAG_subprogram)
<192641> DW_AT_name : (indirect string, offset: 0x299576): __amd_put_nb_event_constraints
<192645> DW_AT_decl_file : 1
<192646> DW_AT_decl_line : 361
<192648> DW_AT_decl_column : 13
<192649> DW_AT_prototyped : 1
<192649> DW_AT_inline : 1 (inlined)
<19264a> DW_AT_sibling : <0x192700>
<2><19264e>: Abbrev Number: 38 (DW_TAG_formal_parameter)
^C
[root@quaco ~]#

Continuing to process the other patches...

- Arnaldo

> > Fixes: 4ea42b181434 ("perf: Add perf probe subcommand, a kprobe-event setup helper")
> > Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> > ---
> > tools/perf/util/probe-finder.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> > index 71633f55f045..2fa932bcf960 100644
> > --- a/tools/perf/util/probe-finder.c
> > +++ b/tools/perf/util/probe-finder.c
> > @@ -930,7 +930,7 @@ static int probe_point_inline_cb(Dwarf_Die *in_die, void *data)
> > ret = find_probe_point_lazy(in_die, pf);
> > else {
> > /* Get probe address */
> > - if (dwarf_entrypc(in_die, &addr) != 0) {
> > + if (die_entrypc(in_die, &addr) != 0) {
> > pr_warning("Failed to get entry address of %s.\n",
> > dwarf_diename(in_die));
> > return -ENOENT;
>
> --
>
> - Arnaldo

--

- Arnaldo