Skip to content

Commit 449067f

Browse files
James-A-Clarkacmel
authored andcommitted
perf cs-etm: Fix timeless decode mode detection
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 f42c0ce ("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: f42c0ce ("perf record: Always get text_poke events with --kcore option") Reported-by: Yang Shi <shy828301@gmail.com> Signed-off-by: James Clark <james.clark@arm.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Will Deacon <will@kernel.org> Cc: coresight@lists.linaro.org Cc: denik@google.com Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/lkml/CAHbLzkrJQTrYBtPkf=jf3OpQ-yBcJe7XkvQstX9j2frz4WF-SQ@mail.gmail.com/ Link: https://lore.kernel.org/r/20230424134748.228137-2-james.clark@arm.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent ce1d3bc commit 449067f

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

tools/perf/util/cs-etm.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,26 +2684,29 @@ static int cs_etm__process_auxtrace_event(struct perf_session *session,
26842684
return 0;
26852685
}
26862686

2687-
static bool cs_etm__is_timeless_decoding(struct cs_etm_auxtrace *etm)
2687+
static int cs_etm__setup_timeless_decoding(struct cs_etm_auxtrace *etm)
26882688
{
26892689
struct evsel *evsel;
26902690
struct evlist *evlist = etm->session->evlist;
2691-
bool timeless_decoding = true;
26922691

26932692
/* Override timeless mode with user input from --itrace=Z */
2694-
if (etm->synth_opts.timeless_decoding)
2695-
return true;
2693+
if (etm->synth_opts.timeless_decoding) {
2694+
etm->timeless_decoding = true;
2695+
return 0;
2696+
}
26962697

26972698
/*
2698-
* Circle through the list of event and complain if we find one
2699-
* with the time bit set.
2699+
* Find the cs_etm evsel and look at what its timestamp setting was
27002700
*/
2701-
evlist__for_each_entry(evlist, evsel) {
2702-
if ((evsel->core.attr.sample_type & PERF_SAMPLE_TIME))
2703-
timeless_decoding = false;
2704-
}
2701+
evlist__for_each_entry(evlist, evsel)
2702+
if (cs_etm__evsel_is_auxtrace(etm->session, evsel)) {
2703+
etm->timeless_decoding =
2704+
!(evsel->core.attr.config & BIT(ETM_OPT_TS));
2705+
return 0;
2706+
}
27052707

2706-
return timeless_decoding;
2708+
pr_err("CS ETM: Couldn't find ETM evsel\n");
2709+
return -EINVAL;
27072710
}
27082711

27092712
/*
@@ -3155,7 +3158,6 @@ int cs_etm__process_auxtrace_info_full(union perf_event *event,
31553158
etm->snapshot_mode = (ptr[CS_ETM_SNAPSHOT] != 0);
31563159
etm->metadata = metadata;
31573160
etm->auxtrace_type = auxtrace_info->type;
3158-
etm->timeless_decoding = cs_etm__is_timeless_decoding(etm);
31593161

31603162
/* Use virtual timestamps if all ETMs report ts_source = 1 */
31613163
etm->has_virtual_ts = cs_etm__has_virtual_ts(metadata, num_cpu);
@@ -3172,6 +3174,10 @@ int cs_etm__process_auxtrace_info_full(union perf_event *event,
31723174
etm->auxtrace.evsel_is_auxtrace = cs_etm__evsel_is_auxtrace;
31733175
session->auxtrace = &etm->auxtrace;
31743176

3177+
err = cs_etm__setup_timeless_decoding(etm);
3178+
if (err)
3179+
return err;
3180+
31753181
etm->unknown_thread = thread__new(999999999, 999999999);
31763182
if (!etm->unknown_thread) {
31773183
err = -ENOMEM;

0 commit comments

Comments
 (0)