Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756089AbaAHIsP (ORCPT ); Wed, 8 Jan 2014 03:48:15 -0500 Received: from lgeamrelo01.lge.com ([156.147.1.125]:42210 "EHLO LGEAMRELO01.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755885AbaAHIqr (ORCPT ); Wed, 8 Jan 2014 03:46:47 -0500 X-AuditID: 9c93017d-b7b66ae000006a2a-17-52cd106f81e0 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Paul Mackerras , Ingo Molnar , Namhyung Kim , LKML , Arun Sharma , Frederic Weisbecker , Jiri Olsa , Rodrigo Campos Subject: [PATCH 13/28] perf hists: Sort hist entries by accumulated period Date: Wed, 8 Jan 2014 17:46:18 +0900 Message-Id: <1389170793-21926-14-git-send-email-namhyung@kernel.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1389170793-21926-1-git-send-email-namhyung@kernel.org> References: <1389170793-21926-1-git-send-email-namhyung@kernel.org> X-Brightmail-Tracker: AAAAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Frederic Weisbecker Signed-off-by: Namhyung Kim --- tools/perf/util/hist.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index a6bb3e329857..daf39fc8fe33 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -624,6 +624,18 @@ static int hist_entry__sort_on_period(struct hist_entry *a, struct hist_entry *pair; u64 *periods_a, *periods_b; + if (symbol_conf.cumulate_callchain) { + /* + * 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/