[PATCH 03/14] perf cs-etm: Turn on context packet timestamps in per-thread mode

From: James Clark

Date: Tue Aug 11 2026 - 11:38:39 EST


Practically this costs nothing and preempts future changes that will be
made to support decoding trace in order with Perf MMAP and JIT events.
It also helps keep samples in order when we add support for multiple
per-thread mode threads in the next commit.

Signed-off-by: James Clark <james.clark@xxxxxxxxxx>
---
tools/perf/arch/arm/util/cs-etm.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c
index acfdb3f53821..d0486a164a70 100644
--- a/tools/perf/arch/arm/util/cs-etm.c
+++ b/tools/perf/arch/arm/util/cs-etm.c
@@ -453,13 +453,22 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
*/
evsel__set_sample_bit(cs_etm_evsel, CPU);

- /*
- * Also the case of per-cpu mmaps, need the contextID in order to be notified
- * when a context switch happened.
- */
if (!perf_cpu_map__is_any_cpu_or_is_empty(cpus)) {
+ /*
+ * Timestamps are required to interleave samples from different
+ * CPUs.
+ */
evsel__set_config_if_unset(cs_etm_evsel, "timestamp", 1);
+ /* Context IDs are required to associate trace to a process */
evsel__set_config_if_unset(cs_etm_evsel, "contextid", 1);
+ } else {
+ /*
+ * Enable context packet timestamps only (no periodic
+ * timestamps). Even in per-thread mode with a single process we
+ * still need to correlate trace to a specific mmap around
+ * execs, which can be done with just context packet timestamps.
+ */
+ evsel__set_config_if_unset(cs_etm_evsel, "timestamp", UINT64_MAX);
}

/*

--
2.43.0