From: Leo Yan <leo.yan@arm.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
James Clark <james.clark@linaro.org>,
Mike Leach <mike.leach@arm.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Yeoreum Yun <yeoreum.yun@arm.com>,
Jonathan Corbet <corbet@lwn.net>, Suyash Mahar <smahar@meta.com>,
Amir Ayupov <aaupov@fb.com>
Cc: Ingo Molnar <mingo@kernel.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
coresight@lists.linaro.org,
linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org,
Leo Yan <leo.yan@arm.com>
Subject: [PATCH 00/25] CoreSight / perf: Support AUX sampling
Date: Tue, 15 Sep 2026 16:48:46 +0100 [thread overview]
Message-ID: <20260915-arm_cs_support_aux_sample-v1-0-35cf6f297d20@arm.com> (raw)
This series adds AUX sampling support to Arm CoreSight. A PMU sample can
carry a window of recent AUX trace, which perf generates callchain and
branch stack for the sampled thread. This provides execution history for
context-based profiling.
The series can be divided into four parts:
1. Patches 01 ~ 03 for event core:
The perf event core changes warn on non-positive AUX snapshot
returns before checking alignment padding. Space for a non-zero AUX
payload has already been reserved, so a zero return leaves that
payload unwritten. CoreSight fills unavailable trace with zeros and
returns the requested size.
It also prevents AUX sampling and pause/resume from nesting through
an NMI. A driver guard alone can leave perf's pause state
(aux_paused) inconsistent with the hardware state. The event core
ensures only one AUX callback is exclusively invoked.
Export the output copy helpers so CoreSight can fill sample payloads
when the driver is built as a module.
2. Patches 04 ~ 09 for ETM perf:
The ETM perf changes separate the lifetime of the published CoreSight
context from that of the AUX output handle.
Centralize buffer updates, and end AUX output when throttling stops
an event without PERF_EF_UPDATE so a later restart can acquire a
fresh handle.
Make hardware-state transitions reflect completed operations.
3. Patches 10 ~ 13 for TRBE driver:
TRBE snapshot buffers need padding to meet the CPU's alignment and
wrap constraints. Use circular buffer mode for overwrite snapshots,
retaining Fill mode on CPUs that require the write out-of-range
workaround.
TRBE faults can still raise interrupts in circular mode. Track when
the sink is handling an interrupt so an AUX sampling NMI can skip a
snapshot while the interrupted handler is updating the buffer. Make
repeated sink disable safe for deferred cleanup after a snapshot
failure.
4. Patches 14 ~ 25 for AUX sampling and decoding:
Shared atomic STOP and AUX action bits prevent an NMI stop from
tearing down the context while pause, resume or snapshot accesses it.
The AUX operation finishes and then completes the deferred stop,
publishing the stopped state only after hardware teardown.
Add snapshot_aux() to the CoreSight driver to pause the source, update
the sink buffer, disable the path, copy the recent trace into the PMU
sample, and then re-enable the path and resume the source.
Patch 17 fixes history collection for zero-IP PMU samples. Perf clears
the IP when a user-only sampling interrupt skids into the kernel, but
the timestamp and TID remain valid for matching the trace history.
In perf, decode each embedded payload as an independent trace window,
selecting the decoder with the sampled CPU and using the sample's
PID/TID and traced context IDs to attribute history to the sampled
thread. Refactor common timeless decoding and history collection, and
drain pending OpenCSD output so buffered history is not lost.
Attach reconstructed callchains and branch stacks to the original PMU
samples, preserving histories already present in the samples. Add a
test, and document the recording and decoding workflow and its
limitations.
The initial support targets unformatted trace from per-CPU sinks such as
TRBE. Shared formatted sinks such as ETR can mix trace from multiple CPUs,
consuming the limited sample window with execution unrelated to the
sampled thread.
This series is based on Amir's series "perf: Add CoreSight branch
history to existing samples" [1] for perf tool's branch / callchain
generating.
[1] https://lore.kernel.org/linux-perf-users/cover.1787005265.git.aaupov@fb.com/
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
Leo Yan (25):
perf/core: Reject non-positive AUX snapshot sizes
perf/core: Prevent AUX sampling from racing with pause/resume
perf/core: Export output copy helpers for CoreSight
coresight: perf: End AUX output when an event is throttled
coresight: perf: Extract AUX buffer update helper
coresight: perf: Simplify flow for CPUs without a path
coresight: perf: Validate the live context through its path
coresight: perf: Validate context before resuming trace
coresight: perf: Improve hardware state transitions
coresight: trbe: Pad snapshot buffers
coresight: trbe: Use circular buffer mode for snapshots
coresight: trbe: Track per-CPU sink interrupt handling
coresight: trbe: Handle an already disabled sink
coresight: perf: Look up the trace path in etm_event_pause()
coresight: perf: Serialize AUX pause and resume with event stops
coresight: perf: Support AUX sampling with per-CPU sinks
perf cs-etm: Allow history collection for samples with zero IP
perf cs-etm: Unify timeless buffer decoding
perf cs-etm: Propagate errors from trace queue flushing
perf cs-etm: Drain pending packets before finishing trace blocks
perf cs-etm: Complete packet draining with end of trace
perf cs-etm: Centralize sample history collection
perf cs-etm: Decode AUX samples into callchains and branch stacks
perf test: Add CoreSight AUX sample decoding test
Documentation: coresight: Document AUX sample decoding
Documentation/trace/coresight/coresight-perf.rst | 39 ++
drivers/hwtracing/coresight/coresight-etm-perf.c | 396 +++++++++++++-----
drivers/hwtracing/coresight/coresight-etm-perf.h | 2 +
drivers/hwtracing/coresight/coresight-trbe.c | 122 ++++--
include/linux/coresight.h | 2 +
kernel/events/core.c | 26 +-
kernel/events/ring_buffer.c | 2 +
tools/perf/arch/arm/util/cs-etm.c | 6 +
tools/perf/tests/shell/coresight/aux_sample.sh | 189 +++++++++
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 39 ++
tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 7 +
tools/perf/util/cs-etm.c | 491 ++++++++++++++++-------
12 files changed, 1040 insertions(+), 281 deletions(-)
---
base-commit: 134e1295eedfc9a3c6e4e63d8ef45dc63749449b
change-id: 20260826-arm_cs_support_aux_sample-275664545588
Best regards,
--
Leo Yan <leo.yan@arm.com>
next reply other threads:[~2026-09-15 15:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 15:48 Leo Yan [this message]
2026-09-15 15:48 ` [PATCH 01/25] perf/core: Reject non-positive AUX snapshot sizes Leo Yan
2026-09-15 15:48 ` [PATCH 02/25] perf/core: Prevent AUX sampling from racing with pause/resume Leo Yan
2026-09-15 15:48 ` [PATCH 03/25] perf/core: Export output copy helpers for CoreSight Leo Yan
2026-09-15 15:48 ` [PATCH 04/25] coresight: perf: End AUX output when an event is throttled Leo Yan
2026-09-15 15:48 ` [PATCH 05/25] coresight: perf: Extract AUX buffer update helper Leo Yan
2026-09-15 15:48 ` [PATCH 06/25] coresight: perf: Simplify flow for CPUs without a path Leo Yan
2026-09-15 15:48 ` [PATCH 07/25] coresight: perf: Validate the live context through its path Leo Yan
2026-09-15 15:48 ` [PATCH 08/25] coresight: perf: Validate context before resuming trace Leo Yan
2026-09-15 15:48 ` [PATCH 09/25] coresight: perf: Improve hardware state transitions Leo Yan
2026-09-15 15:48 ` [PATCH 10/25] coresight: trbe: Pad snapshot buffers Leo Yan
2026-09-15 15:48 ` [PATCH 11/25] coresight: trbe: Use circular buffer mode for snapshots Leo Yan
2026-09-15 15:48 ` [PATCH 12/25] coresight: trbe: Track per-CPU sink interrupt handling Leo Yan
2026-09-15 15:48 ` [PATCH 13/25] coresight: trbe: Handle an already disabled sink Leo Yan
2026-09-15 15:49 ` [PATCH 14/25] coresight: perf: Look up the trace path in etm_event_pause() Leo Yan
2026-09-15 15:49 ` [PATCH 15/25] coresight: perf: Serialize AUX pause and resume with event stops Leo Yan
2026-09-15 15:49 ` [PATCH 16/25] coresight: perf: Support AUX sampling with per-CPU sinks Leo Yan
2026-09-15 15:49 ` [PATCH 17/25] perf cs-etm: Allow history collection for samples with zero IP Leo Yan
2026-09-15 15:49 ` [PATCH 18/25] perf cs-etm: Unify timeless buffer decoding Leo Yan
2026-09-15 15:49 ` [PATCH 19/25] perf cs-etm: Propagate errors from trace queue flushing Leo Yan
2026-09-15 15:49 ` [PATCH 20/25] perf cs-etm: Drain pending packets before finishing trace blocks Leo Yan
2026-09-15 15:49 ` [PATCH 21/25] perf cs-etm: Complete packet draining with end of trace Leo Yan
2026-09-15 15:49 ` [PATCH 22/25] perf cs-etm: Centralize sample history collection Leo Yan
2026-09-15 15:49 ` [PATCH 23/25] perf cs-etm: Decode AUX samples into callchains and branch stacks Leo Yan
2026-09-15 15:49 ` [PATCH 24/25] perf test: Add CoreSight AUX sample decoding test Leo Yan
2026-09-15 15:49 ` [PATCH 25/25] Documentation: coresight: Document AUX sample decoding Leo Yan
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=20260915-arm_cs_support_aux_sample-v1-0-35cf6f297d20@arm.com \
--to=leo.yan@arm.com \
--cc=aaupov@fb.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=anshuman.khandual@arm.com \
--cc=corbet@lwn.net \
--cc=coresight@lists.linaro.org \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mike.leach@arm.com \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=smahar@meta.com \
--cc=suzuki.poulose@arm.com \
--cc=yeoreum.yun@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®