mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 00/34] perf cs-etm: JIT decoding support
@ 2026-11-18 16:29 James Clark
  2026-11-18 16:29 ` [PATCH 01/34] perf jit: Support JITDUMP_USE_ARCH_TIMESTAMP on arm64 James Clark
                   ` (34 more replies)
  0 siblings, 35 replies; 36+ messages in thread
From: James Clark @ 2026-11-18 16:29 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Suzuki K Poulose, Mike Leach, Leo Yan,
	Amir Ayupov, Suyash Mahar
  Cc: linux-perf-users, linux-kernel, coresight, linux-arm-kernel, James Clark

Restructure the Coresight decoder to decode trace in order with the Perf
events. This improves decoding accuracy all workloads, but particularly
with JIT code when instructions at the same addresses are re-written.

The resulting decode loop structure is simplified to
cs_etm__insert_heap() and cs_etm__pop_heap(), which work in the same way
for all of the timeless/per-thread/per-cpu etc modes.

For every Perf event, we pop from the heap while the packet's timestamps
are before the current Perf event. When a packet is popped, the next
packet is decoded and re-inserted.

The same path works for timeless mode because we can just assign the
timestamp of the AUX record to all trace from that buffer. This also
improves timeless decoding accuracy because now we don't use the
timestamp from the very last AUX record for all samples.

In Coresight trace, timestamps come after their associated atoms and
Perf uses a single decoder for both searching forwards for a timestamp
and decoding. It does this by caching decoded packets into
packet_buffer[] and replaying them once a timestamp is received.
Unfortunately this does't work for strict ordering with Perf events
because while searching for the timestamp the decoder will decode trace
using previously seen mmap which is incorrect.

To fix this, add a "packet only" decoder for each queue. This is used
for searching for the next timestamp after a discontinuity and not for
decoding trace. Once it's found, the backend re-orders that timestamp
and the previous packet before delivering them to the frontend so that
we can be at the correct Perf event before processing context packets or
ranges. Excluding the tests, this patchset results in similar total
lines of code but if we updated OpenCSD to return timestamps and
discontinuities in the correct order, then it would be a significant
reduction in code and complexity.

This series depends on https://lore.kernel.org/linux-perf-users/20261105-james-cs-unformatted-per-thread-fix-v4-0-7759e0ce2449@linaro.org/

Signed-off-by: James Clark <james.clark@linaro.org>
---
James Clark (34):
      perf jit: Support JITDUMP_USE_ARCH_TIMESTAMP on arm64
      perf jit: Add name of clock in error message
      perf jit: Add address ranges to DWARF compilation units
      perf libdw: Don't look up the module by ELF address
      perf cs-etm: Use the exception level to tell kernel from user
      perf cs-etm: Don't read past the end of the map
      perf build-id: Cache the vDSO in build ID mmap mode
      perf cs-etm: arm-spe: Use arch timestamp in HW tracers
      perf cs-etm: arm-spe: Report error if default clock isn't used
      perf cs-etm: Remove old pipe mode support
      perf cs-etm: Track threads in timeless mode
      perf cs-etm: Track sched out events
      perf cs-etm: Handle PERF_RECORD_SWITCH events
      perf cs-etm: Always enable Perf event timestamps
      perf cs-etm: Use time from Perf samples
      perf cs-etm: Don't buffer non-timestamped packets
      perf cs-etm: Decode in order of Perf samples
      perf cs-etm: Don't special case per-thread mode
      perf cs-etm: Decode one packet at a time and don't estimate timestamps
      perf cs-etm: Remove the decoded packet ring buffer
      perf cs-etm: Fold packet state into the trace ID queue
      perf cs-etm: Rename trace ID queues to trace ID contexts
      perf cs-etm: Rename tidq variables to tidc
      perf cs-etm: Share the thread ctxt between frontend and backend
      perf cs-etm: Consume each OpenCSD packet immediately
      perf cs-etm: Split base and packet decoder state
      perf cs-etm: Add packet-only timestamp decoder ops
      perf cs-etm: Create timestamp decoders
      perf cs-etm: Find timestamps by searching ahead
      perf cs-etm: Invalidate OpenCSD's cache on MMAPs
      perf test cs-etm: Add a Java JIT source-line test
      perf test cs-etm: Test trace is ordered with context switch records
      perf test cs-etm: Test decoding of kernel modules
      perf test cs-etm: Add an HHVM JIT call stack test

 tools/perf/Makefile.perf                           |    4 +-
 tools/perf/arch/arm/util/cs-etm.c                  |   21 +-
 tools/perf/arch/arm64/util/arm-spe.c               |   11 +
 tools/perf/jvmti/jvmti_agent.c                     |    5 +
 tools/perf/tests/genelf.c                          |   70 +-
 .../tests/shell/coresight/context_switch_thread.sh |   20 +-
 tools/perf/tests/shell/coresight/hhvm-jit.sh       |   89 ++
 tools/perf/tests/shell/coresight/java-jit.sh       |   65 +
 tools/perf/tests/shell/coresight/kernel_module.sh  |   54 +
 tools/perf/tests/shell/coresight/lib/PerfJit.java  |   82 ++
 tools/perf/tests/shell/coresight/per-thread.sh     |   45 +-
 tools/perf/tests/workloads/jitdump.c               |    7 +-
 tools/perf/util/auxtrace.h                         |    2 +
 tools/perf/util/build-id.c                         |   12 +
 tools/perf/util/cs-etm-decoder/cs-etm-decoder.c    |  790 ++++++----
 tools/perf/util/cs-etm-decoder/cs-etm-decoder.h    |   28 +-
 tools/perf/util/cs-etm.c                           | 1515 ++++++++------------
 tools/perf/util/cs-etm.h                           |   56 +-
 tools/perf/util/genelf.c                           |    2 +-
 tools/perf/util/genelf.h                           |    3 +-
 tools/perf/util/genelf_debug.c                     |   22 +-
 tools/perf/util/jitdump.c                          |    2 +-
 tools/perf/util/libdw.c                            |   16 +-
 23 files changed, 1643 insertions(+), 1278 deletions(-)
