drivers/perf/arm_spe_pmu.c | 8 + include/linux/damon.h | 5 + include/linux/perf/arm_spe_pmu.h | 11 + mm/damon/Kconfig | 28 + mm/damon/core.c | 22 +- mm/damon/ops-common.h | 6 +- mm/damon/perf/Makefile | 5 + mm/damon/perf/aux_backend.c | 121 +++++ mm/damon/perf/aux_backend.h | 72 +++ mm/damon/perf/spe_backend.c | 479 ++++++++++++++++++ mm/damon/perf/spe_parser.h | 109 ++++ mm/damon/perf/spe_parser_test.c | 365 +++++++++++++ mm/damon/vaddr.c | 68 ++- tools/testing/selftests/damon/Makefile | 1 + .../selftests/damon/damon_perf_aux_test.sh | 414 +++++++++++++++ 15 files changed, 1704 insertions(+), 10 deletions(-) create mode 100644 include/linux/perf/arm_spe_pmu.h create mode 100644 mm/damon/perf/aux_backend.c create mode 100644 mm/damon/perf/aux_backend.h create mode 100644 mm/damon/perf/spe_backend.c create mode 100644 mm/damon/perf/spe_parser.h create mode 100644 mm/damon/perf/spe_parser_test.c create mode 100755 tools/testing/selftests/damon/damon_perf_aux_test.sh
From: Kunwu Chan <kunwu.chan@gmail.com>
This series adds an AUX trace-buffer backend to the DAMON perf
observability framework, enabling ARM SPE (Statistical Profiling
Extension) to deliver hardware-sampled access reports into DAMON's
existing SPSC report ring.
Patch 2 touches drivers/perf/arm_spe_pmu.c to expose the PMU matcher.
This change is tightly coupled with the DAMON AUX backend. ARM SPE
PMU driver maintainers only need to review patch 2.
This series is based on the Ravi's hardware-sampled access reports
branch [1], and depends on the perf AUX kernel-consumer RFC series [2].
The dependencies is not upstream yet, so this series remains RFC.
Why a dedicated AUX backend
---------------------------
ARM SPE and similar PMUs do not deliver samples through the standard
perf overflow callback. Instead, they write trace data into an AUX
buffer managed by the perf core. The AUX buffer is consumed from
process context (kdamond) rather than from NMI, so the existing
overflow-callback path in DAMON cannot be reused.
The backend model adds three operations to the damon_perf_event
lifecycle: init (allocate the AUX buffer), arm (position the consumer
cursor), and drain (parse the SPE packet stream and publish reports).
The backend is selected at event creation time by matching the PMU
object via its event_init callback.
What the series adds
--------------------
Patch 1 introduces the backend operations table, the backend state
fields in damon_perf_event, and the Kconfig options. ARM SPE must be
built into the kernel; the KUnit test option is separate.
Patch 2 is the ARM SPE backend. It owns a per-CPU AUX buffer,
decodes the SPE packet stream (the same encoding that perf's
userspace arm-spe-decoder handles), resolves sampled
CONTEXTIDR_EL1 values to tgids under RCU, and publishes synthesized
access reports. The drain runs before the SPSC ring consumer on
each monitoring interval, and a final drain after event disable
ensures no records are lost. The backend also modifies the ARM SPE
PMU driver to expose arm_spe_pmu_match() for PMU object matching.
Patch 3 adds byte-exact KUnit tests for the SPE record parser. The
tests cover load and store records, timestamp terminators, multiple
records in one window, PAD and ALIGNMENT packets at both odd and
aligned positions, extended addresses, bad-packet resynchronization,
truncated records, and records without a virtual address. A split-
record test verifies that a record spanning two AUX snapshots leaves
the tail unchanged until the terminating packet arrives.
Patch 4 adds a DAMON selftest for the AUX backend. It checks the
backend integration, the required AUX-before-ring lifecycle ordering,
runs the parser KUnit suite through debugfs, and on an ARM SPE system
creates a live DAMON session with a controlled userspace target,
verifying positive end-to-end pipeline counters and final
enqueue/dequeue closure.
Testing
=======
Tested on Kunpeng 920 (256 CPUs, ARM SPE, kernel 7.1.0-rc5-mm-new-damon+):
ARM SPE KUnit (spe_parse_one_record):
16 passed, 0 failed, 0 skipped
(store record, load record with timestamp, two records, pad-wrapped,
alignment at odd/aligned positions, bad packet resync, record without
address, events/source/counter, truncated record retained, truncated
packet retained, extended address, invalid extended header, pad-only,
empty window, split record across two snapshots)
AUX selftest (damon_perf_aux_test.sh arm_spe_0):
SUMMARY: 52 passed, 0 failed, 0 skipped (Overall PASS)
callback=58318, valid=58318, enqueue=43390, dequeue=43390,
match=34049, update=564
final ring closure: enqueue=43390 dequeue=43390
Known limitations
=================
- AUX_BACKEND_MAX=4: the AUX backend registration table holds at most 4
backend types. This is a framework limit, not a per-PMU-instance cap.
- ARM SPE must be built into the kernel (ARM_SPE_PMU=y), not as a
module, because the backend calls arm_spe_pmu_match() at initcall
time.
- The AUX buffer is 2 pages (8 KiB). The SPE hardware pauses when the
non-overwrite ring is full; the drain frees space and re-enables
the event.
- CONTEXTIDR_EL1 carries the sampled task's pid, resolved to tgid
under RCU. Records without a valid tgid are dropped.
- This series requires the perf AUX kernel API patches [2] to be applied
first. These patches are not yet upstream and must be reviewed by the
perf subsystem maintainers.
References
==========
Link [1]: https://github.com/damonitor/linux.git
branch: ravi_hw_sampled_access_reports_rfc_v1
commit: fd968106e5bf
Link [2]: https://lore.kernel.org/all/20260814144927.489172-1-kunwu.chan@linux.dev/
perf AUX kernel API PATCH Series:
- perf/core: add AUX buffer ownership for kernel events
- perf/core: add AUX ring accessors for kernel consumers
- perf/core: add KUnit tests for AUX kernel-consumer API
- selftests/perf_events: add userspace AUX regression test
- selftests/perf_events: add AUX kernel API selftest script
Kunwu Chan (2):
mm/damon/perf: introduce AUX backend interface and Kconfig
mm/damon/perf: add AUX trace-buffer PMU backend for ARM SPE
Lian Wang (ProcessMission) (2):
mm/damon/perf: add KUnit tests for the SPE record parser
selftests/damon: add DAMON perf AUX backend test
drivers/perf/arm_spe_pmu.c | 8 +
include/linux/damon.h | 5 +
include/linux/perf/arm_spe_pmu.h | 11 +
mm/damon/Kconfig | 28 +
mm/damon/core.c | 22 +-
mm/damon/ops-common.h | 6 +-
mm/damon/perf/Makefile | 5 +
mm/damon/perf/aux_backend.c | 121 +++++
mm/damon/perf/aux_backend.h | 72 +++
mm/damon/perf/spe_backend.c | 479 ++++++++++++++++++
mm/damon/perf/spe_parser.h | 109 ++++
mm/damon/perf/spe_parser_test.c | 365 +++++++++++++
mm/damon/vaddr.c | 68 ++-
tools/testing/selftests/damon/Makefile | 1 +
.../selftests/damon/damon_perf_aux_test.sh | 414 +++++++++++++++
15 files changed, 1704 insertions(+), 10 deletions(-)
create mode 100644 include/linux/perf/arm_spe_pmu.h
create mode 100644 mm/damon/perf/aux_backend.c
create mode 100644 mm/damon/perf/aux_backend.h
create mode 100644 mm/damon/perf/spe_backend.c
create mode 100644 mm/damon/perf/spe_parser.h
create mode 100644 mm/damon/perf/spe_parser_test.c
create mode 100755 tools/testing/selftests/damon/damon_perf_aux_test.sh
--
2.43.0
Hello Kunwu, On Sun, 16 Aug 2026 22:22:17 +0800 Kunwu Chan <kunwu.chan@gmail.com> wrote: > From: Kunwu Chan <kunwu.chan@gmail.com> > > This series adds an AUX trace-buffer backend to the DAMON perf > observability framework, enabling ARM SPE (Statistical Profiling > Extension) to deliver hardware-sampled access reports into DAMON's > existing SPSC report ring. Awesome. Thank you for making this. This will make DAMON be more useful on ARM machines. > > Patch 2 touches drivers/perf/arm_spe_pmu.c to expose the PMU matcher. > This change is tightly coupled with the DAMON AUX backend. ARM SPE > PMU driver maintainers only need to review patch 2. > > This series is based on the Ravi's hardware-sampled access reports > branch [1], and depends on the perf AUX kernel-consumer RFC series [2]. > The dependencies is not upstream yet, so this series remains RFC. Unfortunately I haven't had a time to thoroughly read the dependent patches. I believe the basic idea of this patch series is aligned with the ongoing DAMON extension roadmap [1], though. That is, this series is supposed to be a part of the milestone 3. We are currently at the near end of milestone 1, and aim to complete milestone 2 by the time around next year's LSFMMBPF. I will hold review of this series for now, and take more time on making milestones 1 and 2 for thier planned delivery timeline. Sorry for being a bottleneck of your work, and thanks in advance for your patience. Please feel free to let me know if you have specific parts that need my review right now, though. Otherwise, please make sure this is aligned with the roadmap until we finish the milestone 2. I do want ARM SPE support of DAMON. [1] https://lore.kernel.org/all/20260525225208.1179-1-sj@kernel.org/ Thanks, SJ [...]
Hello SJ, On Mon, Aug 17, 2026 at 12:56 AM SJ Park <sj@kernel.org> wrote: > > Hello Kunwu, > > On Sun, 16 Aug 2026 22:22:17 +0800 Kunwu Chan <kunwu.chan@gmail.com> wrote: > > > From: Kunwu Chan <kunwu.chan@gmail.com> > > > > This series adds an AUX trace-buffer backend to the DAMON perf > > observability framework, enabling ARM SPE (Statistical Profiling > > Extension) to deliver hardware-sampled access reports into DAMON's > > existing SPSC report ring. > > Awesome. Thank you for making this. This will make DAMON be more useful on > ARM machines. Thanks for the feedback. > > > > > Patch 2 touches drivers/perf/arm_spe_pmu.c to expose the PMU matcher. > > This change is tightly coupled with the DAMON AUX backend. ARM SPE > > PMU driver maintainers only need to review patch 2. > > > > This series is based on the Ravi's hardware-sampled access reports > > branch [1], and depends on the perf AUX kernel-consumer RFC series [2]. > > The dependencies is not upstream yet, so this series remains RFC. > > Unfortunately I haven't had a time to thoroughly read the dependent patches. I > believe the basic idea of this patch series is aligned with the ongoing DAMON > extension roadmap [1], though. That is, this series is supposed to be a part > of the milestone 3. We are currently at the near end of milestone 1, and aim > to complete milestone 2 by the time around next year's LSFMMBPF. One clarification on the architecture: the AUX backend is intended as a transport/front-end for damon_report_access(), rather than a separate reporting path. spe_submit() ultimately calls damon_report_access(&report), and the AUX path shares the same SPSC report ring and kdamond_check_reported_accesses() consumer with the existing overflow-callback path. The main difference is the producer context: the overflow path enqueues from NMI context, while the AUX path enqueues from kdamond process context. The perf AUX kernel-consumer API is still an upstream dependency, so there is no specific part that needs your review right now. The implementation is already functional and tested on Kunpeng 920, and I can rebase and resend once the dependency chain is ready and the relevant DAMON infrastructure has landed. Separately, the DAMON perf observability framework (CONFIG_DAMON_PERF_OBSERVE) was developed in parallel with the AUX backend and is already implemented. It provides the observability infrastructure used by both the existing overflow path and the new AUX path, including per-CPU pipeline counters, debugfs statistics, and tracepoints. This work is independent of the AUX transport, and I will post it shortly as a standalone series. Thanks, Kunwu > > I will hold review of this series for now, and take more time on making > milestones 1 and 2 for thier planned delivery timeline. Sorry for being a > bottleneck of your work, and thanks in advance for your patience. > > Please feel free to let me know if you have specific parts that need my review > right now, though. Otherwise, please make sure this is aligned with the > roadmap until we finish the milestone 2. I do want ARM SPE support of DAMON. > > [1] https://lore.kernel.org/all/20260525225208.1179-1-sj@kernel.org/ > > > Thanks, > SJ > > [...]
© 2016 - 2026 Red Hat, Inc.