linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH 9/9] perf tools: Fix srcline sort key behavior
Date: Wed, 11 Sep 2013 14:09:33 +0900	[thread overview]
Message-ID: <1378876173-13363-10-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1378876173-13363-1-git-send-email-namhyung@kernel.org>

From: Namhyung Kim <namhyung.kim@lge.com>

Currently the srcline sort key compares ip rather than srcline info.
I guess this was due to a performance reason to run external addr2line
utility.  Now we have implemented the functionality inside, use the
srcline info when comparing hist entries.

Also constantly print "??:0" string for unknown srcline rather than
printing ip.

Reviewed-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/sort.c | 41 ++++++++++++++++++++---------------------
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 58cfe69d3a6c..082480579861 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -243,33 +243,32 @@ struct sort_entry sort_sym = {
 static int64_t
 sort__srcline_cmp(struct hist_entry *left, struct hist_entry *right)
 {
-	return (int64_t)(right->ip - left->ip);
+	if (!left->srcline) {
+		if (!left->ms.map)
+			left->srcline = SRCLINE_UNKNOWN;
+		else {
+			struct map *map = left->ms.map;
+			left->srcline = get_srcline(map->dso,
+					    map__rip_2objdump(map, left->ip));
+		}
+	}
+	if (!right->srcline) {
+		if (!right->ms.map)
+			right->srcline = SRCLINE_UNKNOWN;
+		else {
+			struct map *map = right->ms.map;
+			right->srcline = get_srcline(map->dso,
+					    map__rip_2objdump(map, right->ip));
+		}
+	}
+	return strcmp(left->srcline, right->srcline);
 }
 
 static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf,
 					size_t size,
 					unsigned int width __maybe_unused)
 {
-	FILE *fp = NULL;
-	char *path = self->srcline;
-
-	if (path != NULL)
-		goto out_path;
-
-	if (!self->ms.map)
-		goto out_ip;
-
-	path = get_srcline(self->ms.map->dso, self->ip);
-	self->srcline = path;
-
-out_path:
-	if (fp)
-		pclose(fp);
-	return repsep_snprintf(bf, size, "%s", path);
-out_ip:
-	if (fp)
-		pclose(fp);
-	return repsep_snprintf(bf, size, "%-#*llx", BITS_PER_LONG / 4, self->ip);
+	return repsep_snprintf(bf, size, "%s", self->srcline);
 }
 
 struct sort_entry sort_srcline = {
-- 
1.7.11.7


  parent reply	other threads:[~2013-09-11  5:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11  5:09 [PATCHSET 0/9] perf tools: Enhance and correct srcline behavior (v2) Namhyung Kim
2013-09-11  5:09 ` [PATCH 1/9] perf sort: Fix a memory leak on srcline Namhyung Kim
2013-10-15  5:25   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-09-11  5:09 ` [PATCH 2/9] perf annotate: Reuse path from the result of addr2line Namhyung Kim
2013-10-15  5:25   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-09-11  5:09 ` [PATCH 3/9] perf hists: Free srcline when freeing hist_entry Namhyung Kim
2013-10-15  5:26   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-09-11  5:09 ` [PATCH 4/9] perf tools: Factor out get/free_srcline() Namhyung Kim
2013-10-15  5:26   ` [tip:perf/core] perf annotate: " tip-bot for Namhyung Kim
2013-09-11  5:09 ` [PATCH 5/9] perf tools: Do not try to call addr2line for non-binary files Namhyung Kim
2013-10-15  5:26   ` [tip:perf/core] perf tools: Do not try to call addr2line on " tip-bot for Namhyung Kim
2013-09-11  5:09 ` [PATCH 6/9] perf tools: Pass dso instead of dso_name to get_srcline() Namhyung Kim
2013-10-15  5:26   ` [tip:perf/core] perf annotate: " tip-bot for Namhyung Kim
2013-09-11  5:09 ` [PATCH 7/9] perf tools: Save failed result of get_srcline() Namhyung Kim
2013-10-15  5:26   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-09-11  5:09 ` [PATCH 8/9] perf tools: Implement addr2line directly using libbfd Namhyung Kim
2013-10-15  5:26   ` [tip:perf/core] " tip-bot for Roberto Vitillo
2013-09-11  5:09 ` Namhyung Kim [this message]
2013-10-15  5:26   ` [tip:perf/core] perf tools: Fix srcline sort key behavior tip-bot for Namhyung Kim
  -- strict thread matches above, loose matches on Subject: below --
2013-08-01  2:55 [PATCH 0/9] perf tools: Enhance and correct srcline behavior Namhyung Kim
2013-08-01  2:55 ` [PATCH 9/9] perf tools: Fix srcline sort key behavior Namhyung Kim

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=1378876173-13363-10-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.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;
as well as URLs for NNTP newsgroup(s).