From: Chris Phlipot <cphlipot0@gmail.com>
To: adrian.hunter@intel.com, acme@kernel.org, peterz@infradead.org,
mingo@redhat.com
Cc: linux-kernel@vger.kernel.org, Chris Phlipot <cphlipot0@gmail.com>
Subject: [PATCH 1/2] perf tools: fix handling of zero-length symbols.
Date: Sat, 7 May 2016 02:16:59 -0700 [thread overview]
Message-ID: <1462612620-25008-1-git-send-email-cphlipot0@gmail.com> (raw)
This change introduces a fix to symbols__find, so that it is able to find
symbols of length zero (where start==end)
The current code has the following problem:
-The current implementation of symbols__find is unable to find any symbols
of length zero.
-The db-export framework explicitly creates zero length symbols at
locations where no symbol currently exists.
The combination of the two above behaviors results in behavior similar to
the example below.
1. addr_location is created for a sample, but symbol is unable to be
resolved.
2. db export creates an "unknown" symbol of length zero at that address
and inserts it into the dso.
3. A new sample comes in at the same address, but symbol__find is unable
to find the zero length symbol, so it is still unresolved.
4. db export sees the symbol is unresolved, and allocated a duplicate
symbol, even though it already did this in step 2.
This behavior continues every time an address without symbol information
is seen, which causes a very large number of these symbols to be
allocated.
The effect of this fix can be observed by looking at the contents of an
exported database before/after the fix
(generated with scripts/python/export-to-postgresql.py)
Ex.
BEFORE THE CHANGE:
example_db=# select count(*) from symbols;
count
--------
900213
(1 row)
example_db=# select count(*) from symbols where symbols.name='unknown';
count
--------
897355
(1 row)
example_db=# select count(*) from symbols where symbols.name!='unknown';
count
-------
2858
(1 row)
AFTER THE CHANGE:
example_db=# select count(*) from symbols;
count
-------
25217
(1 row)
example_db=# select count(*) from symbols where name='unknown';
count
-------
22359
(1 row)
example_db=# select count(*) from symbols where name!='unknown';
count
-------
2858
(1 row)
Signed-off-by: Chris Phlipot <cphlipot0@gmail.com>
---
tools/perf/util/symbol.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 415c4f6..e42bf9a 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -299,7 +299,9 @@ static struct symbol *symbols__find(struct rb_root *symbols, u64 ip)
while (n) {
struct symbol *s = rb_entry(n, struct symbol, rb_node);
- if (ip < s->start)
+ if (ip == s->start && s->start == s->end)
+ return s;
+ else if (ip < s->start)
n = n->rb_left;
else if (ip >= s->end)
n = n->rb_right;
--
2.7.4
next reply other threads:[~2016-05-07 9:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-07 9:16 Chris Phlipot [this message]
2016-05-07 9:17 ` [PATCH 2/2] perf script: fix incorrect python db-export error message Chris Phlipot
2016-05-10 20:31 ` [tip:perf/core] perf script: Fix " tip-bot for Chris Phlipot
2016-05-09 17:06 ` [PATCH 1/2] perf tools: fix handling of zero-length symbols Arnaldo Carvalho de Melo
2016-05-09 17:51 ` Chris Phlipot
2016-05-10 20:33 ` [tip:perf/core] perf symbols: Fix " tip-bot for Chris Phlipot
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=1462612620-25008-1-git-send-email-cphlipot0@gmail.com \
--to=cphlipot0@gmail.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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).