Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 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: f42c0ce573df79d1 ("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>

authored by

James Clark and committed by
Arnaldo Carvalho de Melo
449067f3 ce1d3bc2

+20 -14
+20 -14
tools/perf/util/cs-etm.c
··· 2684 2684 return 0; 2685 2685 } 2686 2686 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) 2688 2688 { 2689 2689 struct evsel *evsel; 2690 2690 struct evlist *evlist = etm->session->evlist; 2691 - bool timeless_decoding = true; 2692 2691 2693 2692 /* Override timeless mode with user input from --itrace=Z */ 2694 - if (etm->synth_opts.timeless_decoding) 2695 - return true; 2696 - 2697 - /* 2698 - * Circle through the list of event and complain if we find one 2699 - * with the time bit set. 2700 - */ 2701 - evlist__for_each_entry(evlist, evsel) { 2702 - if ((evsel->core.attr.sample_type & PERF_SAMPLE_TIME)) 2703 - timeless_decoding = false; 2693 + if (etm->synth_opts.timeless_decoding) { 2694 + etm->timeless_decoding = true; 2695 + return 0; 2704 2696 } 2705 2697 2706 - return timeless_decoding; 2698 + /* 2699 + * Find the cs_etm evsel and look at what its timestamp setting was 2700 + */ 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 + } 2707 + 2708 + pr_err("CS ETM: Couldn't find ETM evsel\n"); 2709 + return -EINVAL; 2707 2710 } 2708 2711 2709 2712 /* ··· 3158 3155 etm->snapshot_mode = (ptr[CS_ETM_SNAPSHOT] != 0); 3159 3156 etm->metadata = metadata; 3160 3157 etm->auxtrace_type = auxtrace_info->type; 3161 - etm->timeless_decoding = cs_etm__is_timeless_decoding(etm); 3162 3158 3163 3159 /* Use virtual timestamps if all ETMs report ts_source = 1 */ 3164 3160 etm->has_virtual_ts = cs_etm__has_virtual_ts(metadata, num_cpu); ··· 3173 3171 etm->auxtrace.free = cs_etm__free; 3174 3172 etm->auxtrace.evsel_is_auxtrace = cs_etm__evsel_is_auxtrace; 3175 3173 session->auxtrace = &etm->auxtrace; 3174 + 3175 + err = cs_etm__setup_timeless_decoding(etm); 3176 + if (err) 3177 + return err; 3176 3178 3177 3179 etm->unknown_thread = thread__new(999999999, 999999999); 3178 3180 if (!etm->unknown_thread) {