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>,
Frederic Weisbecker <fweisbec@gmail.com>,
Stephane Eranian <eranian@google.com>,
Jiri Olsa <jolsa@redhat.com>,
Rodrigo Campos <rodrigo@sdfg.com.ar>,
Arun Sharma <asharma@fb.com>
Subject: [PATCH 09/14] perf hists: Sort hist entries by accumulated period
Date: Thu, 31 Oct 2013 15:56:11 +0900 [thread overview]
Message-ID: <1383202576-28141-10-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1383202576-28141-1-git-send-email-namhyung@kernel.org>
From: Namhyung Kim <namhyung.kim@lge.com>
When callchain accumulation is requested, we need to sort the entries
by accumulated period value. When accumulated periods of two entries
are same (i.e. single path callchain) put the caller above since
accumulation tends to put callers on higher position for obvious
reason.
Cc: Arun Sharma <asharma@fb.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-report.c | 13 +++++++++++++
tools/perf/util/hist.c | 12 ++++++++++++
2 files changed, 25 insertions(+)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1a0de9a4a568..3b626127c8d6 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -349,6 +349,13 @@ iter_add_single_normal_entry(struct add_entry_iter *iter, struct addr_location *
if (he == NULL)
return -ENOMEM;
+ /*
+ * This is for putting parents upward during output resort iff
+ * only a child gets sampled. See hist_entry__sort_on_period().
+ */
+ he->callchain->max_depth = callchain_cursor.nr - callchain_cursor.pos;
+ he->callchain->max_depth += PERF_MAX_STACK_DEPTH + 1;
+
iter->he = he;
return 0;
}
@@ -559,6 +566,12 @@ iter_add_next_cumulative_entry(struct add_entry_iter *iter,
return -ENOMEM;
/*
+ * This is for putting parents upward during output resort iff
+ * only a child gets sampled. See hist_entry__sort_on_period().
+ */
+ he->callchain->max_depth = callchain_cursor.nr - callchain_cursor.pos;
+
+ /*
* Only in the TUI browser we are doing integrated annotation,
* so we don't allocated the extra space needed because the stdio
* code will not use it.
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 229329a20ba5..c1d5d6b43bba 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -623,6 +623,18 @@ static int hist_entry__sort_on_period(struct hist_entry *a,
struct hist_entry *pair;
u64 *periods_a, *periods_b;
+ if (callchain_param.mode == CHAIN_CUMULATIVE) {
+ /*
+ * Put caller above callee when they have equal period.
+ */
+ if (a->stat_acc->period != b->stat_acc->period)
+ return a->stat_acc->period > b->stat_acc->period ? 1 : -1;
+
+ if (a->callchain->max_depth != b->callchain->max_depth)
+ return a->callchain->max_depth < b->callchain->max_depth ?
+ 1 : -1;
+ }
+
ret = period_cmp(a->stat.period, b->stat.period);
if (ret || !symbol_conf.event_group)
return ret;
--
1.7.11.7
next prev parent reply other threads:[~2013-10-31 6:57 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-31 6:56 [RFC/PATCHSET 00/14] perf report: Add support to accumulate hist periods (v2) Namhyung Kim
2013-10-31 6:56 ` [PATCH 01/14] perf tools: Consolidate __hists__add_*entry() Namhyung Kim
2013-11-01 11:56 ` Jiri Olsa
2013-11-06 5:43 ` [tip:perf/core] perf hists: " tip-bot for Namhyung Kim
2013-10-31 6:56 ` [PATCH 02/14] perf tools: Introduce struct add_entry_iter Namhyung Kim
2013-11-01 12:07 ` Jiri Olsa
2013-11-05 7:09 ` Namhyung Kim
2013-11-01 12:09 ` Jiri Olsa
2013-11-05 7:16 ` Namhyung Kim
2013-10-31 6:56 ` [PATCH 03/14] perf hists: Convert hist entry functions to use struct he_stat Namhyung Kim
2013-11-04 23:45 ` Arnaldo Carvalho de Melo
2013-11-05 7:17 ` Namhyung Kim
2013-10-31 6:56 ` [PATCH 04/14] perf hists: Add support for accumulated stat of hist entry Namhyung Kim
2013-10-31 6:56 ` [PATCH 05/14] perf hists: Check if accumulated when adding a " Namhyung Kim
2013-10-31 6:56 ` [PATCH 06/14] perf hists: Accumulate hist entry stat based on the callchain Namhyung Kim
2013-10-31 6:56 ` [PATCH 07/14] perf tools: Update cpumode for each cumulative entry Namhyung Kim
2013-11-01 12:55 ` Jiri Olsa
2013-11-05 7:41 ` Namhyung Kim
2013-10-31 6:56 ` [PATCH 08/14] perf report: Cache cumulative callchains Namhyung Kim
2013-10-31 11:13 ` Rodrigo Campos
2013-11-01 7:07 ` Namhyung Kim
2013-11-01 14:24 ` Rodrigo Campos
2013-11-01 15:16 ` Rodrigo Campos
2013-11-01 12:29 ` Jiri Olsa
2013-11-01 12:57 ` Jiri Olsa
2013-10-31 6:56 ` Namhyung Kim [this message]
2013-10-31 6:56 ` [PATCH 10/14] perf ui/hist: Add support to accumulated hist stat Namhyung Kim
2013-10-31 6:56 ` [PATCH 11/14] perf ui/browser: " Namhyung Kim
2013-10-31 6:56 ` [PATCH 12/14] perf ui/gtk: " Namhyung Kim
2013-10-31 6:56 ` [PATCH 13/14] perf tools: Apply percent-limit to cumulative percentage Namhyung Kim
2013-10-31 6:56 ` [PATCH 14/14] perf report: Add -g cumulative option Namhyung Kim
2013-11-01 13:17 ` Jiri Olsa
2013-11-05 7:44 ` Namhyung Kim
2013-10-31 8:09 ` [RFC/PATCHSET 00/14] perf report: Add support to accumulate hist periods (v2) Ingo Molnar
2013-11-01 6:48 ` Namhyung Kim
2013-11-01 7:55 ` Ingo Molnar
2013-11-01 9:18 ` Pekka Enberg
2013-11-01 9:22 ` Namhyung Kim
2013-11-01 9:27 ` Ingo Molnar
2013-11-05 7:31 ` Namhyung Kim
2013-11-05 7:46 ` Ingo Molnar
2013-11-05 9:05 ` Namhyung Kim
2013-11-05 11:58 ` Ingo Molnar
2013-11-06 7:56 ` Namhyung Kim
2013-11-06 8:30 ` Ingo Molnar
2013-11-06 9:17 ` Namhyung Kim
2013-11-06 11:47 ` Ingo Molnar
2013-11-06 12:14 ` Frederic Weisbecker
2013-11-11 12:13 ` Ingo Molnar
2013-11-11 13:08 ` Frederic Weisbecker
2013-11-11 13:56 ` Ingo Molnar
2013-11-11 15:45 ` Frederic Weisbecker
2013-11-06 15:33 ` David Ahern
2013-11-11 12:19 ` Ingo Molnar
2013-11-11 14:44 ` David Ahern
2013-11-12 12:08 ` Pekka Enberg
2013-11-06 16:09 ` Peter Zijlstra
2013-11-11 12:17 ` Ingo Molnar
2013-11-06 12:10 ` Frederic Weisbecker
2013-11-11 12:12 ` Ingo Molnar
2013-11-11 13:01 ` Frederic Weisbecker
2013-11-04 13:27 ` Frederic Weisbecker
2013-11-04 13:23 ` Frederic Weisbecker
2013-11-04 13:34 ` Frederic Weisbecker
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=1383202576-28141-10-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=asharma@fb.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=paulus@samba.org \
--cc=rodrigo@sdfg.com.ar \
/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
Powered by JetHome