linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [BUGFIX PATCH 3/6] perf/probe: Fix to probe an inline function which has no entry pc
Date: Sat, 26 Oct 2019 17:04:37 +0900	[thread overview]
Message-ID: <20191026170437.22719a025f59111c4213b701@kernel.org> (raw)
In-Reply-To: <20191025143910.GC15617@kernel.org>

Hi Arnaldo 

On Fri, 25 Oct 2019 11:39:10 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> 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 ~]#

Ah, sorry, it was my mistake, when I copy the command, I lacked -k option,
which means using offline kernel image. I'll update the patch description
and resend it.

With online kernel (same buildid), perf-probe modifies the address with
_text based offset for avoiding mixed up with same-name symbols. Even if
there are several same-name symbols (like local functions),  the
"_text + offset" expression can identify one of them.
However, if the buildid of the given kernel image (specified by -k option)
doesn't match, it generates event definition based on the symbol name.
Hmm, I think we can use _text even with off-line kernel, I'll check it.

> > 
> > 
> > ----
> > 
> > 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 ~]#

So, _text + offset is normal behavior. I'll try to renew the example
with actual options. Sorry for confusing.

Thank you,


> 
> 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@kernel.org>
> > > ---
> > >  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


-- 
Masami Hiramatsu <mhiramat@kernel.org>

  reply	other threads:[~2019-10-26  8:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25  8:46 [BUGFIX PATCH 0/6] perf/probe: Additional fixes for range only functions Masami Hiramatsu
2019-10-25  8:46 ` [BUGFIX PATCH 1/6] perf/probe: Fix wrong address verification Masami Hiramatsu
2019-10-25 12:14   ` Arnaldo Carvalho de Melo
2019-10-25 12:36     ` Masami Hiramatsu
2019-10-25 14:28       ` Arnaldo Carvalho de Melo
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:46 ` [BUGFIX PATCH 2/6] perf/probe: Fix to probe a function which has no entry pc Masami Hiramatsu
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:46 ` [BUGFIX PATCH 3/6] perf/probe: Fix to probe an inline " Masami Hiramatsu
2019-10-25 14:35   ` Arnaldo Carvalho de Melo
2019-10-25 14:39     ` Arnaldo Carvalho de Melo
2019-10-26  8:04       ` Masami Hiramatsu [this message]
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:46 ` [BUGFIX PATCH 4/6] perf/probe: Fix to list probe event with correct line number Masami Hiramatsu
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:47 ` [BUGFIX PATCH 5/6] perf/probe: Fix to show inlined function callsite without entry_pc Masami Hiramatsu
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu
2019-10-25  8:47 ` [BUGFIX PATCH 6/6] perf/probe: Fix to show ranges of variables in functions " Masami Hiramatsu
2019-11-12 11:18   ` [tip: perf/core] perf probe: " tip-bot2 for Masami Hiramatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191026170437.22719a025f59111c4213b701@kernel.org \
    --to=mhiramat@kernel.org \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).