From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932333AbdJYRW7 (ORCPT ); Wed, 25 Oct 2017 13:22:59 -0400 Received: from terminus.zytor.com ([65.50.211.136]:51205 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751970AbdJYRWy (ORCPT ); Wed, 25 Oct 2017 13:22:54 -0400 Date: Wed, 25 Oct 2017 10:19:13 -0700 From: tip-bot for Milian Wolff Message-ID: Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, acme@redhat.com, dsahern@gmail.com, namhyung@kernel.org, tglx@linutronix.de, peterz@infradead.org, jolsa@redhat.com, milian.wolff@kdab.com, ravi.bangoria@linux.vnet.ibm.com, mingo@kernel.org, yao.jin@linux.intel.com Reply-To: milian.wolff@kdab.com, ravi.bangoria@linux.vnet.ibm.com, yao.jin@linux.intel.com, mingo@kernel.org, acme@redhat.com, hpa@zytor.com, linux-kernel@vger.kernel.org, jolsa@redhat.com, peterz@infradead.org, namhyung@kernel.org, tglx@linutronix.de, dsahern@gmail.com In-Reply-To: <20171009203310.17362-10-milian.wolff@kdab.com> References: <20171009203310.17362-10-milian.wolff@kdab.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf callchain: Compare symbol name for inlined frames when matching Git-Commit-ID: 9856240ad3269f2fdab0b2fa4400ef8aab792061 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: 9856240ad3269f2fdab0b2fa4400ef8aab792061 Gitweb: https://git.kernel.org/tip/9856240ad3269f2fdab0b2fa4400ef8aab792061 Author: Milian Wolff AuthorDate: Mon, 9 Oct 2017 22:33:03 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 24 Oct 2017 09:59:56 -0300 perf callchain: Compare symbol name for inlined frames when matching The fake symbols we create for inlined frames will represent different functions but can use the symbol start address. This leads to issues when different inline branches all lead to the same function. Before: ~~~~~ $ perf report -s sym -i perf.inlining.data --inline --stdio -g function ... --38.86%--_start __libc_start_main main | --37.57%--std::norm (inlined) std::_Norm_helper::_S_do_it (inlined) | --36.36%--std::abs (inlined) std::__complex_abs (inlined) | --12.24%--std::linear_congruential_engine::operator() (inlined) std::__detail::__mod (inlined) std::__detail::_Mod::__calc (inlined) ~~~~~ Note that this backtrace representation is completely bogus. Complex abs does not call the linear congruential engine! It is just a side-effect of a longer inlined stack being appended to a shorter, different inlined stack, both of which originate in the same function (main). This patch fixes the issue: ~~~~~ $ perf report -s sym -i perf.inlining.data --inline --stdio -g function ... --38.86%--_start __libc_start_main main | |--35.59%--std::uniform_real_distribution::operator() > (inlined) | std::uniform_real_distribution::operator() > (inlined) | | | --34.37%--std::__detail::_Adaptor, double>::operator() (inlined) | std::generate_canonical > (inlined) | | | --12.24%--std::linear_congruential_engine::operator() (inlined) | std::__detail::__mod (inlined) | std::__detail::_Mod::__calc (inlined) | --1.99%--std::norm (inlined) std::_Norm_helper::_S_do_it (inlined) std::abs (inlined) std::__complex_abs (inlined) ~~~~~ Signed-off-by: Milian Wolff Reviewed-by: Jiri Olsa Reviewed-by: Namhyung Kim Cc: David Ahern Cc: Peter Zijlstra Cc: Ravi Bangoria Cc: Yao Jin Link: http://lkml.kernel.org/r/20171009203310.17362-10-milian.wolff@kdab.com Cc: Arnaldo Carvalho de Melo [ Fix up conflict with c1fbc0cf81f1 ("perf callchain: Compare dsos (as well) for CCKEY_FUNCTION"), remove unneeded hunk ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/callchain.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 77031ef..35a920f 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -690,6 +690,14 @@ static enum match_result match_chain(struct callchain_cursor_node *node, } if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) { + /* + * Compare inlined frames based on their symbol name because + * different inlined frames will have the same symbol start + */ + if (cnode->ms.sym->inlined || node->sym->inlined) + return match_chain_strings(cnode->ms.sym->name, + node->sym->name); + left = cnode->ms.sym->start; right = sym->start; left_dso = cnode->ms.map->dso;