lkml.org 
[lkml]   [2012]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 11/15] perf hists: Sort hist entries by accumulated period
Date
From: Namhyung Kim <namhyung.kim@lge.com>

When symbol_conf.cumulate_callchain is requested, we need to sort the
entries by accumulated period value. To do this, separate out the
compare routine to hists__output_cmp().

In addition, if 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/util/hist.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 2b629f460889..53ca74f1979a 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -628,6 +628,23 @@ void hists__collapse_resort_threaded(struct hists *hists)
* reverse the map, sort on period.
*/

+static int hists__output_cmp(struct hist_entry *left, struct hist_entry *right)
+{
+ int cmp = left->stat.period > right->stat.period;
+
+ if (symbol_conf.cumulate_callchain) {
+ /*
+ * Put caller above callee when they have equal period.
+ */
+ if (left->stat_acc->period == right->stat_acc->period)
+ cmp = left->callchain->max_depth < right->callchain->max_depth;
+ else
+ cmp = left->stat_acc->period > right->stat_acc->period;
+ }
+
+ return cmp;
+}
+
static void __hists__insert_output_entry(struct rb_root *entries,
struct hist_entry *he,
u64 min_callchain_hits)
@@ -644,7 +661,7 @@ static void __hists__insert_output_entry(struct rb_root *entries,
parent = *p;
iter = rb_entry(parent, struct hist_entry, rb_node);

- if (he->stat.period > iter->stat.period)
+ if (hists__output_cmp(he, iter))
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
--
1.7.11.4


\
 
 \ /
  Last update: 2012-09-13 10:01    [W:0.130 / U:2.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site