[RFC PATCH v3 02/37] mm/damon: define struct damon_sample_control

SeongJae Park
2025-12-08T06:29:51Z

All existing DAMON operation sets are using page table Accessed bits as
their access check sampling primitive. In following commits, the
operation set for physical address space will be extended for multiple
access sampling primitives, specifically page fault events. Define a
new DAMON core layer API data structure for controlling which primitives
the given operation set should use.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
include/linux/damon.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 1bee6e7fed1d..b9359c76a6f1 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -765,6 +765,33 @@ struct damon_attrs {
unsigned long aggr_samples;
};

+/**
+ * struct damon_primitives_enabled - Enablement of access sampling primitives.
+ *
+ * @page_table: Page table Accessed bits scanning.
+ * @page_fault: Page faults monitoring.
+ *
+ * Read &struct damon_sample_control for more details.
+ */
+struct damon_primitives_enabled {
+ bool page_table;
+ bool page_fault;
+};
+
+/**
+ * struct damon_sample_control - Low level access check sampling rules.
+ *
+ * @primitives_enabled: Enablement of access check primitives.
+ *
+ * DAMON collect low level access information using sampling, and aggregate
+ * that to make higher access pattern picture. It can use multiple sampling
+ * primitives including page table accessed bits and page fault events. This
+ * struct is for controlling what sampling primitives to use (enable).
+ */
+struct damon_sample_control {
+ struct damon_primitives_enabled primitives_enabled;
+};
+
/**
* struct damon_ctx - Represents a context for each monitoring. This is the
* main interface that allows users to set the attributes and get the results
@@ -833,6 +860,7 @@ struct damon_ctx {
struct mutex kdamond_lock;

struct damon_operations ops;
+ struct damon_sample_control sample_control;
unsigned long addr_unit;
unsigned long min_sz_region;

--
2.47.3