From: Kunwu Chan <kunwu.chan@gmail.com>
To: will@kernel.org, mark.rutland@arm.com, sj@kernel.org,
akpm@linux-foundation.org, shuah@kernel.org,
kunwu.chan@linux.dev
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-perf-users@vger.kernel.org, damon@lists.linux.dev,
linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
Kunwu Chan <kunwu.chan@gmail.com>,
Lian Wang <lianux.mm@gmail.com>
Subject: [RFC PATCH 1/4] mm/damon/perf: introduce AUX backend interface and Kconfig
Date: Sun, 16 Aug 2026 22:22:18 +0800 [thread overview]
Message-ID: <20260816142222.689624-2-kunwu.chan@linux.dev> (raw)
In-Reply-To: <20260816142222.689624-1-kunwu.chan@linux.dev>
From: Kunwu Chan <kunwu.chan@gmail.com>
Add the backend operations used by AUX trace-buffer PMUs, backend state
to damon_perf_event, and stubs for configurations without AUX support.
Add CONFIG_DAMON_PERF_AUX for the ARM SPE transport and a separate
CONFIG_DAMON_PERF_SPE_KUNIT_TEST option. The current transport requires
ARM SPE to be built into the kernel; it remains independent of the
optional observability counters and tracepoints.
Co-developed-by: Lian Wang (ProcessMission) <lianux.mm@gmail.com>
Signed-off-by: Lian Wang (ProcessMission) <lianux.mm@gmail.com>
Signed-off-by: Kunwu Chan <kunwu.chan@gmail.com>
---
include/linux/damon.h | 5 +++
mm/damon/Kconfig | 28 +++++++++++++++
mm/damon/perf/aux_backend.h | 72 +++++++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+)
create mode 100644 mm/damon/perf/aux_backend.h
diff --git a/include/linux/damon.h b/include/linux/damon.h
index c191c065b0e4..a27c5f6c459b 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -8,6 +8,7 @@
#ifndef _DAMON_H_
#define _DAMON_H_
+#include <linux/cpumask.h>
#include <linux/math64.h>
#include <linux/memcontrol.h>
#include <linux/mutex.h>
@@ -127,6 +128,7 @@ struct damon_target {
enum damon_report_source {
DAMON_REPORT_SRC_PERF_OVERFLOW = 0, /* overflow_handler (IBS, PEBS) */
DAMON_REPORT_SRC_PAGE_FAULT, /* damon_report_page_fault() */
+ DAMON_REPORT_SRC_PERF_AUX, /* AUX trace-buffer backend */
};
/**
@@ -538,6 +540,7 @@ struct damos_filter {
struct damon_ctx;
struct damon_target_lookup;
struct damos;
+struct damon_perf_backend_ops;
/**
* struct damos_walk_control - Control damos_walk().
@@ -1056,6 +1059,8 @@ struct damon_perf_event_attr {
struct damon_perf_event {
struct damon_perf_event_attr attr;
void *priv;
+ const struct damon_perf_backend_ops *ops;
+ cpumask_t aux_cpumask;
struct list_head list;
struct hlist_node hlist_node;
bool init_complete;
diff --git a/mm/damon/Kconfig b/mm/damon/Kconfig
index 9fac286df124..e9fb62ec186f 100644
--- a/mm/damon/Kconfig
+++ b/mm/damon/Kconfig
@@ -149,4 +149,32 @@ config DAMON_PERF_OBSERVE
If unsure, say N.
+
+config DAMON_PERF_AUX
+ bool "DAMON AUX trace-buffer backend support"
+ depends on DAMON
+ depends on PERF_EVENTS
+ depends on ARM_SPE_PMU=y
+ default n
+ help
+ Enable the functional AUX trace-buffer transport for DAMON perf
+ events. This provides backend selection and drain scheduling for
+ ARM SPE, which does not deliver samples through an overflow
+ callback. ARM SPE must be built into the kernel.
+
+ This transport is independent of CONFIG_DAMON_PERF_OBSERVE.
+
+ If unsure, say N.
+
+config DAMON_PERF_SPE_KUNIT_TEST
+ bool "Test the DAMON perf SPE parser" if !KUNIT_ALL_TESTS
+ depends on DAMON_PERF_AUX && KUNIT=y
+ default KUNIT_ALL_TESTS
+ help
+ Test the ARM SPE parser with byte-exact packet streams. The cases
+ cover valid records, truncation, alignment, error resynchronization
+ and consumed-length accounting. Results can be exposed through
+ debugfs when CONFIG_KUNIT_DEBUGFS is enabled.
+
+ If unsure, say N.
endmenu
diff --git a/mm/damon/perf/aux_backend.h b/mm/damon/perf/aux_backend.h
new file mode 100644
index 000000000000..70e6ac6771bc
--- /dev/null
+++ b/mm/damon/perf/aux_backend.h
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _DAMON_PERF_AUX_BACKEND_H
+#define _DAMON_PERF_AUX_BACKEND_H
+
+#include <linux/bits.h>
+#include <linux/errno.h>
+#include <linux/perf_event.h>
+#include <linux/types.h>
+
+struct damon_ctx;
+struct damon_perf_event;
+
+/**
+ * struct damon_perf_backend_ops - PMU-specific AUX backend operations
+ * @name: Human-readable backend name.
+ * @flags: Bitmask of DAMON_PERF_BACKEND_* flags.
+ * @match_pmu: Return true when this backend claims @perf_event.
+ * @init: Allocate per-event, per-CPU resources.
+ * @cleanup: Release resources initialized for one CPU.
+ * @arm: Prepare the AUX producer before perf_event_enable().
+ * @disarm: Quiesce backend state after perf_event_disable().
+ * @drain: Parse pending AUX data into DAMON access reports.
+ *
+ * All callbacks run in process context. The caller serializes resource
+ * lifetime against CPU hotplug and invokes @drain only for CPUs recorded
+ * in damon_perf_event::aux_cpumask.
+ */
+struct damon_perf_backend_ops {
+ const char *name;
+ u32 flags;
+ bool (*match_pmu)(struct perf_event *perf_event);
+ int (*init)(struct damon_perf_event *event, int cpu,
+ struct perf_event *perf_event);
+ void (*cleanup)(struct damon_perf_event *event, int cpu);
+ int (*arm)(struct damon_perf_event *event, int cpu);
+ void (*disarm)(struct damon_perf_event *event, int cpu);
+ unsigned int (*drain)(struct damon_perf_event *event, int cpu);
+};
+
+#define DAMON_PERF_BACKEND_AUX BIT(0)
+
+#ifdef CONFIG_DAMON_PERF_AUX
+void damon_perf_aux_drain(struct damon_ctx *ctx);
+int damon_perf_aux_register_backend(const struct damon_perf_backend_ops *ops);
+const struct damon_perf_backend_ops *
+damon_perf_aux_find_backend(struct perf_event *perf_event);
+void damon_perf_aux_select(struct damon_perf_event *event,
+ struct perf_event *perf_event);
+#else
+static inline void damon_perf_aux_drain(struct damon_ctx *ctx)
+{
+}
+
+static inline int
+damon_perf_aux_register_backend(const struct damon_perf_backend_ops *ops)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline const struct damon_perf_backend_ops *
+damon_perf_aux_find_backend(struct perf_event *perf_event)
+{
+ return NULL;
+}
+
+static inline void damon_perf_aux_select(struct damon_perf_event *event,
+ struct perf_event *perf_event)
+{
+}
+#endif
+
+#endif /* _DAMON_PERF_AUX_BACKEND_H */
--
2.43.0
next prev parent reply other threads:[~2026-08-16 14:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-16 14:22 [RFC PATCH 0/4] mm/damon/perf: add ARM SPE AUX backend Kunwu Chan
2026-08-16 14:22 ` Kunwu Chan [this message]
2026-08-16 14:22 ` [RFC PATCH 2/4] mm/damon/perf: add AUX trace-buffer PMU backend for ARM SPE Kunwu Chan
2026-08-16 14:22 ` [RFC PATCH 3/4] mm/damon/perf: add KUnit tests for the SPE record parser Kunwu Chan
2026-08-16 14:22 ` [RFC PATCH 4/4] selftests/damon: add DAMON perf AUX backend test Kunwu Chan
2026-08-16 16:56 ` [RFC PATCH 0/4] mm/damon/perf: add ARM SPE AUX backend SJ Park
2026-08-17 2:57 ` KunWu Chan
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=20260816142222.689624-2-kunwu.chan@linux.dev \
--to=kunwu.chan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=kunwu.chan@linux.dev \
--cc=lianux.mm@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=shuah@kernel.org \
--cc=sj@kernel.org \
--cc=will@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.