[PATCH 2/3] perf tools: Put callers above callee when callchain order is caller

From: Namhyung Kim
Date: Thu Aug 14 2014 - 02:01:55 EST


The perf report/top shows callers above their callees, but if user
gives a callchain param to caller it's inverted. Fix it.

Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/ui/hist.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index b5fa7019d2e2..eacbb561af78 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -197,14 +197,16 @@ static int __hpp__sort_acc(struct hist_entry *a, struct hist_entry *b,
s64 ret = 0;

if (symbol_conf.cumulate_callchain) {
- /*
- * Put caller above callee when they have equal period.
- */
ret = field_cmp(get_field(a), get_field(b));
if (ret)
return ret;

+ /*
+ * Put caller above callee when they have equal period.
+ */
ret = b->callchain->max_depth - a->callchain->max_depth;
+ if (callchain_param.order == ORDER_CALLER)
+ ret = -ret;
}
return ret;
}
--
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/