From nobody Wed Dec 17 00:14:49 2025 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 2D188C7618E for ; Mon, 24 Apr 2023 13:48:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232767AbjDXNsM (ORCPT ); Mon, 24 Apr 2023 09:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbjDXNsF (ORCPT ); Mon, 24 Apr 2023 09:48:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6B2957AB5; Mon, 24 Apr 2023 06:48:04 -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 11D33FEC; Mon, 24 Apr 2023 06:48:48 -0700 (PDT) Received: from e127643.arm.com (unknown [10.57.58.229]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id F007E3F64C; Mon, 24 Apr 2023 06:48:00 -0700 (PDT) From: James Clark To: linux-perf-users@vger.kernel.org, coresight@lists.linaro.org, shy828301@gmail.com Cc: denik@google.com, James Clark , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] perf: cs-etm: Fix timeless decode mode detection Date: Mon, 24 Apr 2023 14:47:41 +0100 Message-Id: <20230424134748.228137-2-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424134748.228137-1-james.clark@arm.com> References: <20230424134748.228137-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In this context, timeless refers to the trace data rather than the perf event data. But when detecting whether there are timestamps in the trace data or not, the presence of a timestamp flag on any perf event is used. Since commit f42c0ce573df ("perf record: Always get text_poke events with --kcore option") timestamps were added to a tracking event when --kcore is used which breaks this detection mechanism. Fix it by detecting if trace timestamps exist by looking at the ETM config flags. This would have always been a more accurate way of doing it anyway. This fixes the following error message when using --kcore with Coresight: $ perf record --kcore -e cs_etm// --per-thread $ perf report The perf.data/data data has no samples! Fixes: f42c0ce573df ("perf record: Always get text_poke events with --kcore= option") Reported-by: Yang Shi Link: https://lore.kernel.org/lkml/CAHbLzkrJQTrYBtPkf=3Djf3OpQ-yBcJe7XkvQst= X9j2frz4WF-SQ@mail.gmail.com/ Signed-off-by: James Clark --- tools/perf/util/cs-etm.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c index 8dd81ddd9e4e..50593289d53c 100644 --- a/tools/perf/util/cs-etm.c +++ b/tools/perf/util/cs-etm.c @@ -2684,26 +2684,29 @@ static int cs_etm__process_auxtrace_event(struct pe= rf_session *session, return 0; } =20 -static bool cs_etm__is_timeless_decoding(struct cs_etm_auxtrace *etm) +static int cs_etm__setup_timeless_decoding(struct cs_etm_auxtrace *etm) { struct evsel *evsel; struct evlist *evlist =3D etm->session->evlist; - bool timeless_decoding =3D true; =20 /* Override timeless mode with user input from --itrace=3DZ */ - if (etm->synth_opts.timeless_decoding) - return true; + if (etm->synth_opts.timeless_decoding) { + etm->timeless_decoding =3D true; + return 0; + } =20 /* - * Circle through the list of event and complain if we find one - * with the time bit set. + * Find the cs_etm evsel and look at what its timestamp setting was */ - evlist__for_each_entry(evlist, evsel) { - if ((evsel->core.attr.sample_type & PERF_SAMPLE_TIME)) - timeless_decoding =3D false; - } + evlist__for_each_entry(evlist, evsel) + if (cs_etm__evsel_is_auxtrace(etm->session, evsel)) { + etm->timeless_decoding =3D + !(evsel->core.attr.config & BIT(ETM_OPT_TS)); + return 0; + } =20 - return timeless_decoding; + pr_err("CS ETM: Couldn't find ETM evsel\n"); + return -EINVAL; } =20 /* @@ -3155,7 +3158,6 @@ int cs_etm__process_auxtrace_info_full(union perf_eve= nt *event, etm->snapshot_mode =3D (ptr[CS_ETM_SNAPSHOT] !=3D 0); etm->metadata =3D metadata; etm->auxtrace_type =3D auxtrace_info->type; - etm->timeless_decoding =3D cs_etm__is_timeless_decoding(etm); =20 /* Use virtual timestamps if all ETMs report ts_source =3D 1 */ etm->has_virtual_ts =3D cs_etm__has_virtual_ts(metadata, num_cpu); @@ -3172,6 +3174,10 @@ int cs_etm__process_auxtrace_info_full(union perf_ev= ent *event, etm->auxtrace.evsel_is_auxtrace =3D cs_etm__evsel_is_auxtrace; session->auxtrace =3D &etm->auxtrace; =20 + err =3D cs_etm__setup_timeless_decoding(etm); + if (err) + return err; + etm->unknown_thread =3D thread__new(999999999, 999999999); if (!etm->unknown_thread) { err =3D -ENOMEM; --=20 2.34.1