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

perf cs-etm: Enable itrace option 'T'

Prior to Armv8.4, the feature FEAT_TRF is not supported by Arm CPUs.
Consequently, the sysfs node 'ts_source' will not be set as 1 by the
CoreSight ETM driver. On the other hand, the perf tool relies on the
'ts_source' node to determine whether the kernel timestamp is traced.
Since the 'ts_source' is not set for Arm CPUs prior to Armv8.4,
platforms in this case cannot utilize the traced timestamp as the kernel
time.

This patch enables the 'T' itrace option, which forcibly utilizes the
traced timestamp as the kernel time. If users are aware that their
working platform's Arm CoreSight shares the same counter with the kernel
time, they can specify 'T' option to decode the traced timestamp as the
kernel time.

An usage example is:

# perf record -e cs_etm// -- test_program
# perf script --itrace=i10ibT
# perf report --itrace=i10ibT

Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Leo Yan <leo.yan@linaro.org>
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: Mark Rutland <mark.rutland@arm.com>
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: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20231014074513.1668000-3-leo.yan@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Leo Yan and committed by
Arnaldo Carvalho de Melo
a4271827 26218331

+18 -3
+18 -3
tools/perf/util/cs-etm.c
··· 3346 3346 etm->metadata = metadata; 3347 3347 etm->auxtrace_type = auxtrace_info->type; 3348 3348 3349 - /* Use virtual timestamps if all ETMs report ts_source = 1 */ 3350 - etm->has_virtual_ts = cs_etm__has_virtual_ts(metadata, num_cpu); 3349 + if (etm->synth_opts.use_timestamp) 3350 + /* 3351 + * Prior to Armv8.4, Arm CPUs don't support FEAT_TRF feature, 3352 + * therefore the decoder cannot know if the timestamp trace is 3353 + * same with the kernel time. 3354 + * 3355 + * If a user has knowledge for the working platform and can 3356 + * specify itrace option 'T' to tell decoder to forcely use the 3357 + * traced timestamp as the kernel time. 3358 + */ 3359 + etm->has_virtual_ts = true; 3360 + else 3361 + /* Use virtual timestamps if all ETMs report ts_source = 1 */ 3362 + etm->has_virtual_ts = cs_etm__has_virtual_ts(metadata, num_cpu); 3351 3363 3352 3364 if (!etm->has_virtual_ts) 3353 3365 ui__warning("Virtual timestamps are not enabled, or not supported by the traced system.\n" 3354 - "The time field of the samples will not be set accurately.\n\n"); 3366 + "The time field of the samples will not be set accurately.\n" 3367 + "For Arm CPUs prior to Armv8.4 or without support FEAT_TRF,\n" 3368 + "you can specify the itrace option 'T' for timestamp decoding\n" 3369 + "if the Coresight timestamp on the platform is same with the kernel time.\n\n"); 3355 3370 3356 3371 etm->auxtrace.process_event = cs_etm__process_event; 3357 3372 etm->auxtrace.process_auxtrace_event = cs_etm__process_auxtrace_event;