public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yannick Brosseau <scientist@fb.com>
To: <acme@kernel.org>, <mingo@redhat.com>, <paulus@samba.org>,
	<a.p.zijlstra@chello.nl>, <jolsa@kernel.org>,
	<ak@linux.intel.com>
Cc: <linux-kernel@vger.kernel.org>, <kernel-team@fb.com>,
	Yannick Brosseau <scientist@fb.com>
Subject: [PATCH] perf report: Fix sort__sym_cmp to also compare end of symbol
Date: Wed, 17 Jun 2015 16:41:10 -0700	[thread overview]
Message-ID: <1434584470-17771-1-git-send-email-scientist@fb.com> (raw)

When using a map file from a JIT, due to memory reuse, we can
obtain multiple symbols with the same start address but a different
length.
The symbols__find does check for the end so not doing it in sort__sym_cmp
was causing the hist_entry in the annotate part of a report to match to the
wrong entry, causing a fatal error.

Signed-off-by: Yannick Brosseau <scientist@fb.com>
---
 tools/perf/util/sort.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 4593f36..e226118 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -182,18 +182,16 @@ static int64_t _sort__addr_cmp(u64 left_ip, u64 right_ip)
 
 static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r)
 {
-	u64 ip_l, ip_r;
-
 	if (!sym_l || !sym_r)
 		return cmp_null(sym_l, sym_r);
 
 	if (sym_l == sym_r)
 		return 0;
 
-	ip_l = sym_l->start;
-	ip_r = sym_r->start;
+	if (sym_l->start != sym_r->start)
+		return (int64_t)(sym_r->start - sym_l->start);
 
-	return (int64_t)(ip_r - ip_l);
+	return (int64_t)(sym_r->end - sym_l->end);
 }
 
 static int64_t
-- 
2.1.4


             reply	other threads:[~2015-06-17 23:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-17 23:41 Yannick Brosseau [this message]
2015-06-17 23:53 ` [PATCH] perf report: Fix sort__sym_cmp to also compare end of symbol Jeff Epler
2015-06-17 23:55   ` Yannick Brosseau
2015-06-19 21:14     ` Arnaldo Carvalho de Melo
2015-06-19 23:18 ` [tip:perf/core] " tip-bot for Yannick Brosseau

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=1434584470-17771-1-git-send-email-scientist@fb.com \
    --to=scientist@fb.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=jolsa@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.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