From: Lin Ming <ming.m.lin@intel.com>
To: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@elte.hu>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] perf probe: Add fastpath to do lookup by function name
Date: Thu, 24 Mar 2011 21:47:28 +0800 [thread overview]
Message-ID: <1300974448.2283.17.camel@localhost> (raw)
In-Reply-To: <4D8B0A13.8000008@hitachi.com>
On Thu, 2011-03-24 at 17:08 +0800, Masami Hiramatsu wrote:
> (2011/03/25 0:38), Lin Ming wrote:
> > The vmlinux file may have thousands of CUs.
> > We can lookup function name from .debug_pubnames section
> > to avoid the slow loop on CUs.
> >
> > Signed-off-by: Lin Ming <ming.m.lin@intel.com>
> > ---
> > tools/perf/util/probe-finder.c | 38 ++++++++++++++++++++++++++++++++++++++
> > tools/perf/util/probe-finder.h | 1 +
> > 2 files changed, 39 insertions(+), 0 deletions(-)
> >
> > diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
> > index 194f9e2..b2034c2 100644
> > --- a/tools/perf/util/probe-finder.c
> > +++ b/tools/perf/util/probe-finder.c
> > @@ -1876,6 +1876,30 @@ static int find_line_range_by_func(struct line_finder *lf)
> > return param.retval;
> > }
> >
> > +static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data)
> > +{
> > + struct line_finder *lf = data;
> > + struct line_range *lr = lf->lr;
> > +
> > + if (dwarf_offdie(dbg, gl->die_offset, &lf->sp_die)) {
> > + if (dwarf_tag(&lf->sp_die) != DW_TAG_subprogram)
> > + return DWARF_CB_OK;
> > +
> > + if (die_compare_name(&lf->sp_die, lr->function)) {
> > + if (!dwarf_offdie(dbg, gl->cu_offset, &lf->cu_die))
> > + return DWARF_CB_OK;
> > +
>
> Just one comment.
> Could you ensure that the decl_file of sp_die matches lr->file (by strtailcmp) here?
OK, so the file name compare with cu_find_realpath(..) can be removed,
as below.
This makes the lookup a bit more faster again.
Thanks, I'll post a new version with below changes.
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index b2034c2..38e4a05 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -1880,6 +1880,7 @@ static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data)
{
struct line_finder *lf = data;
struct line_range *lr = lf->lr;
+ const char *file;
if (dwarf_offdie(dbg, gl->die_offset, &lf->sp_die)) {
if (dwarf_tag(&lf->sp_die) != DW_TAG_subprogram)
@@ -1889,8 +1890,12 @@ static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data)
if (!dwarf_offdie(dbg, gl->cu_offset, &lf->cu_die))
return DWARF_CB_OK;
- if (lr->file && !cu_find_realpath(&lf->cu_die, lr->file))
- return DWARF_CB_OK;
+ if (lr->file) {
+ file = dwarf_decl_file(&lf->sp_die);
+
+ if (file && strtailcmp(file, lr->file))
+ return DWARF_CB_OK;
+ }
lf->found = 1;
return DWARF_CB_ABORT;
next prev parent reply other threads:[~2011-03-24 13:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 15:38 [PATCH] perf probe: Add fastpath to do lookup by function name Lin Ming
2011-03-24 7:58 ` Ingo Molnar
2011-03-24 8:38 ` Lin Ming
2011-03-24 8:47 ` Ingo Molnar
2011-03-24 9:08 ` Masami Hiramatsu
2011-03-24 13:47 ` Lin Ming [this message]
2011-03-24 14:09 ` [PATCH v2 -tip] " Lin Ming
2011-03-25 1:14 ` Masami Hiramatsu
2011-03-25 2:57 ` Arnaldo Carvalho de Melo
2011-03-25 6:33 ` Lin Ming
2011-03-25 8:30 ` Lin Ming
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=1300974448.2283.17.camel@localhost \
--to=ming.m.lin@intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=mingo@elte.hu \
/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