From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752059AbdJYRVn (ORCPT ); Wed, 25 Oct 2017 13:21:43 -0400 Received: from terminus.zytor.com ([65.50.211.136]:43119 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751898AbdJYRVk (ORCPT ); Wed, 25 Oct 2017 13:21:40 -0400 Date: Wed, 25 Oct 2017 10:18:03 -0700 From: tip-bot for Milian Wolff Message-ID: Cc: acme@redhat.com, peterz@infradead.org, dsahern@gmail.com, mingo@kernel.org, jolsa@redhat.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, yao.jin@linux.intel.com, namhyung@kernel.org, milian.wolff@kdab.com, hpa@zytor.com Reply-To: namhyung@kernel.org, milian.wolff@kdab.com, linux-kernel@vger.kernel.org, yao.jin@linux.intel.com, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, peterz@infradead.org, dsahern@gmail.com, acme@redhat.com, jolsa@redhat.com In-Reply-To: <20171009203310.17362-7-milian.wolff@kdab.com> References: <20171009203310.17362-7-milian.wolff@kdab.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf report: Fall-back to function name comparison for -g srcline Git-Commit-ID: cbe50f61727f538f05e63186c2e0022182a3a28f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: cbe50f61727f538f05e63186c2e0022182a3a28f Gitweb: https://git.kernel.org/tip/cbe50f61727f538f05e63186c2e0022182a3a28f Author: Milian Wolff AuthorDate: Mon, 9 Oct 2017 22:33:00 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 24 Oct 2017 09:59:55 -0300 perf report: Fall-back to function name comparison for -g srcline When a callchain entry has no srcline available, we ended up comparing the instruction pointer. I consider this to be not too useful. Rather, I think we should group the entries by function name, which this patch adds. For people who want to split the data on the IP boundary, using `-g address` is the correct choice. Before: ~~~~~ 100.00% 38.86% [.] main | |--61.14%--main inlining.cpp:14 | std::norm complex:664 | std::_Norm_helper::_S_do_it complex:654 | std::abs complex:597 | std::__complex_abs complex:589 | | | |--56.03%--hypot | | | | | |--8.45%--__hypot_finite | | | | | |--7.62%--__hypot_finite | | | | | |--2.29%--__hypot_finite | | | | | |--2.24%--__hypot_finite | | | | | |--2.06%--__hypot_finite | | | | | |--1.81%--__hypot_finite ... ~~~~~ After: ~~~~~ 100.00% 38.86% [.] main | |--61.14%--main inlining.cpp:14 | std::norm complex:664 | std::_Norm_helper::_S_do_it complex:654 | std::abs complex:597 | std::__complex_abs complex:589 | | | |--60.29%--hypot | | | | | --56.03%--__hypot_finite | | | --0.85%--cabs ~~~~~ Signed-off-by: Milian Wolff Reviewed-by: Jiri Olsa Reviewed-by: Namhyung Kim Cc: David Ahern Cc: Peter Zijlstra Cc: Yao Jin Link: http://lkml.kernel.org/r/20171009203310.17362-7-milian.wolff@kdab.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/callchain.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index e7ee794..0f2ba49 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -645,11 +645,9 @@ enum match_result { MATCH_GT, }; -static enum match_result match_chain_srcline(struct callchain_cursor_node *node, - struct callchain_list *cnode) +static enum match_result match_chain_strings(const char *left, + const char *right) { - const char *left = cnode->srcline; - const char *right = node->srcline; enum match_result ret = MATCH_EQ; int cmp; @@ -659,10 +657,8 @@ static enum match_result match_chain_srcline(struct callchain_cursor_node *node, cmp = 1; else if (left && !right) cmp = -1; - else if (cnode->ip == node->ip) - cmp = 0; else - cmp = (cnode->ip < node->ip) ? -1 : 1; + return MATCH_ERROR; if (cmp != 0) ret = cmp < 0 ? MATCH_LT : MATCH_GT; @@ -679,10 +675,18 @@ static enum match_result match_chain(struct callchain_cursor_node *node, struct dso *right_dso = NULL; if (callchain_param.key == CCKEY_SRCLINE) { - enum match_result match = match_chain_srcline(node, cnode); + enum match_result match = match_chain_strings(cnode->srcline, + node->srcline); + + /* if no srcline is available, fallback to symbol name */ + if (match == MATCH_ERROR && cnode->ms.sym && node->sym) + match = match_chain_strings(cnode->ms.sym->name, + node->sym->name); if (match != MATCH_ERROR) return match; + + /* otherwise fall-back to IP-based comparison below */ } if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) {