---
base-commit: b7ff10b9ddec8da75304c40fe4abf1ee4f9f0a43
change-id: 20260824-james-coresight-jit-250f19309e35
prerequisite-message-id: <20261105-james-cs-unformatted-per-thread-fix-v4-0-7759e0ce2449@linaro.org>
prerequisite-patch-id: 9c49b9ffb75309e9187eb2e3ef84026118fcfdb5
prerequisite-patch-id: 4ce0ba0ab1302c9043f0d0734d9cf6a35298bc47
prerequisite-patch-id: 5e69770fbaf94296da5c474ce09539a1993bc61e
prerequisite-patch-id: 41d797af2aba7e97ff4435ae2659629e026d36ec
prerequisite-patch-id: d5f67b3b704f4f4b3d9e39c4299d13a086b29363
prerequisite-patch-id: a99348cc2065af31840f652286f840f23395892f
prerequisite-patch-id: aa90408e69dedf9e68d7158f2499bd9fbc7b0b40
prerequisite-patch-id: cd31a650f8dd3e7a9795fa641eee2415b126ad29
prerequisite-patch-id: 922a7fe2937a575beb8d0e7777fd869a11023eb2
prerequisite-patch-id: b0436630e22fd92803e277cd08d782c50f135be6
prerequisite-patch-id: e136ff402ddf5121c63c1393b7fc00a826f60a69
prerequisite-patch-id: 8a2674fa45e40848742e8b8472003e2b9706211d
prerequisite-patch-id: df905386a100ac4b8b047328de08da86b3adf241
prerequisite-patch-id: 44ee88eeafd54c0148ed2332dc5e33f1ba6dfce4
prerequisite-patch-id: b9622164f99682ca6b813b9d38ced3e95170653e
prerequisite-patch-id: 2f22df1738caf5af3a631851d8a57fc3bfea7742
prerequisite-patch-id: afe679ea285ddc6cd281f697ce504b7a18888999
prerequisite-patch-id: f507254858995051e8e1b96fb9fd95506228c5e6
prerequisite-patch-id: 6fe822580ea330633f8a23260aa7b2c7de834ab3

