From: James Clark <james.clark@linaro.org>
To: Linux perf Profiling <linux-perf-users@vger.kernel.org>
Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org,
linux-arm-kernel@lists.infradead.org,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@arm.com>, Leo Yan <leo.yan@arm.com>,
Amir Ayupov <aaupov@fb.com>, Suyash Mahar <smahar@meta.com>
Subject: Re: [PATCH 00/34] perf cs-etm: JIT decoding support
Date: Wed, 18 Nov 2026 16:33:21 +0000 [thread overview]
Message-ID: <c9a9e247-265d-476d-abc1-308fbe1d4a2b@linaro.org> (raw)
In-Reply-To: <20261118-james-coresight-jit-v1-0-dad4d90747f6@linaro.org>
On 18/11/2026 16:29, James Clark wrote:
> 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/
>
Assisted by various Claude and Codex agents.
> 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>
>
prev parent reply other threads:[~2026-11-18 16:33 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
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
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 ` James Clark [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9a9e247-265d-476d-abc1-308fbe1d4a2b@linaro.org \
--to=james.clark@linaro.org \
--cc=aaupov@fb.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=coresight@lists.linaro.org \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mike.leach@arm.com \
--cc=namhyung@kernel.org \
--cc=smahar@meta.com \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®