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 1AD4EC433FE for ; Wed, 13 Apr 2022 08:15:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233027AbiDMISM (ORCPT ); Wed, 13 Apr 2022 04:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbiDMISJ (ORCPT ); Wed, 13 Apr 2022 04:18:09 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D5F52CC9D; Wed, 13 Apr 2022 01:15:49 -0700 (PDT) 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 C94A113D5; Wed, 13 Apr 2022 01:15:48 -0700 (PDT) Received: from [10.1.33.136] (e127744.cambridge.arm.com [10.1.33.136]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 890833F5A1; Wed, 13 Apr 2022 01:15:46 -0700 (PDT) Subject: Re: [PATCH] perf report: Set PERF_SAMPLE_DATA_SRC bit for Arm SPE event To: Leo Yan , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ravi Bangoria , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220413075124.635589-1-leo.yan@linaro.org> From: German Gomez Message-ID: Date: Wed, 13 Apr 2022 09:15:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20220413075124.635589-1-leo.yan@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Leo, On 13/04/2022 08:51, Leo Yan wrote: > Since commit bb30acae4c4d ("perf report: Bail out --mem-mode if mem info > is not available") "perf mem report" and "perf report --mem-mode" > don't report result if the PERF_SAMPLE_DATA_SRC bit is missed in sample > type. > > The commit ffab48705205 ("perf: arm-spe: Fix perf report --mem-mode") > partially fixes the issue. It adds PERF_SAMPLE_DATA_SRC bit for Arm SPE > event, this allows the perf data file generated by kernel v5.18-rc1 or > later version can be reported properly. > > On the other hand, perf tool still fails to be backward compatibility > for a data file recorded by an older version's perf which contains Arm > SPE trace data. This patch is a workaround in reporting phase, when > detects ARM SPE PMU event and without PERF_SAMPLE_DATA_SRC bit, it will > force to set the bit in the sample type and give a warning info. > > Fixes: bb30acae4c4d ("perf report: Bail out --mem-mode if mem info is not available") > Signed-off-by: Leo Yan > --- > tools/perf/builtin-report.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c > index 1ad75c7ba074..f26dd14eb852 100644 > --- a/tools/perf/builtin-report.c > +++ b/tools/perf/builtin-report.c > @@ -353,6 +353,7 @@ static int report__setup_sample_type(struct report *rep) > struct perf_session *session = rep->session; > u64 sample_type = evlist__combined_sample_type(session->evlist); > bool is_pipe = perf_data__is_pipe(session->data); > + struct evsel *evsel; > > if (session->itrace_synth_opts->callchain || > session->itrace_synth_opts->add_callchain || > @@ -407,6 +408,21 @@ static int report__setup_sample_type(struct report *rep) > } > > if (sort__mode == SORT_MODE__MEMORY) { > + /* > + * FIXUP: prior to kernel 5.18, Arm SPE missed to set > + * PERF_SAMPLE_DATA_SRC bit in sample type. For backward > + * compatibility, set the bit if it's an old perf data file. > + */ > + evlist__for_each_entry(session->evlist, evsel) { > + if (strstr(evsel->name, "arm_spe_") && This didn't work for me when the file recorded "-e arm_spe//" instead of "-e arm_spe_0//". Could you remove the trailing _? With that: Tested-by: German Gomez > + !(sample_type & PERF_SAMPLE_DATA_SRC)) { > + ui__warning("PERF_SAMPLE_DATA_SRC bit is not set " > + "for Arm SPE event.\n"); > + evsel->core.attr.sample_type |= PERF_SAMPLE_DATA_SRC; > + sample_type |= PERF_SAMPLE_DATA_SRC; > + } > + } > + > if (!is_pipe && !(sample_type & PERF_SAMPLE_DATA_SRC)) { > ui__error("Selected --mem-mode but no mem data. " > "Did you call perf record without -d?\n");