From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B6BCC433FE for ; Wed, 15 Dec 2021 16:37:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244593AbhLOQhy (ORCPT ); Wed, 15 Dec 2021 11:37:54 -0500 Received: from foss.arm.com ([217.140.110.172]:57304 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbhLOQhx (ORCPT ); Wed, 15 Dec 2021 11:37:53 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A94886D; Wed, 15 Dec 2021 08:37:52 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.67.176]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A283E3F5A1; Wed, 15 Dec 2021 08:37:50 -0800 (PST) Date: Wed, 15 Dec 2021 16:37:47 +0000 From: Mark Rutland To: German Gomez Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org, Alexandre Truong , John Garry , Will Deacon , Mathieu Poirier , Leo Yan , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 4/6] perf tools: enable dwarf_callchain_users on arm64 Message-ID: References: <20211215151139.40854-1-german.gomez@arm.com> <20211215151139.40854-5-german.gomez@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211215151139.40854-5-german.gomez@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 15, 2021 at 03:11:36PM +0000, German Gomez wrote: > From: Alexandre Truong > > On arm64, enable dwarf_callchain_users which will be needed > to do a dwarf unwind in order to get the caller of the leaf frame. > > Signed-off-by: Alexandre Truong > Signed-off-by: German Gomez > --- > tools/perf/builtin-report.c | 4 ++-- > tools/perf/builtin-script.c | 4 ++-- > tools/perf/util/callchain.c | 9 ++++++++- > tools/perf/util/callchain.h | 2 +- > 4 files changed, 13 insertions(+), 6 deletions(-) > > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c > index 8167ebfe776a..a31ad60ba66e 100644 > --- a/tools/perf/builtin-report.c > +++ b/tools/perf/builtin-report.c > @@ -410,7 +410,7 @@ static int report__setup_sample_type(struct report *rep) > } > } > > - callchain_param_setup(sample_type); > + callchain_param_setup(sample_type, perf_env__arch(&rep->session->header.env)); > > if (rep->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) { > ui__warning("Can't find LBR callchain. Switch off --stitch-lbr.\n" > @@ -1124,7 +1124,7 @@ static int process_attr(struct perf_tool *tool __maybe_unused, > * on events sample_type. > */ > sample_type = evlist__combined_sample_type(*pevlist); > - callchain_param_setup(sample_type); > + callchain_param_setup(sample_type, perf_env__arch((*pevlist)->env)); > return 0; > } > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c > index ab7d575f97f2..d308adfd1176 100644 > --- a/tools/perf/builtin-script.c > +++ b/tools/perf/builtin-script.c > @@ -2318,7 +2318,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event, > * on events sample_type. > */ > sample_type = evlist__combined_sample_type(evlist); > - callchain_param_setup(sample_type); > + callchain_param_setup(sample_type, perf_env__arch((*pevlist)->env)); > > /* Enable fields for callchain entries */ > if (symbol_conf.use_callchain && > @@ -3468,7 +3468,7 @@ static void script__setup_sample_type(struct perf_script *script) > struct perf_session *session = script->session; > u64 sample_type = evlist__combined_sample_type(session->evlist); > > - callchain_param_setup(sample_type); > + callchain_param_setup(sample_type, perf_env__arch(session->machines.host.env)); > > if (script->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) { > pr_warning("Can't find LBR callchain. Switch off --stitch-lbr.\n" > diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c > index 8e2777133bd9..aaab9a674807 100644 > --- a/tools/perf/util/callchain.c > +++ b/tools/perf/util/callchain.c > @@ -1600,7 +1600,7 @@ void callchain_cursor_reset(struct callchain_cursor *cursor) > map__zput(node->ms.map); > } > > -void callchain_param_setup(u64 sample_type) > +void callchain_param_setup(u64 sample_type, const char *arch) > { > if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) { > if ((sample_type & PERF_SAMPLE_REGS_USER) && > @@ -1612,6 +1612,13 @@ void callchain_param_setup(u64 sample_type) > else > callchain_param.record_mode = CALLCHAIN_FP; > } > + > + /* > + * It's possible to determine the caller of leaf frames with omitted > + * frame pointers on aarch64 using libunwind, so enable it. > + */ I reckon it's worth mentioning *why* we need to do this; how about: /* * It's necessary to use libunwind to reliably determine the caller of * a leaf function on aarch64, as otherwise we cannot know whether to * start from the LR or FP. * * Always starting from the LR can result in duplicate or entirely * erroneous entries. Always skipping the LR and starting from the FP * can result in missing entries. */ Other than that, this looks fine to me! Thanks, Mark. > + if (callchain_param.record_mode == CALLCHAIN_FP && !strcmp(arch, "arm64")) > + dwarf_callchain_users = true; > } > > static bool chain_match(struct callchain_list *base_chain, > diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h > index 77fba053c677..d95615daed73 100644 > --- a/tools/perf/util/callchain.h > +++ b/tools/perf/util/callchain.h > @@ -300,7 +300,7 @@ int callchain_branch_counts(struct callchain_root *root, > u64 *branch_count, u64 *predicted_count, > u64 *abort_count, u64 *cycles_count); > > -void callchain_param_setup(u64 sample_type); > +void callchain_param_setup(u64 sample_type, const char *arch); > > bool callchain_cnode_matched(struct callchain_node *base_cnode, > struct callchain_node *pair_cnode); > -- > 2.25.1 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CE95C433F5 for ; Wed, 15 Dec 2021 16:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nnfBF/gmApBHPyd4HdIG1vt1nLheYLhO31/bg+9HQl0=; b=1etxjvORMophQh kzV08sHPTGuexSOJtOW1tIgEoSe4lXnJ/OpuS3MPKgvSjLD9/vMQD1TWdyuYGdkhNIJCyUonpMAZr cIEI4bGCQaoq9s9vwZ0cZsD/qTaIKEaMYUKDMQsOTqPk8DtAeW9swxU1lQholQjKvHqRvg+P++HVo BAMAwWXZ/ploEmPrux7+MxiIIJSKuWRRStldu/A407AcR9paE2BL40kpuJFPg+Aa2q37wNYnyZj+x V3dBJ2FDabZ/P4X9JVv0jKbCNQM/4oNcqPHsjsoWt51A9/YLUaK5o7ubOWZPg/NybsihGnJCXrsrh 4V/ICicHLpHbEIBaLa6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxXaY-001tpV-Rc; Wed, 15 Dec 2021 16:57:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxXHu-001m7f-AH for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 16:37:56 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A94886D; Wed, 15 Dec 2021 08:37:52 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.67.176]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A283E3F5A1; Wed, 15 Dec 2021 08:37:50 -0800 (PST) Date: Wed, 15 Dec 2021 16:37:47 +0000 From: Mark Rutland To: German Gomez Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org, Alexandre Truong , John Garry , Will Deacon , Mathieu Poirier , Leo Yan , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4 4/6] perf tools: enable dwarf_callchain_users on arm64 Message-ID: References: <20211215151139.40854-1-german.gomez@arm.com> <20211215151139.40854-5-german.gomez@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211215151139.40854-5-german.gomez@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_083754_508014_F8BA2140 X-CRM114-Status: GOOD ( 23.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Dec 15, 2021 at 03:11:36PM +0000, German Gomez wrote: > From: Alexandre Truong > > On arm64, enable dwarf_callchain_users which will be needed > to do a dwarf unwind in order to get the caller of the leaf frame. > > Signed-off-by: Alexandre Truong > Signed-off-by: German Gomez > --- > tools/perf/builtin-report.c | 4 ++-- > tools/perf/builtin-script.c | 4 ++-- > tools/perf/util/callchain.c | 9 ++++++++- > tools/perf/util/callchain.h | 2 +- > 4 files changed, 13 insertions(+), 6 deletions(-) > > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c > index 8167ebfe776a..a31ad60ba66e 100644 > --- a/tools/perf/builtin-report.c > +++ b/tools/perf/builtin-report.c > @@ -410,7 +410,7 @@ static int report__setup_sample_type(struct report *rep) > } > } > > - callchain_param_setup(sample_type); > + callchain_param_setup(sample_type, perf_env__arch(&rep->session->header.env)); > > if (rep->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) { > ui__warning("Can't find LBR callchain. Switch off --stitch-lbr.\n" > @@ -1124,7 +1124,7 @@ static int process_attr(struct perf_tool *tool __maybe_unused, > * on events sample_type. > */ > sample_type = evlist__combined_sample_type(*pevlist); > - callchain_param_setup(sample_type); > + callchain_param_setup(sample_type, perf_env__arch((*pevlist)->env)); > return 0; > } > > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c > index ab7d575f97f2..d308adfd1176 100644 > --- a/tools/perf/builtin-script.c > +++ b/tools/perf/builtin-script.c > @@ -2318,7 +2318,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event, > * on events sample_type. > */ > sample_type = evlist__combined_sample_type(evlist); > - callchain_param_setup(sample_type); > + callchain_param_setup(sample_type, perf_env__arch((*pevlist)->env)); > > /* Enable fields for callchain entries */ > if (symbol_conf.use_callchain && > @@ -3468,7 +3468,7 @@ static void script__setup_sample_type(struct perf_script *script) > struct perf_session *session = script->session; > u64 sample_type = evlist__combined_sample_type(session->evlist); > > - callchain_param_setup(sample_type); > + callchain_param_setup(sample_type, perf_env__arch(session->machines.host.env)); > > if (script->stitch_lbr && (callchain_param.record_mode != CALLCHAIN_LBR)) { > pr_warning("Can't find LBR callchain. Switch off --stitch-lbr.\n" > diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c > index 8e2777133bd9..aaab9a674807 100644 > --- a/tools/perf/util/callchain.c > +++ b/tools/perf/util/callchain.c > @@ -1600,7 +1600,7 @@ void callchain_cursor_reset(struct callchain_cursor *cursor) > map__zput(node->ms.map); > } > > -void callchain_param_setup(u64 sample_type) > +void callchain_param_setup(u64 sample_type, const char *arch) > { > if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) { > if ((sample_type & PERF_SAMPLE_REGS_USER) && > @@ -1612,6 +1612,13 @@ void callchain_param_setup(u64 sample_type) > else > callchain_param.record_mode = CALLCHAIN_FP; > } > + > + /* > + * It's possible to determine the caller of leaf frames with omitted > + * frame pointers on aarch64 using libunwind, so enable it. > + */ I reckon it's worth mentioning *why* we need to do this; how about: /* * It's necessary to use libunwind to reliably determine the caller of * a leaf function on aarch64, as otherwise we cannot know whether to * start from the LR or FP. * * Always starting from the LR can result in duplicate or entirely * erroneous entries. Always skipping the LR and starting from the FP * can result in missing entries. */ Other than that, this looks fine to me! Thanks, Mark. > + if (callchain_param.record_mode == CALLCHAIN_FP && !strcmp(arch, "arm64")) > + dwarf_callchain_users = true; > } > > static bool chain_match(struct callchain_list *base_chain, > diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h > index 77fba053c677..d95615daed73 100644 > --- a/tools/perf/util/callchain.h > +++ b/tools/perf/util/callchain.h > @@ -300,7 +300,7 @@ int callchain_branch_counts(struct callchain_root *root, > u64 *branch_count, u64 *predicted_count, > u64 *abort_count, u64 *cycles_count); > > -void callchain_param_setup(u64 sample_type); > +void callchain_param_setup(u64 sample_type, const char *arch); > > bool callchain_cnode_matched(struct callchain_node *base_cnode, > struct callchain_node *pair_cnode); > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel