linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org,
	eranian@google.com, paulus@samba.org, hpa@zytor.com,
	mingo@kernel.org, a.p.zijlstra@chello.nl, namhyung.kim@lge.com,
	rodrigo@sdfg.com.ar, namhyung@kernel.org, jolsa@redhat.com,
	fweisbec@gmail.com, tglx@linutronix.de, asharma@fb.com
Subject: [tip:perf/core] perf sort: Compare addresses if no symbol info
Date: Sun, 12 Jan 2014 10:30:57 -0800	[thread overview]
Message-ID: <tip-2037be53b2bceac3c2e648b8ff3fd62e21af2d35@git.kernel.org> (raw)
In-Reply-To: <1387344086-12744-2-git-send-email-namhyung@kernel.org>

Commit-ID:  2037be53b2bceac3c2e648b8ff3fd62e21af2d35
Gitweb:     http://git.kernel.org/tip/2037be53b2bceac3c2e648b8ff3fd62e21af2d35
Author:     Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Wed, 18 Dec 2013 14:21:09 +0900
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 18 Dec 2013 14:42:30 -0300

perf sort: Compare addresses if no symbol info

If a hist entry doesn't have symbol information, compare it with its
address.  Currently it only compares its level or whether it's NULL.

This can lead to an undesired result like an overhead exceeds 100%
especially when callchain accumulation is enabled by later patch.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arun Sharma <asharma@fb.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Rodrigo Campos <rodrigo@sdfg.com.ar>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1387344086-12744-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/sort.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 8b0bb1f..68a4fd2 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -161,6 +161,11 @@ struct sort_entry sort_dso = {
 
 /* --sort symbol */
 
+static int64_t _sort__addr_cmp(u64 left_ip, u64 right_ip)
+{
+	return (int64_t)(right_ip - left_ip);
+}
+
 static int64_t _sort__sym_cmp(struct symbol *sym_l, struct symbol *sym_r)
 {
 	u64 ip_l, ip_r;
@@ -183,7 +188,7 @@ sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
 	int64_t ret;
 
 	if (!left->ms.sym && !right->ms.sym)
-		return right->level - left->level;
+		return _sort__addr_cmp(left->ip, right->ip);
 
 	/*
 	 * comparing symbol address alone is not enough since it's a
@@ -372,7 +377,7 @@ sort__sym_from_cmp(struct hist_entry *left, struct hist_entry *right)
 	struct addr_map_symbol *from_r = &right->branch_info->from;
 
 	if (!from_l->sym && !from_r->sym)
-		return right->level - left->level;
+		return _sort__addr_cmp(from_l->addr, from_r->addr);
 
 	return _sort__sym_cmp(from_l->sym, from_r->sym);
 }
@@ -384,7 +389,7 @@ sort__sym_to_cmp(struct hist_entry *left, struct hist_entry *right)
 	struct addr_map_symbol *to_r = &right->branch_info->to;
 
 	if (!to_l->sym && !to_r->sym)
-		return right->level - left->level;
+		return _sort__addr_cmp(to_l->addr, to_r->addr);
 
 	return _sort__sym_cmp(to_l->sym, to_r->sym);
 }

  parent reply	other threads:[~2014-01-12 18:32 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18  5:21 [RFC/PATCHSET 00/18] perf report: Add support to accumulate hist periods (v3) Namhyung Kim
2013-12-18  5:21 ` [PATCH 01/18] perf sort: Compare addresses if no symbol info Namhyung Kim
2013-12-18 15:38   ` Jiri Olsa
2013-12-18 17:35     ` Arnaldo Carvalho de Melo
2013-12-18 17:39       ` Arnaldo Carvalho de Melo
2013-12-19  7:17         ` Namhyung Kim
2014-01-12 18:30   ` tip-bot for Namhyung Kim [this message]
2013-12-18  5:21 ` [PATCH 02/18] perf sort: Do not compare dso again Namhyung Kim
2013-12-18 15:40   ` Jiri Olsa
2014-01-12 18:31   ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-18  5:21 ` [PATCH 03/18] perf tools: Do not pass period and weight to add_hist_entry() Namhyung Kim
2013-12-18 15:41   ` Jiri Olsa
2014-01-12 18:31   ` [tip:perf/core] perf hists: " tip-bot for Namhyung Kim
2013-12-18  5:21 ` [PATCH 04/18] perf tools: Introduce struct add_entry_iter Namhyung Kim
2013-12-18 15:50   ` Jiri Olsa
2013-12-19  7:15     ` Namhyung Kim
2013-12-18  5:21 ` [PATCH 05/18] perf hists: Convert hist entry functions to use struct he_stat Namhyung Kim
2013-12-18  5:21 ` [PATCH 06/18] perf hists: Add support for accumulated stat of hist entry Namhyung Kim
2013-12-18  5:21 ` [PATCH 07/18] perf hists: Check if accumulated when adding a " Namhyung Kim
2013-12-18  5:21 ` [PATCH 08/18] perf hists: Accumulate hist entry stat based on the callchain Namhyung Kim
2013-12-18  5:21 ` [PATCH 09/18] perf tools: Update cpumode for each cumulative entry Namhyung Kim
2013-12-18  5:21 ` [PATCH 10/18] perf report: Cache cumulative callchains Namhyung Kim
2013-12-18  5:21 ` [PATCH 11/18] perf hists: Sort hist entries by accumulated period Namhyung Kim
2013-12-18  5:21 ` [PATCH 12/18] perf ui/hist: Add support to accumulated hist stat Namhyung Kim
2013-12-18  5:21 ` [PATCH 13/18] perf ui/browser: " Namhyung Kim
2013-12-18  5:21 ` [PATCH 14/18] perf ui/gtk: " Namhyung Kim
2013-12-18  5:21 ` [PATCH 15/18] perf tools: Apply percent-limit to cumulative percentage Namhyung Kim
2013-12-18  5:21 ` [PATCH 16/18] perf tools: Add more hpp helper functions Namhyung Kim
2013-12-18  5:21 ` [PATCH 17/18] perf report: Add --cumulate option Namhyung Kim
2013-12-18  5:21 ` [PATCH 18/18] perf report: Add report.cumulate config option Namhyung Kim
2013-12-18  9:46 ` [RFC/PATCHSET 00/18] perf report: Add support to accumulate hist periods (v3) Ingo Molnar
2013-12-18 10:38   ` Arun Sharma
2013-12-18 14:39     ` Namhyung Kim
2013-12-23  9:16       ` Arun Sharma
2013-12-24  7:59         ` Namhyung Kim
2013-12-18 14:37   ` Namhyung Kim
2013-12-18 17:47     ` Arnaldo Carvalho de Melo
2013-12-19  7:20       ` 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=tip-2037be53b2bceac3c2e648b8ff3fd62e21af2d35@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=asharma@fb.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    --cc=rodrigo@sdfg.com.ar \
    --cc=tglx@linutronix.de \
    /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).