Best regards,
--  
James Clark <james.clark@linaro.org>


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2026-11-18 16:33 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 16:29 [PATCH 00/34] perf cs-etm: JIT decoding support James Clark
2026-11-18 16:29 ` [PATCH 01/34] perf jit: Support JITDUMP_USE_ARCH_TIMESTAMP on arm64 James Clark
2026-11-18 16:29 ` [PATCH 02/34] perf jit: Add name of clock in error message James Clark
2026-11-18 16:29 ` [PATCH 03/34] perf jit: Add address ranges to DWARF compilation units James Clark
2026-11-18 16:29 ` [PATCH 04/34] perf libdw: Don't look up the module by ELF address James Clark
2026-11-18 16:29 ` [PATCH 05/34] perf cs-etm: Use the exception level to tell kernel from user James Clark
2026-11-18 16:29 ` [PATCH 06/34] perf cs-etm: Don't read past the end of the map James Clark
2026-11-18 16:29 ` [PATCH 07/34] perf build-id: Cache the vDSO in build ID mmap mode James Clark
2026-11-18 16:29 ` [PATCH 08/34] perf cs-etm: arm-spe: Use arch timestamp in HW tracers James Clark
2026-11-18 16:29 ` [PATCH 09/34] perf cs-etm: arm-spe: Report error if default clock isn't used James Clark
2026-11-18 16:29 ` [PATCH 10/34] perf cs-etm: Remove old pipe mode support James Clark
2026-11-18 16:29 ` [PATCH 11/34] perf cs-etm: Track threads in timeless mode James Clark
2026-11-18 16:29 ` [PATCH 12/34] perf cs-etm: Track sched out events James Clark
2026-11-18 16:29 ` [PATCH 13/34] perf cs-etm: Handle PERF_RECORD_SWITCH events James Clark
2026-11-18 16:29 ` [PATCH 14/34] perf cs-etm: Always enable Perf event timestamps James Clark
2026-11-18 16:29 ` [PATCH 15/34] perf cs-etm: Use time from Perf samples James Clark
2026-11-18 16:29 ` [PATCH 16/34] perf cs-etm: Don't buffer non-timestamped packets James Clark
2026-11-18 16:29 ` [PATCH 17/34] perf cs-etm: Decode in order of Perf samples James Clark
2026-11-18 16:29 ` [PATCH 18/34] perf cs-etm: Don't special case per-thread mode James Clark
2026-11-18 16:29 ` [PATCH 19/34] perf cs-etm: Decode one packet at a time and don't estimate timestamps James Clark
2026-11-18 16:29 ` [PATCH 20/34] perf cs-etm: Remove the decoded packet ring buffer James Clark
2026-11-18 16:29 ` [PATCH 21/34] perf cs-etm: Fold packet state into the trace ID queue James Clark
2026-11-18 16:29 ` [PATCH 22/34] perf cs-etm: Rename trace ID queues to trace ID contexts James Clark
2026-11-18 16:29 ` [PATCH 23/34] perf cs-etm: Rename tidq variables to tidc James Clark
2026-11-18 16:29 ` [PATCH 24/34] perf cs-etm: Share the thread ctxt between frontend and backend James Clark
2026-11-18 16:29 ` [PATCH 25/34] perf cs-etm: Consume each OpenCSD packet immediately James Clark
2026-11-18 16:29 ` [PATCH 26/34] perf cs-etm: Split base and packet decoder state James Clark
2026-11-18 16:29 ` [PATCH 27/34] perf cs-etm: Add packet-only timestamp decoder ops James Clark
2026-11-18 16:29 ` [PATCH 28/34] perf cs-etm: Create timestamp decoders James Clark
2026-11-18 16:29 ` [PATCH 29/34] perf cs-etm: Find timestamps by searching ahead James Clark
2026-11-18 16:29 ` [PATCH 30/34] perf cs-etm: Invalidate OpenCSD's cache on MMAPs James Clark
2026-11-18 16:29 ` [PATCH 31/34] perf test cs-etm: Add a Java JIT source-line test James Clark
2026-11-18 16:29 ` [PATCH 32/34] perf test cs-etm: Test trace is ordered with context switch records James Clark
2026-11-18 16:29 ` [PATCH 33/34] perf test cs-etm: Test decoding of kernel modules James Clark
2026-11-18 16:29 ` [PATCH 34/34] perf test cs-etm: Add an HHVM JIT call stack test James Clark
2026-11-18 16:33 ` [PATCH 00/34] perf cs-etm: JIT decoding support James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®