Skip to contentSkip to conversation

mm/damon: introduce data access-as-a-data attribute

RFC PATCH Superseded SJ Park 2 participants 38 messages Jul 25

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

SJ Park

author maintainer
#0 lore raw

cover mm/damon: introduce data access-as-a-data attribute

TL;DR: extend DAMON's data attributes monitoring system to support page table accessed bit and PG_idle based access monitoring.

DAMON was initially introduced as a data access monitor. Users found data access pattern becomes more useful when it is combined with other data attributes such as belonging cgroups and backing page types. For such cases, DAMON has extended to support such data attributes monitoring in addition to the original data access monitoring. The DAMON probes system was introduced for this purpose. Users set probes for filtering data attributes of their interest. For use cases where the primary interests are the attributes but the access pattern, probe weights system has been introduced. When it is used, DAMON applies its adaptive regions adjustment based on the monitored data attributes.

However, DAMON stops access monitoring when the probe weights are used. DAMON cannot optimally help users who have interests in both data attributes and access patterns. Data access can also be thought of as another data attribute, though. Extend the probe system to support data access as a data attribute.

Introduce a new probe filter type, pgidle_unset. It shows if the page is not set as idle. Specifically, it shows the page table accessed bit and the PG_idle flag. It can inform if the region is ever accessed. But it cannot say when it is accessed. To answer the second question, introduce a new probe feature, prep actions. Using the features, Users can specify what preparation actions should be made to each region for each probe. DAMON executes the preparation actions for each sampling interval, like it is doing the preparation for access check in the access monitoring mode. To help 'pgidle_unset' probe action use case, 'set_pgidle' preparation action is introduced together. The action does exactly what the access monitoring was doing: clearing the page table accessed bits and setting the PG_idle flags.

Patches Sequence
================

First four patches (patches 1-4) introduce the new probe filter type for knowing if a region is accessed. Patch 1 defines the new type in the core. Patch 2 implements the execution of the new filter in the physical address space DAMON operation set. Patch 3 implements a user interface on DAMON sysfs interface. Patch 4 updates the documentation for the new filter type.

Following 13 patches (patches 5-17) introduce the probe preparation actions feature. Patch 5 defines the data structure for specifying the preparation actions. Patch 6 completes setup of the API parameter for the prep. Patch 7 extends the DAMON operation set callback list to connect the parameter with the underlying operation set. Patch 8 implements the execution of the prep in the physical address space DAMON operation set.

Following five patches (patches 9-13) extends DAMON sysfs interface for the new prep feature. Patch 14 adds simple selftest for basic file operations of the new sysfs files. Final three patches (patches 15-17) respectively update design, usage and ABI documents for the new feature and its interface.

SJ Park (17):
mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET mm/damon/paddr: support PGIDLE_UNSET probe filter type mm/damon/sysfs: support pgidle_unset probe filter type Docs/mm/damon/design: document pgidle_unset probe filter type mm/damon/core: introduce damon_prep struct mm/damon/core: commit preps
mm/damon/core: introduce damon_operations->prep_probes() mm/damon/paddr: support damon_prep
mm/damon/sysfs: implement preps directory mm/damon/sysfs: create probe preps directory mm/damon/sysfs: implement probe prep directory mm/damon/sysfs: create probe prep files for preps/nr file write mm/damon/sysfs: pass preps to DAMON core selftests/damon/sysfs.sh: test probe prep sysfs files Docs/mm/damon/design: document probe preps Docs/admin-guide/mm/damon/usage: document probe preps sysfs files Docs/ABI/damon: document probe prep sysfs files

 .../ABI/testing/sysfs-kernel-mm-damon         |  13 +
 Documentation/admin-guide/mm/damon/usage.rst  |  18 +-
 Documentation/mm/damon/design.rst             |  17 +-
 include/linux/damon.h                         |  42 ++-
 mm/damon/core.c                               | 103 ++++++-
 mm/damon/paddr.c                              |  41 +++
 mm/damon/sysfs.c                              | 280 +++++++++++++++++-
 tools/testing/selftests/damon/sysfs.sh        |  27 ++
 8 files changed, 527 insertions(+), 14 deletions(-)

base-commit: 7c69a13f116ab63f525a2c4b0be7ce89f73befcd

Signature · 1 line
2.47.3
author maintainer
#1 lore raw

RFC PATCH 1/17 mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET

Introduce a new DAMON filter type, pgidle_unset. It will match pages that have their PG_Idle flag unset, or the page table accessed bit set. In other words, it says if the page is accessed.

---
 include/linux/damon.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
include/linux/damon.h +4 -2
index 8ad6ef2e063de..cee4b74761081 100644
@@ -744,12 +744,14 @@ struct damon_intervals_goal {
 /**
  * enum damon_filter_type - Type of &struct damon_filter
  *
- * @DAMON_FILTER_TYPE_ANON:	Anonymous pages.
- * @DAMON_FILTER_TYPE_MEMCG:	Specific memcg's pages.
+ * @DAMON_FILTER_TYPE_ANON:		Anonymous pages.
+ * @DAMON_FILTER_TYPE_MEMCG:		Specific memcg's pages.
+ * @DAMON_FILTER_TYPE_PGIDLE_UNSET:	Pgidle is unset.
  */
 enum damon_filter_type {
 	DAMON_FILTER_TYPE_ANON,
 	DAMON_FILTER_TYPE_MEMCG,
+	DAMON_FILTER_TYPE_PGIDLE_UNSET,
 };
 
 /**
Signature · 1 line
2.47.3
author maintainer
#4 lore raw

RFC PATCH 2/17 mm/damon/paddr: support PGIDLE_UNSET probe filter type

In reply to SJ Park

Implement support of DAMON_FILTER_TYPE_PGIDLE_UNSET in the physical address space DAMON operations set. It reuses damon_folio_young(), which was being used for access monitoring.

---
 mm/damon/paddr.c | 6 ++++++
 1 file changed, 6 insertions(+)
mm/damon/paddr.c +6 -0
index 5a6a78054784a..199de1463fa06 100644
@@ -132,6 +132,12 @@ static bool damon_pa_filter_match(struct damon_filter *filter,
 			matched = filter->memcg_id == mem_cgroup_id(memcg);
 		rcu_read_unlock();
 		break;
+	case DAMON_FILTER_TYPE_PGIDLE_UNSET:
+		if (!folio)
+			matched = false;
+		else
+			matched = damon_folio_young(folio);
+		break;
 	default:
 		break;
 	}
Signature · 1 line
2.47.3
author maintainer
#7 lore raw

RFC PATCH 3/17 mm/damon/sysfs: support pgidle_unset probe filter type

In reply to SJ Park

Extend DAMON sysfs interface to allow users to set DAMON_FILTER_TYPE_PGIDLE_UNSET by writing 'pgidle_unset' to the probe filter type file.

---
 mm/damon/sysfs.c | 4 ++++
 1 file changed, 4 insertions(+)
mm/damon/sysfs.c +4 -0
index 053ba2e53b969..376c6ecbd4bf3 100644
@@ -782,6 +782,10 @@ damon_sysfs_filter_type_names[] = {
 		.type = DAMON_FILTER_TYPE_MEMCG,
 		.name = "memcg",
 	},
+	{
+		.type = DAMON_FILTER_TYPE_PGIDLE_UNSET,
+		.name = "pgidle_unset",
+	},
 };
 
 static ssize_t type_show(struct kobject *kobj,
Signature · 1 line
2.47.3
author maintainer
#8 lore raw

RFC PATCH 4/17 Docs/mm/damon/design: document pgidle_unset probe filter type

In reply to SJ Park

Update DAMON design document for the newly added pgidle_unset probe filter type. Also use a list for the types, as it becomes not very easy to read the whole types in a simple sentence.

---
 Documentation/mm/damon/design.rst | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Documentation/mm/damon/design.rst +8 -2
index a8c163475ef2b..12a2c3f81a262 100644
@@ -293,8 +293,14 @@ registration is made by specifying a probe per attribute.  Each of the probe
 specifies a rule to determine if a given memory region has the related
 attribute.  The rule is constructed with multiple filters.  The filters work
 same to :ref:`DAMOS filters <damon_design_damos_filters>` except the supported
-filter types.  Currently only ``anon`` and ``memcg`` filter types are supported
-for data attributes monitoring.
+filter types.  Currently below fitler types are supported.
+
+- ``anon``: Same to that for DAMOS filters.
+- ``memcg``: Same to that for DAMOS filters.
+- ``pgidle_unset``: Matches if the page for the memory is marked as not
+  access-idle.
+  Matches if the memory is not backed by pages that DAMON can idnetify
+  idleness.
 
 If such probes are registered, DAMON executes the probes for each region's
 sampling memory when it does the access :ref:`sampling
Signature · 1 line
2.47.3
author maintainer
#11 lore raw

RFC PATCH 5/17 mm/damon/core: introduce damon_prep struct

In reply to SJ Park

Some DAMON probe filter types require preparatory actions. For example, pgilde_unset probe filter can say if the page was accessed but when. To answer the second question, the PG_Idle flag should be set at a specific time. It can make life much easier if DAMON can do such preparatory actions. Introduce a new data type called damon_prep. It specifies each of the preparation actions for each probe. DAMON will execute the action for each region per sampling interval, like it clears page table accessed bits and unsets PG_Idle flag for access monitoring.

Also introduce DAMON_PREP_SET_PGIDLE as the initial prep action. As the name says, it will do exactly what DAMON was doing as the preparation action for the access monitoring.

---
 include/linux/damon.h | 32 ++++++++++++++++++++++++++++++++
 mm/damon/core.c       | 26 ++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
include/linux/damon.h +32 -0
index cee4b74761081..255b20e44287f 100644
@@ -741,6 +741,27 @@ struct damon_intervals_goal {
 	unsigned long max_sample_us;
 };
 
+/**
+ * enum damon_prep_action - DAMON probing preparation action.
+ *
+ * @DAMON_PREP_SET_PGIDLE:	Set the probing memory as idle page.
+ */
+enum damon_prep_action {
+	DAMON_PREP_SET_PGIDLE,
+};
+
+/**
+ * struct damon_prep - DAMON probing preparation request.
+ *
+ * @action:	Action to do to the probing memory for the preparation.
+ */
+struct damon_prep {
+	enum damon_prep_action action;
+/* private: */
+	/* siblings list. */
+	struct list_head list;
+};
+
 /**
  * enum damon_filter_type - Type of &struct damon_filter
  *
@@ -782,6 +803,8 @@ struct damon_filter {
 struct damon_probe {
 	unsigned int weight;
 /* private: */
+	/* Preparation actions to apply to each probing memory. */
+	struct list_head preps;
 	/* Filters for assessing if a given region is for this probe. */
 	struct list_head filters;
 	/* Siblings list. */
@@ -961,6 +984,12 @@ static inline unsigned long damon_sz_region(struct damon_region *r)
 	return r->ar.end - r->ar.start;
 }
 
+#define damon_for_each_prep(p, prep) \
+	list_for_each_entry(p, &(prep)->preps, list)
+
+#define damon_for_each_prep_safe(p, next, prep) \
+	list_for_each_entry_safe(p, next, &(prep)->preps, list)
+
 #define damon_for_each_filter(f, p) \
 	list_for_each_entry(f, &(p)->filters, list)
 
@@ -1014,6 +1043,9 @@ static inline unsigned long damon_sz_region(struct damon_region *r)
 
 #ifdef CONFIG_DAMON
 
+struct damon_prep *damon_new_prep(enum damon_prep_action action);
+void damon_add_prep(struct damon_probe *p, struct damon_prep *prep);
+
 struct damon_filter *damon_new_filter(enum damon_filter_type type,
 		bool matching, bool allow);
 void damon_add_filter(struct damon_probe *probe, struct damon_filter *f);
mm/damon/core.c +26 -0
index 5eb0400d5ce16..bda61f9ec0266 100644
@@ -111,6 +111,28 @@ int damon_select_ops(struct damon_ctx *ctx, enum damon_ops_id id)
 	return err;
 }
 
+struct damon_prep *damon_new_prep(enum damon_prep_action action)
+{
+	struct damon_prep *prep;
+
+	prep = kmalloc_obj(*prep);
+	if (!prep)
+		return NULL;
+	prep->action = action;
+	INIT_LIST_HEAD(&prep->list);
+	return prep;
+}
+
+void damon_add_prep(struct damon_probe *p, struct damon_prep *prep)
+{
+	list_add_tail(&prep->list, &p->preps);
+}
+
+static void damon_free_prep(struct damon_prep *p)
+{
+	kfree(p);
+}
+
 struct damon_filter *damon_new_filter(enum damon_filter_type type,
 		bool matching, bool allow)
 {
@@ -167,6 +189,7 @@ struct damon_probe *damon_new_probe(void)
 	if (!p)
 		return NULL;
 	p->weight = 0;
+	INIT_LIST_HEAD(&p->preps);
 	INIT_LIST_HEAD(&p->filters);
 	INIT_LIST_HEAD(&p->list);
 	return p;
@@ -184,8 +207,11 @@ static void damon_del_probe(struct damon_probe *p)
 
 static void damon_free_probe(struct damon_probe *p)
 {
+	struct damon_prep *prep, *prep_next;
 	struct damon_filter *f, *next;
 
+	damon_for_each_prep_safe(prep, prep_next, p)
+		damon_free_prep(prep);
 	damon_for_each_filter_safe(f, next, p)
 		damon_free_filter(f);
 	kfree(p);
Signature · 1 line
2.47.3
author maintainer
#12 lore raw

RFC PATCH 6/17 mm/damon/core: commit preps

In reply to SJ Park

damon_commit_probes() is ignoring damon_prep. Commit the prep actions, too.

---
 mm/damon/core.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
mm/damon/core.c +59 -0
index bda61f9ec0266..c74dee56efee8 100644
@@ -128,11 +128,34 @@ void damon_add_prep(struct damon_probe *p, struct damon_prep *prep)
 	list_add_tail(&prep->list, &p->preps);
 }
 
+static void damon_del_prep(struct damon_prep *p)
+{
+	list_del(&p->list);
+}
+
 static void damon_free_prep(struct damon_prep *p)
 {
 	kfree(p);
 }
 
+static void damon_destroy_prep(struct damon_prep *p)
+{
+	damon_del_prep(p);
+	damon_free_prep(p);
+}
+
+static struct damon_prep *damon_nth_prep(int n, struct damon_probe *p)
+{
+	struct damon_prep *prep;
+	int i = 0;
+
+	damon_for_each_prep(prep, p) {
+		if (i++ == n)
+			return prep;
+	}
+	return NULL;
+}
+
 struct damon_filter *damon_new_filter(enum damon_filter_type type,
 		bool matching, bool allow)
 {
@@ -1694,6 +1717,36 @@ static int damon_commit_targets(
 	return err;
 }
 
+static void damon_commit_prep(struct damon_prep *dst, struct damon_prep *src)
+{
+	dst->action = src->action;
+}
+
+static int damon_commit_preps(struct damon_probe *dst, struct damon_probe *src)
+{
+	struct damon_prep *dst_prep, *next, *src_prep, *new_prep;
+	int i = 0, j = 0;
+
+	damon_for_each_prep_safe(dst_prep, next, dst) {
+		src_prep = damon_nth_prep(i++, src);
+		if (src_prep)
+			damon_commit_prep(dst_prep, src_prep);
+		else
+			damon_destroy_prep(dst_prep);
+	}
+
+	damon_for_each_prep_safe(src_prep, next, src) {
+		if (j++ < i)
+			continue;
+
+		new_prep = damon_new_prep(src_prep->action);
+		if (!new_prep)
+			return -ENOMEM;
+		damon_add_prep(dst, new_prep);
+	}
+	return 0;
+}
+
 static void damon_commit_filter(struct damon_filter *dst,
 		struct damon_filter *src)
 {
@@ -1752,6 +1805,9 @@ static int damon_commit_probes(struct damon_ctx *dst, struct damon_ctx *src)
 		src_probe = damon_nth_probe(i++, src);
 		if (src_probe) {
 			dst_probe->weight = src_probe->weight;
+			err = damon_commit_preps(dst_probe, src_probe);
+			if (err)
+				return err;
 			err = damon_commit_filters(dst_probe, src_probe);
 			if (err)
 				return err;
@@ -1769,6 +1825,9 @@ static int damon_commit_probes(struct damon_ctx *dst, struct damon_ctx *src)
 			return -ENOMEM;
 		damon_add_probe(dst, new_probe);
 		new_probe->weight = src_probe->weight;
+		err = damon_commit_preps(new_probe, src_probe);
+		if (err)
+			return err;
 		err = damon_commit_filters(new_probe, src_probe);
 		if (err)
 			return err;
Signature · 1 line
2.47.3
author maintainer
#13 lore raw

RFC PATCH 7/17 mm/damon/core: introduce damon_operations->prep_probes()

In reply to SJ Park

damon_prep needs to be executed by the underlying DAMON operation set. Extend the operation set callback list for the execution of damon_prep actions. If the underlying operation set implements the callback, DAMON core executes it in the monitoring preparation time.

---
 include/linux/damon.h |  4 ++++
 mm/damon/core.c       | 18 +++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
include/linux/damon.h +4 -0
index 255b20e44287f..f5b0f16305b30 100644
@@ -629,6 +629,7 @@ enum damon_ops_id {
  * @update:			Update operations-related data structures.
  * @prepare_access_checks:	Prepare next access check of target regions.
  * @check_accesses:		Check the accesses to target regions.
+ * @prep_probes:		Prepare applying probes for each region.
  * @apply_probes:		Apply probes for each region.
  * @get_scheme_score:		Get the score of a region for a scheme.
  * @apply_scheme:		Apply a DAMON-based operation scheme.
@@ -656,6 +657,8 @@ enum damon_ops_id {
  * last preparation and update the number of observed accesses of each region.
  * It should also return max number of observed accesses that made as a result
  * of its update.  The value will be used for regions adjustment threshold.
+ * @prep_probes should execute required &struct damon_prep for next &struct
+ * damon_probe applications to each region.
  * @apply_probes should apply the data attribute probes to each region and
  * accordingly update the probe hits counter of the region.  It should also
  * set &damon_region->sampling_addr of each region if ``set_samples`` is true.
@@ -678,6 +681,7 @@ struct damon_operations {
 	void (*update)(struct damon_ctx *context);
 	void (*prepare_access_checks)(struct damon_ctx *context);
 	unsigned int (*check_accesses)(struct damon_ctx *context);
+	void (*prep_probes)(struct damon_ctx *context, bool set_samples);
 	unsigned int (*apply_probes)(struct damon_ctx *context,
 			bool set_samples, bool return_max_wsum);
 	int (*get_scheme_score)(struct damon_ctx *context,
mm/damon/core.c +17 -1
index c74dee56efee8..11d16b7104a7e 100644
@@ -156,6 +156,18 @@ static struct damon_prep *damon_nth_prep(int n, struct damon_probe *p)
 	return NULL;
 }
 
+static bool damon_has_prep(struct damon_ctx *c)
+{
+	struct damon_prep *prep;
+	struct damon_probe *probe;
+
+	damon_for_each_probe(probe, c) {
+		damon_for_each_prep(prep, probe)
+			return true;
+	}
+	return false;
+}
+
 struct damon_filter *damon_new_filter(enum damon_filter_type type,
 		bool matching, bool allow)
 {
@@ -3868,6 +3880,7 @@ static int kdamond_fn(void *data)
 		unsigned long next_ops_update_sis = ctx->next_ops_update_sis;
 		unsigned long sample_interval = ctx->attrs.sample_interval;
 		bool access_check_disabled = damon_has_probe_weights(ctx);
+		bool has_prep = damon_has_prep(ctx);
 		unsigned int max_merge_score = 0, max_wsum;
 		bool get_max_wsum;
 
@@ -3876,6 +3889,8 @@ static int kdamond_fn(void *data)
 
 		if (!access_check_disabled && ctx->ops.prepare_access_checks)
 			ctx->ops.prepare_access_checks(ctx);
+		if (ctx->ops.prep_probes)
+			ctx->ops.prep_probes(ctx, has_prep);
 
 		kdamond_usleep(sample_interval);
 		ctx->passed_sample_intervals++;
@@ -3890,7 +3905,8 @@ static int kdamond_fn(void *data)
 			else
 				get_max_wsum = false;
 			max_wsum = ctx->ops.apply_probes(ctx,
-					access_check_disabled, get_max_wsum);
+					access_check_disabled && !has_prep,
+					get_max_wsum);
 			if (get_max_wsum)
 				max_merge_score = max_wsum;
 		}
Signature · 1 line
2.47.3
author maintainer
#16 lore raw

RFC PATCH 8/17 mm/damon/paddr: support damon_prep

In reply to SJ Park

Implement damon_operations->prep_probes() callback. Support the only existing prep action, DAMON_PREP_SET_PGIDLE in a way similar to what it was doing for the access check preparation: unset page table accessed bits and set PG_Idle flag. Reuse the function for the access check preparation.

---
 mm/damon/paddr.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
mm/damon/paddr.c +35 -0
index 199de1463fa06..8d8fcd1369e56 100644
@@ -105,6 +105,40 @@ static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx)
 	return max_nr_accesses;
 }
 
+static void damon_pa_prep_probes_region(struct damon_region *r,
+		struct damon_probe *probe, struct damon_ctx *ctx)
+{
+	struct damon_prep *p;
+
+	damon_for_each_prep(p, probe) {
+		switch (p->action) {
+		case DAMON_PREP_SET_PGIDLE:
+			damon_pa_mkold(damon_pa_phys_addr(r->sampling_addr,
+						ctx->addr_unit));
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+static void damon_pa_prep_probes(struct damon_ctx *ctx, bool set_samples)
+{
+	struct damon_target *t;
+	struct damon_region *r;
+	struct damon_probe *p;
+
+	damon_for_each_target(t, ctx) {
+		damon_for_each_region(r, t) {
+			if (set_samples)
+				r->sampling_addr = damon_rand(ctx, r->ar.start,
+						r->ar.end);
+			damon_for_each_probe(p, ctx)
+				damon_pa_prep_probes_region(r, p, ctx);
+		}
+	}
+}
+
 static bool damon_pa_filter_match(struct damon_filter *filter,
 		struct folio *folio)
 {
@@ -446,6 +480,7 @@ static int __init damon_pa_initcall(void)
 		.update = NULL,
 		.prepare_access_checks = damon_pa_prepare_access_checks,
 		.check_accesses = damon_pa_check_accesses,
+		.prep_probes = damon_pa_prep_probes,
 		.apply_probes = damon_pa_apply_probes,
 		.target_valid = NULL,
 		.apply_scheme = damon_pa_apply_scheme,
Signature · 1 line
2.47.3
author maintainer
#19 lore raw

RFC PATCH 9/17 mm/damon/sysfs: implement preps directory

In reply to SJ Park

Implement a sysfs directory and a file under the directory that will be used for setting DAMON probe preps. Implement only preparatory data structures and functions. The code is not really generating the directories at the moment.

---
 mm/damon/sysfs.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
mm/damon/sysfs.c +68 -0
index 376c6ecbd4bf3..7b971bfd1169f 100644
@@ -750,6 +750,74 @@ static const struct kobj_type damon_sysfs_intervals_ktype = {
 	.default_groups = damon_sysfs_intervals_groups,
 };
 
+/*
+ * preps directory
+ */
+
+struct damon_sysfs_preps {
+	struct kobject kobj;
+	int nr;
+};
+
+static int damon_sysfs_preps_add_dirs(struct damon_sysfs_preps *preps,
+		int nr_preps)
+{
+	preps->nr = nr_preps;
+	return 0;
+}
+
+static ssize_t nr_preps_show(struct kobject *kobj, struct kobj_attribute *attr,
+		char *buf)
+{
+	struct damon_sysfs_preps *preps = container_of(kobj,
+			struct damon_sysfs_preps, kobj);
+
+	return sysfs_emit(buf, "%d\n", preps->nr);
+}
+
+static ssize_t nr_preps_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	struct damon_sysfs_preps *preps;
+	int nr, err = kstrtoint(buf, 0, &nr);
+
+	if (err)
+		return err;
+	if (nr < 0)
+		return -EINVAL;
+
+	preps = container_of(kobj, struct damon_sysfs_preps, kobj);
+
+	if (!mutex_trylock(&damon_sysfs_lock))
+		return -EBUSY;
+	err = damon_sysfs_preps_add_dirs(preps, nr);
+	mutex_unlock(&damon_sysfs_lock);
+	if (err)
+		return err;
+
+	return count;
+}
+
+static void damon_sysfs_preps_release(struct kobject *kobj)
+{
+	kfree(container_of(kobj, struct damon_sysfs_preps, kobj));
+}
+
+static struct kobj_attribute damon_sysfs_preps_nr_attr =
+		__ATTR_RW_MODE(nr_preps, 0600);
+
+static struct attribute *damon_sysfs_preps_attrs[] = {
+	&damon_sysfs_preps_nr_attr.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(damon_sysfs_preps);
+
+static const struct kobj_type damon_sysfs_preps_ktype = {
+	.release = damon_sysfs_preps_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+	.default_groups = damon_sysfs_preps_groups,
+};
+
 /*
  * filter directory
  */
Signature · 1 line
2.47.3
author maintainer
#22 lore raw

RFC PATCH 10/17 mm/damon/sysfs: create probe preps directory

In reply to SJ Park

Create probe preps directory when the probe directory is generated.

---
 mm/damon/sysfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 42 insertions(+), 6 deletions(-)
mm/damon/sysfs.c +42 -6
index 7b971bfd1169f..6d3ed80fb2eb1 100644
@@ -759,6 +759,16 @@ struct damon_sysfs_preps {
 	int nr;
 };
 
+static struct damon_sysfs_preps *damon_sysfs_preps_alloc(void)
+{
+	return kzalloc_obj(struct damon_sysfs_preps);
+}
+
+static void damon_sysfs_preps_rm_dirs(struct damon_sysfs_preps *preps)
+{
+	preps->nr = 0;
+}
+
 static int damon_sysfs_preps_add_dirs(struct damon_sysfs_preps *preps,
 		int nr_preps)
 {
@@ -1138,6 +1148,7 @@ static const struct kobj_type damon_sysfs_filters_ktype = {
 struct damon_sysfs_probe {
 	struct kobject kobj;
 	unsigned int weight;
+	struct damon_sysfs_preps *preps;
 	struct damon_sysfs_filters *filters;
 };
 
@@ -1148,25 +1159,50 @@ static struct damon_sysfs_probe *damon_sysfs_probe_alloc(void)
 
 static int damon_sysfs_probe_add_dirs(struct damon_sysfs_probe *probe)
 {
+	struct damon_sysfs_preps *preps;
 	struct damon_sysfs_filters *filters;
 	int err;
 
-	filters = damon_sysfs_filters_alloc();
-	if (!filters)
+	preps = damon_sysfs_preps_alloc();
+	if (!preps)
 		return -ENOMEM;
+	probe->preps = preps;
+
+	err = kobject_init_and_add(&preps->kobj, &damon_sysfs_preps_ktype,
+			&probe->kobj, "preps");
+	if (err)
+		goto put_preps_out;
+
+	filters = damon_sysfs_filters_alloc();
+	if (!filters) {
+		err = -ENOMEM;
+		goto del_preps_out;
+	}
 	probe->filters = filters;
 
 	err = kobject_init_and_add(&filters->kobj, &damon_sysfs_filters_ktype,
 			&probe->kobj, "filters");
-	if (err) {
-		kobject_put(&filters->kobj);
-		probe->filters = NULL;
-	}
+	if (err)
+		goto put_filters_out;
+	return err;
+
+put_filters_out:
+	kobject_put(&filters->kobj);
+	probe->filters = NULL;
+del_preps_out:
+	kobject_del(&preps->kobj);
+put_preps_out:
+	kobject_put(&preps->kobj);
+	probe->preps = NULL;
 	return err;
 }
 
 static void damon_sysfs_probe_rm_dirs(struct damon_sysfs_probe *probe)
 {
+	if (probe->preps) {
+		damon_sysfs_preps_rm_dirs(probe->preps);
+		kobject_put(&probe->preps->kobj);
+	}
 	if (probe->filters) {
 		damon_sysfs_filters_rm_dirs(probe->filters);
 		kobject_put(&probe->filters->kobj);
Signature · 1 line
2.47.3
author maintainer
#23 lore raw

RFC PATCH 11/17 mm/damon/sysfs: implement probe prep directory

In reply to SJ Park

Implement DAMON sysfs directory and files for specifying each probe prep action. Introduce only preparatory data structure and functions. The files are not really being created under the sysfs.

---
 mm/damon/sysfs.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 83 insertions(+)
mm/damon/sysfs.c +83 -0
index 6d3ed80fb2eb1..b15ec082109b7 100644
@@ -750,6 +750,89 @@ static const struct kobj_type damon_sysfs_intervals_ktype = {
 	.default_groups = damon_sysfs_intervals_groups,
 };
 
+/*
+ * prep directory
+ */
+
+struct damon_sysfs_prep {
+	struct kobject kobj;
+	enum damon_prep_action action;
+};
+
+struct damon_sysfs_prep_action_name {
+	enum damon_prep_action action;
+	char *name;
+};
+
+static const struct damon_sysfs_prep_action_name
+damon_sysfs_prep_action_names[] = {
+	{
+		.action = DAMON_PREP_SET_PGIDLE,
+		.name = "set_pgidle",
+	},
+};
+
+static ssize_t prep_action_show(struct kobject *kobj,
+		struct kobj_attribute *attr, char *buf)
+{
+	struct damon_sysfs_prep *prep = container_of(kobj,
+			struct damon_sysfs_prep, kobj);
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(damon_sysfs_prep_action_names); i++) {
+		const struct damon_sysfs_prep_action_name *action_name;
+
+		action_name = &damon_sysfs_prep_action_names[i];
+		if (action_name->action == prep->action)
+			return sysfs_emit(buf, "%s\n", action_name->name);
+	}
+	return -EINVAL;
+}
+
+static ssize_t prep_action_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	struct damon_sysfs_prep *prep = container_of(kobj,
+			struct damon_sysfs_prep, kobj);
+	ssize_t ret = -EINVAL;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(damon_sysfs_prep_action_names); i++) {
+		const struct damon_sysfs_prep_action_name *action_name;
+
+		action_name = &damon_sysfs_prep_action_names[i];
+		if (sysfs_streq(buf, action_name->name)) {
+			prep->action = action_name->action;
+			ret = count;
+			break;
+		}
+	}
+	return ret;
+}
+
+static void damon_sysfs_prep_release(struct kobject *kobj)
+{
+	struct damon_sysfs_prep *prep = container_of(kobj,
+			struct damon_sysfs_prep, kobj);
+
+	kfree(prep);
+}
+
+static struct kobj_attribute damon_sysfs_prep_prep_action_attr =
+		__ATTR_RW_MODE(prep_action, 0600);
+
+static struct attribute *damon_sysfs_prep_attrs[] = {
+	&damon_sysfs_prep_prep_action_attr.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(damon_sysfs_prep);
+
+static const struct kobj_type damon_sysfs_prep_ktype = {
+	.release = damon_sysfs_prep_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+	.default_groups = damon_sysfs_prep_groups,
+};
+
 /*
  * preps directory
  */
Signature · 1 line
2.47.3
author maintainer
#26 lore raw

RFC PATCH 12/17 mm/damon/sysfs: create probe prep files for preps/nr file write

In reply to SJ Park

Implement preps/nr file write operation to really create the probe prep directories and their files.

---
 mm/damon/sysfs.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)
mm/damon/sysfs.c +53 -1
index b15ec082109b7..f275a6f73eee1 100644
@@ -759,6 +759,17 @@ struct damon_sysfs_prep {
 	enum damon_prep_action action;
 };
 
+static struct damon_sysfs_prep *damon_sysfs_prep_alloc(void)
+{
+	struct damon_sysfs_prep *prep;
+
+	prep = kzalloc_obj(struct damon_sysfs_prep);
+	if (!prep)
+		return prep;
+	prep->action = DAMON_PREP_SET_PGIDLE;
+	return prep;
+}
+
 struct damon_sysfs_prep_action_name {
 	enum damon_prep_action action;
 	char *name;
@@ -839,6 +850,7 @@ static const struct kobj_type damon_sysfs_prep_ktype = {
 
 struct damon_sysfs_preps {
 	struct kobject kobj;
+	struct damon_sysfs_prep **preps_arr;
 	int nr;
 };
 
@@ -849,13 +861,53 @@ static struct damon_sysfs_preps *damon_sysfs_preps_alloc(void)
 
 static void damon_sysfs_preps_rm_dirs(struct damon_sysfs_preps *preps)
 {
+	struct damon_sysfs_prep **preps_arr = preps->preps_arr;
+	int i;
+
+	for (i = 0; i < preps->nr; i++) {
+		kobject_del(&preps_arr[i]->kobj);
+		kobject_put(&preps_arr[i]->kobj);
+	}
 	preps->nr = 0;
+	kfree(preps_arr);
+	preps->preps_arr = NULL;
 }
 
 static int damon_sysfs_preps_add_dirs(struct damon_sysfs_preps *preps,
 		int nr_preps)
 {
-	preps->nr = nr_preps;
+	struct damon_sysfs_prep **preps_arr, *prep;
+	int err, i;
+
+	damon_sysfs_preps_rm_dirs(preps);
+	if (!nr_preps)
+		return 0;
+
+	preps_arr = kmalloc_objs(*preps_arr, nr_preps,
+				   GFP_KERNEL | __GFP_NOWARN);
+	if (!preps_arr)
+		return -ENOMEM;
+	preps->preps_arr = preps_arr;
+
+	for (i = 0; i < nr_preps; i++) {
+		prep = damon_sysfs_prep_alloc();
+		if (!prep) {
+			damon_sysfs_preps_rm_dirs(preps);
+			return -ENOMEM;
+		}
+
+		err = kobject_init_and_add(&prep->kobj,
+				&damon_sysfs_prep_ktype, &preps->kobj, "%d",
+				i);
+		if (err) {
+			kobject_put(&prep->kobj);
+			damon_sysfs_preps_rm_dirs(preps);
+			return err;
+		}
+
+		preps_arr[i] = prep;
+		preps->nr++;
+	}
 	return 0;
 }
 
Signature · 1 line
2.47.3
author maintainer
#27 lore raw

RFC PATCH 13/17 mm/damon/sysfs: pass preps to DAMON core

In reply to SJ Park

DAMON sysfs interface provides the files for setting DAMON probe preps. But the underlying code is not really passing the user-set values to DAMON core. Pass those.

---
 mm/damon/sysfs.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
mm/damon/sysfs.c +25 -0
index f275a6f73eee1..d7a2b62322841 100644
@@ -2174,6 +2174,23 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx,
 	return damon_set_attrs(ctx, &attrs);
 }
 
+static int damon_sysfs_set_preps(struct damon_probe *probe,
+		struct damon_sysfs_preps *sys_preps)
+{
+	int i;
+
+	for (i = 0; i < sys_preps->nr; i++) {
+		struct damon_sysfs_prep *sys_prep = sys_preps->preps_arr[i];
+		struct damon_prep *prep;
+
+		prep = damon_new_prep(sys_prep->action);
+		if (!prep)
+			return -ENOMEM;
+		damon_add_prep(probe, prep);
+	}
+	return 0;
+}
+
 static int damon_sysfs_set_filters(struct damon_probe *probe,
 		struct damon_sysfs_filters *sys_filters)
 {
@@ -2209,7 +2226,15 @@ static int damon_sysfs_set_probe(struct damon_probe *probe,
 		struct damon_sysfs_probe *sys_probe)
 {
 	struct damon_sysfs_filters *sys_filters;
+	struct damon_sysfs_preps *sys_preps;
+	int err;
 
+	sys_preps = sys_probe->preps;
+	if (sys_preps) {
+		err = damon_sysfs_set_preps(probe, sys_preps);
+		if (err)
+			return err;
+	}
 	sys_filters = sys_probe->filters;
 	if (!sys_filters)
 		return 0;
Signature · 1 line
2.47.3
author maintainer
#28 lore raw

RFC PATCH 14/17 selftests/damon/sysfs.sh: test probe prep sysfs files

In reply to SJ Park

Add basic file operations test for newly introduced DAMON probe prep sysfs directories and files.

---
 tools/testing/selftests/damon/sysfs.sh | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
tools/testing/selftests/damon/sysfs.sh +27 -0
index f7fb94b84e716..ddebde6edabe4 100755
@@ -361,6 +361,32 @@ test_intervals()
 	test_intervals_goal "$intervals_dir/intervals_goal"
 }
 
+test_damon_prep()
+{
+	damon_prep_dir=$1
+	ensure_file "$damon_prep_dir/prep_action" "exist" "600"
+	ensure_write_succ "$damon_prep_dir/prep_action" "set_pgidle" \
+		"valid input"
+	ensure_write_fail "$damon_prep_dir/prep_action" "foo" "invalid input"
+}
+
+test_damon_preps()
+{
+	preps_dir=$1
+	ensure_dir "$preps_dir" "exist"
+	ensure_file "$preps_dir/nr_preps" "exist" "600"
+	ensure_write_succ "$preps_dir/nr_preps" "1" "valid input"
+	test_damon_prep "$preps_dir/0"
+
+	ensure_write_succ  "$preps_dir/nr_preps" "2" "valid input"
+	test_damon_prep "$preps_dir/0"
+	test_damon_prep "$preps_dir/1"
+
+	ensure_write_succ "$preps_dir/nr_preps" "0" "valid input"
+	ensure_dir "$preps_dir/0" "not_exist"
+	ensure_dir "$preps_dir/1" "not_exist"
+}
+
 test_damon_filter()
 {
 	damon_filter_dir=$1
@@ -392,6 +418,7 @@ test_probe()
 {
 	probe_dir=$1
 	ensure_dir "$probe_dir" "exist"
+	test_damon_preps "$probe_dir/preps"
 	test_damon_filters "$probe_dir/filters"
 }
 
Signature · 1 line
2.47.3
author maintainer
#29 lore raw

RFC PATCH 15/17 Docs/mm/damon/design: document probe preps

In reply to SJ Park

Update DAMON design document for the newly added DAMN probe preps feature.

---
 Documentation/mm/damon/design.rst | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/mm/damon/design.rst +7 -0
index 12a2c3f81a262..5ce777c6b3f30 100644
@@ -311,6 +311,13 @@ Users can therefore know how much of a given DAMON region has a specific data
 attribute by reading the per-region per-probe probe hits counter after each
 aggregation interval.
 
+Users can optionally register probing preparation actions per probe.  If such
+actions are registered, DAMON applies the actions to each region's sampling
+memory before starting the next sampling interval.  Currently only one action,
+``set_pgidle`` is supported.  The action marks the page for the probing target
+memory as access-idle.  This can be useful to be used together with
+``pgidle_unset`` probe filter.
+
 This is a sampling based mechanism.  Hence, it is lightweight but the output
 may include some measurement errors.  The output should be used with good
 understanding of statistics.
Signature · 1 line
2.47.3
author maintainer
#32 lore raw

RFC PATCH 16/17 Docs/admin-guide/mm/damon/usage: document probe preps sysfs files

In reply to SJ Park

Update DAMON usage document for the newly added DAMON probe preps sysfs files.

---
 Documentation/admin-guide/mm/damon/usage.rst | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
Documentation/admin-guide/mm/damon/usage.rst +15 -3
index da5f9afd08aef..1f5a39e1fc38d 100644
@@ -74,6 +74,9 @@ comma (",").
     │ │ │ │ │ │ nr_regions/min,max
     │ │ │ │ │ │ :ref:`probes <damon_usage_sysfs_probes>`/nr_probes
     │ │ │ │ │ │ │ 0/weight
+    │ │ │ │ │ │ │ │ preps/nr_preps
+    │ │ │ │ │ │ │ │ │ 0/prep_action
+    │ │ │ │ │ │ │ │ │ ...
     │ │ │ │ │ │ │ │ filters/nr_filters
     │ │ │ │ │ │ │ │ │ 0/type,matching,allow,path
     │ │ │ │ │ │ │ │ │ ...
@@ -283,9 +286,18 @@ In the beginning, this directory has only one file, ``nr_probes``.  Writing a
 number (``N``) to the file creates the number of child directories named ``0``
 to ``N-1``.  Each directory represents each monitoring probe.
 
-In each probe directory, one directory, ``filters`` exists.  The directory
-contains files for installing filters for the probe, that is used to determine
-the data attribute for the probe.
+In each probe directory, two directories, ``preps`` and ``filters`` exists.
+The directories contains files for installing probing preparation actions and
+filters for the probe, that is used to determine the data attribute for the
+probe.
+
+In the beginning, ``preps`` directory has only one file, ``nr_preps``.
+Writiing a number (``N``) to the file creates the number of child directories
+names ``0`` to ``N-1``.  Each directory represents each preparation action.
+Each directory has one file, ``prep_action``.  The preparation action can be
+selected by writing the name of the action to the ``prep_action`` file.  Refer
+to the :ref:`design doc <damon_design_data_attrs_monitoring>` for the list of
+supported actions.
 
 Each probe directory also contains ``weight`` file.  Reading from and writing
 to the file gets and sets the :ref:`attributes-only monitoring
Signature · 1 line
2.47.3
author maintainer
#35 lore raw

RFC PATCH 17/17 Docs/ABI/damon: document probe prep sysfs files

In reply to SJ Park

Update DAMON ABI document for the newly added DAMON probe prep sysfs files.

---
 Documentation/ABI/testing/sysfs-kernel-mm-damon | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/ABI/testing/sysfs-kernel-mm-damon +13 -0
index e9488bb48d23c..786be4537da14 100644
@@ -173,6 +173,19 @@ Contact:	SJ Park <[email protected]>
 Description:	Writing to and reading from this file sets and gets the
 		per-probe attribute weight.
 
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/preps/nr_preps
+Date:		Jun 2026
+Contact:	SJ Park <[email protected]>
+Description:	Writing a number 'N' to this file creates the number of
+		directories for each DAMON probing preparation action named '0'
+		to 'N-1' under the preps/ directory.
+
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/prep/<R>/action
+Date:		Jun 2026
+Contact:	SJ Park <[email protected]>
+Description:	Writing to and reading from this file sets and gets the probing
+		preeparation action.
+
 What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/filters/nr_filters
 Date:		May 2026
 Contact:	SJ Park <[email protected]>
Signature · 1 line
2.47.3
#9 lore raw

Re: [RFC PATCH 04/17] Docs/mm/damon/design: document pgidle_unset probe filter type

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Typos and grammatically awkward phrasing in the newly added documentation. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Typos and grammatically awkward phrasing in the newly added documentation. --

--- Patch [4]: [RFC PATCH 04/17] Docs/mm/damon/design: document pgidle_unset probe filter type --- commit 616f638e60cd5170d7a26046797874f2e31071a4
Author: SJ Park <[email protected]>

Docs/mm/damon/design: document pgidle_unset probe filter type

This commit updates the DAMON design document to include the newly added pgidle_unset probe filter type. It also formats the supported filter types into a list for improved readability.

Documentation/mm/damon/design.rst registration is made by specifying a probe per attribute. Each of the probe · line 296

Quoted 11 lines
Documentation/mm/damon/design.rst +1 -2
index aed6cb1cf4831..d9f64e9ae2879 100644
@@ -293,8 +293,14 @@ registration is made by specifying a probe per attribute.  Each of the probe
 specifies a rule to determine if a given memory region has the related
 attribute.  The rule is constructed with multiple filters.  The filters work
 same to :ref:`DAMOS filters <damon_design_damos_filters>` except the supported
-filter types.  Currently only ``anon`` and ``memcg`` filter types are supported
-for data attributes monitoring.
+filter types.  Currently below fitler types are supported.

[Severity: Low]
This isn't a bug, but there is a typo here ("fitler" instead of "filter").

Documentation/mm/damon/design.rst registration is made by specifying a probe per attribute. Each of the probe · line 302

Quoted 6 lines
Documentation/mm/damon/design.rst +6 -0
+
+- ``anon``: Same to that for DAMOS filters.
+- ``memcg``: Same to that for DAMOS filters.
+- ``pgidle_unset``: Matches if the page for the memory is marked as not
+  access-idle.
+  Matches if the memory is not backed by pages that DAMON can idnetify

[Severity: Low]
This isn't a bug, but there is a typo here ("idnetify" instead of "identify"). Could this phrasing also be slightly adjusted for better flow? Something like "pages for which DAMON can identify idleness" might read more naturally.

Quoted 4 lines
Documentation/mm/damon/design.rst +1 -0
+  idleness.
 
 If such probes are registered, DAMON executes the probes for each region's
 sampling memory when it does the access :ref:`sampling
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#30 lore raw

Re: [RFC PATCH 15/17] Docs/mm/damon/design: document probe preps

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Typo in the commit message: 'DAMN' instead of 'DAMON'. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Typo in the commit message: 'DAMN' instead of 'DAMON'.
--

--- Patch [15]: [RFC PATCH 15/17] Docs/mm/damon/design: document probe preps --- commit 8a47d1109fc79c6ddb959763fb0ede38e076501a
Author: SJ Park <[email protected]>

Docs/mm/damon/design: document probe preps

This commit updates the DAMON design document to include information about the newly added probe preps feature.

Quoted 2 lines

Update DAMON design document for the newly added DAMN probe preps feature.

[Severity: Low]
This isn't a bug, but there is a typo in the commit message body ("DAMN" instead of "DAMON").

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=15
#33 lore raw

Re: [RFC PATCH 16/17] Docs/admin-guide/mm/damon/usage: document probe preps sysfs files

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Multiple typographical and grammatical errors in the newly added documentation. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Multiple typographical and grammatical errors in the newly added documentation. --

--- Patch [16]: [RFC PATCH 16/17] Docs/admin-guide/mm/damon/usage: document probe preps sysfs files --- commit b237c3e5209fc4981028c7362f98db1f8e443546
Author: SJ Park <[email protected]>

Docs/admin-guide/mm/damon/usage: document probe preps sysfs files

Update DAMON usage document for the newly added DAMON probe preps sysfs files.

Quoted 4 lines
Documentation/admin-guide/mm/damon/usage.rst +0 -0
index da5f9afd08aef..1f5a39e1fc38d 100644

[ ... ]

Documentation/admin-guide/mm/damon/usage.rst In the beginning, this directory has only one file, ``nr_probes``. Writing a · line 290

Quoted 9 lines
Documentation/admin-guide/mm/damon/usage.rst +2 -3
@@ -283,9 +286,18 @@ In the beginning, this directory has only one file, ``nr_probes``.  Writing a
 number (``N``) to the file creates the number of child directories named ``0``
 to ``N-1``.  Each directory represents each monitoring probe.
 
-In each probe directory, one directory, ``filters`` exists.  The directory
-contains files for installing filters for the probe, that is used to determine
-the data attribute for the probe.
+In each probe directory, two directories, ``preps`` and ``filters`` exists.
+The directories contains files for installing probing preparation actions and

[Severity: Low]
This isn't a bug, but there are grammatical errors here with "exists" and "contains".

Documentation/admin-guide/mm/damon/usage.rst In the beginning, this directory has only one file, ``nr_probes``. Writing a · line 296

Quoted 6 lines
Documentation/admin-guide/mm/damon/usage.rst +6 -0
+filters for the probe, that is used to determine the data attribute for the
+probe.
+
+In the beginning, ``preps`` directory has only one file, ``nr_preps``.
+Writiing a number (``N``) to the file creates the number of child directories
+names ``0`` to ``N-1``.  Each directory represents each preparation action.

[Severity: Low]
This isn't a bug, but there are typos here with "Writiing" and "names".

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=16
#24 lore raw

Re: [RFC PATCH 11/17] mm/damon/sysfs: implement probe prep directory

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The static constant `damon_sysfs_prep_ktype` is defined but not used anywhere in the file. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The static constant damon_sysfs_prep_ktype is defined but not used anywhere in the file. --

--- Patch [11]: [RFC PATCH 11/17] mm/damon/sysfs: implement probe prep directory --- commit a150eac865fe6562090f70dc8b3909c07dadeb09
Author: SJ Park <[email protected]>

mm/damon/sysfs: implement probe prep directory

Implement DAMON sysfs directory and files for specifying each probe prep action. Introduce only preparatory data structure and functions, without wiring them up yet.

Quoted 4 lines
mm/damon/sysfs.c +0 -0
index 38affef08d0fb..8f9a5df598c51 100644

[ ... ]

mm/damon/sysfs.c static const struct kobj_type damon_sysfs_intervals_ktype = { · line 834

Quoted 11 lines
mm/damon/sysfs.c +11 -0
+static struct attribute *damon_sysfs_prep_attrs[] = {
+	&damon_sysfs_prep_prep_action_attr.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(damon_sysfs_prep);
+
+static const struct kobj_type damon_sysfs_prep_ktype = {
+	.release = damon_sysfs_prep_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+	.default_groups = damon_sysfs_prep_groups,
+};

[Severity: Low]
Since this patch introduces preparatory data structures that are not yet wired up, the static constant damon_sysfs_prep_ktype is defined but not used anywhere in mm/damon/sysfs.c.

Could this trigger a -Wunused-const-variable warning when building the kernel with W=1?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
#2 lore raw

Re: [RFC PATCH 01/17] mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The commit introduces `DAMON_FILTER_TYPE_PGIDLE_UNSET` but entirely omits its implementation in…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit introduces DAMON_FILTER_TYPE_PGIDLE_UNSET but entirely omits its implementation in both the filter evaluation logic and the sysfs interface. --

--- Patch [1]: [RFC PATCH 01/17] mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET --- commit 227024f25ad71dec25a7b05a4270affaab5be023
Author: SJ Park <[email protected]>

mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET

Introduce a new DAMON filter type, pgidle_unset. It will match pages that have their PG_Idle flag unset, or the page table accessed bit set.

Quoted 4 lines
include/linux/damon.h +0 -0
index 0c8b7ddef9abb..a8bb9ee6979e3 100644

[ ... ]

Quoted 4 lines
include/linux/damon.h +0 -0
@@ -742,12 +742,14 @@ struct damon_intervals_goal {
 /**
  * enum damon_filter_type - Type of &struct damon_filter
  *

include/linux/damon.h struct damon_intervals_goal { · line 752

Quoted 10 lines
include/linux/damon.h +4 -2
- * @DAMON_FILTER_TYPE_ANON:	Anonymous pages.
- * @DAMON_FILTER_TYPE_MEMCG:	Specific memcg's pages.
+ * @DAMON_FILTER_TYPE_ANON:		Anonymous pages.
+ * @DAMON_FILTER_TYPE_MEMCG:		Specific memcg's pages.
+ * @DAMON_FILTER_TYPE_PGIDLE_UNSET:	Pgidle is unset.
  */
 enum damon_filter_type {
 	DAMON_FILTER_TYPE_ANON,
 	DAMON_FILTER_TYPE_MEMCG,
+	DAMON_FILTER_TYPE_PGIDLE_UNSET,

[Severity: Medium]
Is the implementation for this new filter type missing from the filter evaluation logic?

Looking at damon_pa_filter_match() in mm/damon/paddr.c, the switch statement evaluates filters but lacks a case to process the newly introduced type:

mm/damon/paddr.c:damon_pa_filter_match() {
        ...
        switch (filter->type) {
        case DAMON_FILTER_TYPE_ANON:
        ...
}

Will this cause the evaluation to fall through to a default case and behave incorrectly rather than matching the PG_Idle or accessed bit as intended?

Also, does this new type need to be mapped in the sysfs interface so userspace can configure it? The damon_sysfs_filter_type_names array in mm/damon/sysfs.c doesn't seem to include the new mapping:

mm/damon/sysfs.c: {
        ...
        static const struct damon_sysfs_filter_type_name
        damon_sysfs_filter_type_names[] = {
        ...
}
Quoted 3 lines
include/linux/damon.h +0 -0
 };
 
 /**
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#36 lore raw

Re: [RFC PATCH 17/17] Docs/ABI/damon: document probe prep sysfs files

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The documented sysfs ABI path and filename for DAMON probe preparation actions do not match the…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The documented sysfs ABI path and filename for DAMON probe preparation actions do not match the actual kernel implementation, and the description contains a typographical error. --

--- Patch [17]: [RFC PATCH 17/17] Docs/ABI/damon: document probe prep sysfs files --- commit cfe472afe661c1a2901b08aa9b4dfa86ac237ee5
Author: SJ Park <[email protected]>

Docs/ABI/damon: document probe prep sysfs files

This commit updates the DAMON ABI document for the newly added DAMON probe prep sysfs files.

Quoted 4 lines
Documentation/ABI/testing/sysfs-kernel-mm-damon +0 -0
index e675a57145e36..6d596fb7fa1ff 100644

[ ... ]

Documentation/ABI/testing/sysfs-kernel-mm-damon Contact: SJ Park <[email protected]> · line 187

Quoted 5 lines
Documentation/ABI/testing/sysfs-kernel-mm-damon +5 -0
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/prep/<R>/action
+Date:		Jun 2026
+Contact:	SJ Park <[email protected]>
+Description:	Writing to and reading from this file sets and gets the probing
+		preeparation action.

[Severity: Low]
Does this documented path match the actual sysfs implementation?

Looking at damon_sysfs_prep_prep_action_attr in mm/damon/sysfs.c, the attribute file appears to be created as prep_action instead of action, and it resides under the preps/ directory instead of prep/. Should the documented path be updated to preps/<R>/prep_action to align with the kernel code?

This isn't a bug, but there is a typo in the word preeparation.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17
#20 lore raw

Re: [RFC PATCH 09/17] mm/damon/sysfs: implement preps directory

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The `damon_sysfs_preps_ktype` static constant is defined but never referenced or attached to the…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The damon_sysfs_preps_ktype static constant is defined but never referenced or attached to the sysfs hierarchy, resulting in an unused variable. --

--- Patch [9]: [RFC PATCH 09/17] mm/damon/sysfs: implement preps directory --- commit b804c7747bd623e2ca58a340a5342097faad4841
Author: SJ Park <[email protected]>

mm/damon/sysfs: implement preps directory

This commit implements a sysfs directory and a file for setting DAMON probe preps. It implements only the preparatory data structures and functions without generating the directories at the moment.

Quoted 4 lines
mm/damon/sysfs.c +0 -0
index 50ff1c172d746..6910a0f31697a 100644

[ ... ]

mm/damon/sysfs.c static const struct kobj_type damon_sysfs_intervals_ktype = { · line 819

Quoted 11 lines
mm/damon/sysfs.c +11 -0
+static struct attribute *damon_sysfs_preps_attrs[] = {
+	&damon_sysfs_preps_nr_attr.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(damon_sysfs_preps);
+
+static const struct kobj_type damon_sysfs_preps_ktype = {
+	.release = damon_sysfs_preps_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+	.default_groups = damon_sysfs_preps_groups,
+};

[Severity: Low]
This isn't a bug, but since damon_sysfs_preps_ktype is defined here without being referenced or attached to the sysfs hierarchy, will this cause unused variable compiler warnings?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
#14 lore raw

Re: [RFC PATCH 07/17] mm/damon/core: introduce damon_operations->prep_probes()

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] prep_probes receives has_prep instead of access_check_disabled && has_prep, causing it to…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] prep_probes receives has_prep instead of access_check_disabled && has_prep, causing it to overwrite sampling_addr during normal access checking.
- [Medium] Uninitialized sampling_addr usage in apply_probes if prep_probes is not implemented.
--

--- Patch [7]: [RFC PATCH 07/17] mm/damon/core: introduce damon_operations->prep_probes() --- commit 62e96fea7e813101fb4353abda03a93a90ef358a
Author: SJ Park <[email protected]>

mm/damon/core: introduce damon_operations->prep_probes()

damon_prep needs to be executed by the underlying DAMON operation set. Extend the operation set callback list for the execution of damon_prep actions. If the underlying operation set implements the callback, DAMON core executes it in the monitoring preparation time.

Quoted 4 lines
mm/damon/core.c +0 -0
index 127d3a7c27280..d5b1e0b5851a1 100644

[ ... ]

mm/damon/core.c static int kdamond_fn(void *data) · line 3895

Quoted 6 lines
mm/damon/core.c +2 -0
@@ -3878,6 +3891,8 @@ static int kdamond_fn(void *data)
 
 		if (!access_check_disabled && ctx->ops.prepare_access_checks)
 			ctx->ops.prepare_access_checks(ctx);
+		if (ctx->ops.prep_probes)
+			ctx->ops.prep_probes(ctx, has_prep);

[Severity: Medium]
Could this overwrite the tracked sampling_addr during normal access checking?

If a configuration has a prep without probe weights, access_check_disabled is false and has_prep is true. prepare_access_checks() sets sampling_addr and marks it for tracking.

If prep_probes() is implemented by a backend, passing has_prep (true) here instead of access_check_disabled && has_prep would cause it to generate a new, unprepared sampling_addr that silently overwrites the tracked one.

mm/damon/core.c static int kdamond_fn(void *data) · line 3911

Quoted 10 lines
mm/damon/core.c +2 -1
 		kdamond_usleep(sample_interval);
 		ctx->passed_sample_intervals++;
@@ -3892,7 +3907,8 @@ static int kdamond_fn(void *data)
 			else
 				get_max_wsum = false;
 			max_wsum = ctx->ops.apply_probes(ctx,
-					access_check_disabled, get_max_wsum);
+					access_check_disabled && !has_prep,
+					get_max_wsum);

[Severity: Medium]
Does this result in uninitialized sampling_addr usage in apply_probes() if the backend doesn't implement prep_probes?

If a probe has a weight and a prep, both access_check_disabled and has_prep evaluate to true, which skips prepare_access_checks().

If the current operations do not implement prep_probes (ctx->ops.prep_probes == NULL), that callback is also skipped.

When apply_probes() is called, set_samples evaluates to false (because access_check_disabled && !has_prep is false). As a result, no function initializes r->sampling_addr, and the uninitialized memory could be read by apply_probes().

Quoted 3 lines
mm/damon/core.c +0 -0
 			if (get_max_wsum)
 				max_merge_score = max_wsum;
 		}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
#17 lore raw

Re: [RFC PATCH 08/17] mm/damon/paddr: support damon_prep

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Double randomization of `r->sampling_addr` silently overwrites the prepared address when access…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Double randomization of r->sampling_addr silently overwrites the prepared address when access checks are enabled, leading to an orphaned prepared page and evaluation of an unprepared page.
- [Medium] Redundant application of DAMON_PREP_SET_PGIDLE causes duplicate expensive rmap walks for the same folio when multiple probes exist.
--

--- Patch [8]: [RFC PATCH 08/17] mm/damon/paddr: support damon_prep --- commit 4bd5ea4d30cf668863712fb6c9fd487551e2b59c
Author: SJ Park <[email protected]>

mm/damon/paddr: support damon_prep

This commit implements the prep_probes() callback for physical address operations. It supports the DAMON_PREP_SET_PGIDLE action by unsetting page table accessed bits and setting the PG_Idle flag.

Quoted 4 lines
mm/damon/paddr.c +0 -0
index 199de1463fa06..8d8fcd1369e56 100644

[ ... ]

mm/damon/paddr.c static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) · line 118

Quoted 11 lines
mm/damon/paddr.c +11 -0
+static void damon_pa_prep_probes_region(struct damon_region *r,
+		struct damon_probe *probe, struct damon_ctx *ctx)
+{
+	struct damon_prep *p;
+
+	damon_for_each_prep(p, probe) {
+		switch (p->action) {
+		case DAMON_PREP_SET_PGIDLE:
+			damon_pa_mkold(damon_pa_phys_addr(r->sampling_addr,
+						ctx->addr_unit));
+			break;

[Severity: Medium]
Will this result in redundant expensive rmap walks if multiple probes share the same prep action?

When iterating over all probes in damon_pa_prep_probes(), this is called for each probe. If a user configures multiple probes with the pgidle_unset filter in a single context, it looks like damon_pa_mkold() will be invoked multiple times for the same sampling_addr, causing duplicate folio rmap traversals.

Quoted 7 lines
mm/damon/paddr.c +7 -0
+		default:
+			break;
+		}
+	}
+}
+
+static void damon_pa_prep_probes(struct damon_ctx *ctx, bool set_samples)

mm/damon/paddr.c static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) · line 135

Quoted 10 lines
mm/damon/paddr.c +10 -0
+{
+	struct damon_target *t;
+	struct damon_region *r;
+	struct damon_probe *p;
+
+	damon_for_each_target(t, ctx) {
+		damon_for_each_region(r, t) {
+			if (set_samples)
+				r->sampling_addr = damon_rand(ctx, r->ar.start,
+						r->ar.end);

[Severity: High]
Does this conditionally overwrite the sampling address that was already set and prepared?

In mm/damon/core.c:kdamond_fn(), prepare_access_checks() and prep_probes() can both be called in sequence:

    if (!access_check_disabled && ctx->ops.prepare_access_checks)
        ctx->ops.prepare_access_checks(ctx);
    if (ctx->ops.prep_probes)
        ctx->ops.prep_probes(ctx, has_prep);

If a user configures a probe with weight=0 and a prep action, access_check_disabled is false and has_prep is true. Since has_prep is passed as set_samples, damon_pa_prep_probes() will overwrite the r->sampling_addr that was just prepared by prepare_access_checks(). This would leave the originally prepared page orphaned and cause an unprepared page to be evaluated.

Quoted 5 lines
mm/damon/paddr.c +5 -0
+			damon_for_each_probe(p, ctx)
+				damon_pa_prep_probes_region(r, p, ctx);
+		}
+	}
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
#5 lore raw

Re: [RFC PATCH 02/17] mm/damon/paddr: support PGIDLE_UNSET probe filter type

In reply to SJ Park
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] The PGIDLE_UNSET probe filter lacks a mechanism to clear the page idle state and PTE young bits at the start of the sampling interval when used with weights, breaking access monitoring.

Pre-existing issues:
- [High] PFN advancement after page-to-folio conversion using folio_size() causes subsequent folios to be skipped if the iteration does not start at the folio's base address. --

--- Patch [2]: [RFC PATCH 02/17] mm/damon/paddr: support PGIDLE_UNSET probe filter type --- commit 97a45c1fa60aa6c710c0c0c9226adf390fa8207f
Author: SJ Park <[email protected]>

mm/damon/paddr: support PGIDLE_UNSET probe filter type

Implement support of DAMON_FILTER_TYPE_PGIDLE_UNSET in the physical address space DAMON operations set. It reuses damon_folio_young(), which was being used for access monitoring.

mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 139

Quoted 13 lines
mm/damon/paddr.c +5 -0
index 5a6a78054784a..199de1463fa06 100644
@@ -132,6 +132,12 @@ static bool damon_pa_filter_match(struct damon_filter *filter,
 			matched = filter->memcg_id == mem_cgroup_id(memcg);
 		rcu_read_unlock();
 		break;
+	case DAMON_FILTER_TYPE_PGIDLE_UNSET:
+		if (!folio)
+			matched = false;
+		else
+			matched = damon_folio_young(folio);

[Severity: High]
Does this filter evaluate historical access state instead of interval-specific accesses when used with weights?

If a DAMON probe is configured with weights, it skips the prepare_access_checks() phase:

mm/damon/core.c:kdamond_fn() {
    ...
    bool access_check_disabled = damon_has_probe_weights(ctx);
    ...
    if (!access_check_disabled && ctx->ops.prepare_access_checks)
        ctx->ops.prepare_access_checks(ctx);
    ...
}

Because damon_pa_mkold() is never called on this address at the beginning of the interval, it seems damon_folio_young() will read stale access state and perpetually match once a page is accessed.

mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 143

Quoted 4 lines
mm/damon/paddr.c +1 -0
+		break;
 	default:
 		break;
 	}

[Severity: High]
This isn't a bug introduced by this patch, but does the address advancement in damon_pa_pageout() skip valid physical memory if the DAMON region boundary is not aligned to a large folio boundary?

mm/damon/paddr.c:damon_pa_pageout() {
    ...
    folio = damon_get_folio(...);
    ...
    addr += folio_size(folio);
    ...
}

When damon_get_folio() returns a large folio, unconditionally adding the full folio_size(folio) to an unaligned addr over-advances the address by addr % folio_size(folio). This could cause the loop to skip the beginning of the next folio.

The same unaligned address advancement also appears in damon_pa_de_activate(), damon_pa_migrate(), and damon_pa_stat().

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#3 lore raw

Re: [RFC PATCH 01/17] mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET

In reply to [email protected]
Quoted 55 lines · On Sat, 25 Jul 2026 21:11:56 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit introduces DAMON_FILTER_TYPE_PGIDLE_UNSET but entirely omits its implementation in both the filter evaluation logic and the sysfs interface. --

--- Patch [1]: [RFC PATCH 01/17] mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET --- commit 227024f25ad71dec25a7b05a4270affaab5be023
Author: SJ Park <[email protected]>

mm/damon/core: introduce DAMON_FILTER_TYPE_PGIDLE_UNSET

Introduce a new DAMON filter type, pgidle_unset. It will match pages that have their PG_Idle flag unset, or the page table accessed bit set.

Quoted 4 lines
include/linux/damon.h +0 -0
index 0c8b7ddef9abb..a8bb9ee6979e3 100644

[ ... ]

Quoted 4 lines
include/linux/damon.h +0 -0
@@ -742,12 +742,14 @@ struct damon_intervals_goal {
 /**
  * enum damon_filter_type - Type of &struct damon_filter
  *

include/linux/damon.h struct damon_intervals_goal { · line 752

Quoted 10 lines
include/linux/damon.h +4 -2
- * @DAMON_FILTER_TYPE_ANON:	Anonymous pages.
- * @DAMON_FILTER_TYPE_MEMCG:	Specific memcg's pages.
+ * @DAMON_FILTER_TYPE_ANON:		Anonymous pages.
+ * @DAMON_FILTER_TYPE_MEMCG:		Specific memcg's pages.
+ * @DAMON_FILTER_TYPE_PGIDLE_UNSET:	Pgidle is unset.
  */
 enum damon_filter_type {
 	DAMON_FILTER_TYPE_ANON,
 	DAMON_FILTER_TYPE_MEMCG,
+	DAMON_FILTER_TYPE_PGIDLE_UNSET,

[Severity: Medium]
Is the implementation for this new filter type missing from the filter evaluation logic?

Looking at damon_pa_filter_match() in mm/damon/paddr.c, the switch statement evaluates filters but lacks a case to process the newly introduced type:

mm/damon/paddr.c:damon_pa_filter_match() {
        ...
        switch (filter->type) {
        case DAMON_FILTER_TYPE_ANON:
        ...
}

Will this cause the evaluation to fall through to a default case and behave incorrectly rather than matching the PG_Idle or accessed bit as intended?

Also, does this new type need to be mapped in the sysfs interface so userspace can configure it? The damon_sysfs_filter_type_names array in mm/damon/sysfs.c doesn't seem to include the new mapping:

Quoted 6 lines
mm/damon/sysfs.c: {
        ...
        static const struct damon_sysfs_filter_type_name
        damon_sysfs_filter_type_names[] = {
        ...
}

That will be introduced in a later patch of this series.

Quoted 7 lines
Quoted 4 lines
include/linux/damon.h +0 -0
 };
 
 /**
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1

Thanks,
SJ

author maintainer
#6 lore raw

Re: [RFC PATCH 02/17] mm/damon/paddr: support PGIDLE_UNSET probe filter type

In reply to [email protected]
Quoted 49 lines · On Sat, 25 Jul 2026 21:17:05 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [High] The PGIDLE_UNSET probe filter lacks a mechanism to clear the page idle state and PTE young bits at the start of the sampling interval when used with weights, breaking access monitoring.

Pre-existing issues:
- [High] PFN advancement after page-to-folio conversion using folio_size() causes subsequent folios to be skipped if the iteration does not start at the folio's base address. --

--- Patch [2]: [RFC PATCH 02/17] mm/damon/paddr: support PGIDLE_UNSET probe filter type --- commit 97a45c1fa60aa6c710c0c0c9226adf390fa8207f
Author: SJ Park <[email protected]>

mm/damon/paddr: support PGIDLE_UNSET probe filter type

Implement support of DAMON_FILTER_TYPE_PGIDLE_UNSET in the physical address space DAMON operations set. It reuses damon_folio_young(), which was being used for access monitoring.

mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 139

Quoted 13 lines
mm/damon/paddr.c +5 -0
index 5a6a78054784a..199de1463fa06 100644
@@ -132,6 +132,12 @@ static bool damon_pa_filter_match(struct damon_filter *filter,
 			matched = filter->memcg_id == mem_cgroup_id(memcg);
 		rcu_read_unlock();
 		break;
+	case DAMON_FILTER_TYPE_PGIDLE_UNSET:
+		if (!folio)
+			matched = false;
+		else
+			matched = damon_folio_young(folio);

[Severity: High]
Does this filter evaluate historical access state instead of interval-specific accesses when used with weights?

If a DAMON probe is configured with weights, it skips the prepare_access_checks() phase:

mm/damon/core.c:kdamond_fn() {
    ...
    bool access_check_disabled = damon_has_probe_weights(ctx);
    ...
    if (!access_check_disabled && ctx->ops.prepare_access_checks)
        ctx->ops.prepare_access_checks(ctx);
    ...
}
Quoted 3 lines

Because damon_pa_mkold() is never called on this address at the beginning of the interval, it seems damon_folio_young() will read stale access state and perpetually match once a page is accessed.

That will be implemented in a later patch of this series.

Quoted 19 lines

mm/damon/paddr.c static bool damon_pa_filter_match(struct damon_filter *filter, · line 143

Quoted 5 lines
mm/damon/paddr.c +1 -0
+		break;
 	default:
 		break;
 	}

[Severity: High]
This isn't a bug introduced by this patch, but does the address advancement in damon_pa_pageout() skip valid physical memory if the DAMON region boundary is not aligned to a large folio boundary?

mm/damon/paddr.c:damon_pa_pageout() {
    ...
    folio = damon_get_folio(...);
    ...
    addr += folio_size(folio);
    ...
}
Quoted 7 lines

When damon_get_folio() returns a large folio, unconditionally adding the full folio_size(folio) to an unaligned addr over-advances the address by addr % folio_size(folio). This could cause the loop to skip the beginning of the next folio.

The same unaligned address advancement also appears in damon_pa_de_activate(), damon_pa_migrate(), and damon_pa_stat().

Known issue, I'm working on it.

Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2

Thanks,
SJ

author maintainer
#10 lore raw

Re: [RFC PATCH 04/17] Docs/mm/damon/design: document pgidle_unset probe filter type

In reply to [email protected]
Quoted 14 lines · On Sat, 25 Jul 2026 21:05:25 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Typos and grammatically awkward phrasing in the newly added documentation. --

--- Patch [4]: [RFC PATCH 04/17] Docs/mm/damon/design: document pgidle_unset probe filter type --- commit 616f638e60cd5170d7a26046797874f2e31071a4
Author: SJ Park <[email protected]>

Docs/mm/damon/design: document pgidle_unset probe filter type

This commit updates the DAMON design document to include the newly added pgidle_unset probe filter type. It also formats the supported filter types into a list for improved readability.

Quoted 14 lines

Documentation/mm/damon/design.rst registration is made by specifying a probe per attribute. Each of the probe · line 296

Quoted 11 lines
Documentation/mm/damon/design.rst +1 -2
index aed6cb1cf4831..d9f64e9ae2879 100644
@@ -293,8 +293,14 @@ registration is made by specifying a probe per attribute.  Each of the probe
 specifies a rule to determine if a given memory region has the related
 attribute.  The rule is constructed with multiple filters.  The filters work
 same to :ref:`DAMOS filters <damon_design_damos_filters>` except the supported
-filter types.  Currently only ``anon`` and ``memcg`` filter types are supported
-for data attributes monitoring.
+filter types.  Currently below fitler types are supported.

[Severity: Low]
This isn't a bug, but there is a typo here ("fitler" instead of "filter").

Nice catch, I will fix this in the next revision.

Quoted 8 lines

Documentation/mm/damon/design.rst registration is made by specifying a probe per attribute. Each of the probe · line 302

Quoted 7 lines
Documentation/mm/damon/design.rst +6 -0
+
+- ``anon``: Same to that for DAMOS filters.
+- ``memcg``: Same to that for DAMOS filters.
+- ``pgidle_unset``: Matches if the page for the memory is marked as not
+  access-idle.
+  Matches if the memory is not backed by pages that DAMON can idnetify
Quoted 4 lines

[Severity: Low]
This isn't a bug, but there is a typo here ("idnetify" instead of "identify"). Could this phrasing also be slightly adjusted for better flow? Something like "pages for which DAMON can identify idleness" might read more naturally.

The last sentence is wrongly added. Will remove from the next revision.

Quoted 8 lines
Quoted 5 lines
Documentation/mm/damon/design.rst +1 -0
+  idleness.
 
 If such probes are registered, DAMON executes the probes for each region's
 sampling memory when it does the access :ref:`sampling
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4

Thanks,
SJ

author maintainer
#15 lore raw

Re: [RFC PATCH 07/17] mm/damon/core: introduce damon_operations->prep_probes()

In reply to [email protected]
Quoted 33 lines · On Sat, 25 Jul 2026 21:14:14 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] prep_probes receives has_prep instead of access_check_disabled && has_prep, causing it to overwrite sampling_addr during normal access checking.
- [Medium] Uninitialized sampling_addr usage in apply_probes if prep_probes is not implemented.
--

--- Patch [7]: [RFC PATCH 07/17] mm/damon/core: introduce damon_operations->prep_probes() --- commit 62e96fea7e813101fb4353abda03a93a90ef358a
Author: SJ Park <[email protected]>

mm/damon/core: introduce damon_operations->prep_probes()

damon_prep needs to be executed by the underlying DAMON operation set. Extend the operation set callback list for the execution of damon_prep actions. If the underlying operation set implements the callback, DAMON core executes it in the monitoring preparation time.

Quoted 4 lines
mm/damon/core.c +0 -0
index 127d3a7c27280..d5b1e0b5851a1 100644

[ ... ]

mm/damon/core.c static int kdamond_fn(void *data) · line 3895

Quoted 6 lines
mm/damon/core.c +2 -0
@@ -3878,6 +3891,8 @@ static int kdamond_fn(void *data)
 
 		if (!access_check_disabled && ctx->ops.prepare_access_checks)
 			ctx->ops.prepare_access_checks(ctx);
+		if (ctx->ops.prep_probes)
+			ctx->ops.prep_probes(ctx, has_prep);

[Severity: Medium]
Could this overwrite the tracked sampling_addr during normal access checking?

Quoted 7 lines

If a configuration has a prep without probe weights, access_check_disabled is false and has_prep is true. prepare_access_checks() sets sampling_addr and marks it for tracking.

If prep_probes() is implemented by a backend, passing has_prep (true) here instead of access_check_disabled && has_prep would cause it to generate a new, unprepared sampling_addr that silently overwrites the tracked one.

Good check.

Quoted 19 lines

mm/damon/core.c static int kdamond_fn(void *data) · line 3911

Quoted 11 lines
mm/damon/core.c +2 -1
 		kdamond_usleep(sample_interval);
 		ctx->passed_sample_intervals++;
@@ -3892,7 +3907,8 @@ static int kdamond_fn(void *data)
 			else
 				get_max_wsum = false;
 			max_wsum = ctx->ops.apply_probes(ctx,
-					access_check_disabled, get_max_wsum);
+					access_check_disabled && !has_prep,
+					get_max_wsum);

[Severity: Medium]
Does this result in uninitialized sampling_addr usage in apply_probes() if the backend doesn't implement prep_probes?

If a probe has a weight and a prep, both access_check_disabled and has_prep evaluate to true, which skips prepare_access_checks().

Quoted 7 lines

If the current operations do not implement prep_probes (ctx->ops.prep_probes == NULL), that callback is also skipped.

When apply_probes() is called, set_samples evaluates to false (because access_check_disabled && !has_prep is false). As a result, no function initializes r->sampling_addr, and the uninitialized memory could be read by apply_probes().

Again, good finding.

I will fix above two like below.

'''

mm/damon/core.c +4 -4
@@ -4251,7 +4251,7 @@ static int kdamond_fn(void *data)
                unsigned long next_ops_update_sis = ctx->next_ops_update_sis;
                unsigned long sample_interval = ctx->attrs.sample_interval;
                bool access_check_disabled = damon_has_probe_weights(ctx);
-               bool has_prep = damon_has_prep(ctx);
+               bool do_prep = damon_has_prep(ctx) && ctx->ops.prep_probes;
                unsigned int max_merge_score = 0, max_wsum;
                bool get_max_wsum;
 
@@ -4260,8 +4260,8 @@ static int kdamond_fn(void *data)
 
                if (!access_check_disabled && ctx->ops.prepare_access_checks)
                        ctx->ops.prepare_access_checks(ctx);
-               if (ctx->ops.prep_probes)
-                       ctx->ops.prep_probes(ctx, has_prep);
+               if (do_prep)
+                       ctx->ops.prep_probes(ctx, access_check_disabled);
 
                kdamond_usleep(sample_interval);
                ctx->passed_sample_intervals++;
@@ -4283,7 +4283,7 @@ static int kdamond_fn(void *data)
                        else
                                get_max_wsum = false;
                        max_wsum = ctx->ops.apply_probes(ctx,
-                                       access_check_disabled && !has_prep,
+                                       access_check_disabled && !do_prep,
                                        get_max_wsum);
                        if (get_max_wsum)
                                max_merge_score = max_wsum;

'''

Quoted 7 lines
Quoted 4 lines
mm/damon/core.c +0 -0
 			if (get_max_wsum)
 				max_merge_score = max_wsum;
 		}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7

Thanks,
SJ

author maintainer
#18 lore raw

Re: [RFC PATCH 08/17] mm/damon/paddr: support damon_prep

In reply to [email protected]
Quoted 38 lines · On Sat, 25 Jul 2026 21:15:30 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Double randomization of r->sampling_addr silently overwrites the prepared address when access checks are enabled, leading to an orphaned prepared page and evaluation of an unprepared page.
- [Medium] Redundant application of DAMON_PREP_SET_PGIDLE causes duplicate expensive rmap walks for the same folio when multiple probes exist.
--

--- Patch [8]: [RFC PATCH 08/17] mm/damon/paddr: support damon_prep --- commit 4bd5ea4d30cf668863712fb6c9fd487551e2b59c
Author: SJ Park <[email protected]>

mm/damon/paddr: support damon_prep

This commit implements the prep_probes() callback for physical address operations. It supports the DAMON_PREP_SET_PGIDLE action by unsetting page table accessed bits and setting the PG_Idle flag.

Quoted 4 lines
mm/damon/paddr.c +0 -0
index 199de1463fa06..8d8fcd1369e56 100644

[ ... ]

mm/damon/paddr.c static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) · line 118

Quoted 11 lines
mm/damon/paddr.c +11 -0
+static void damon_pa_prep_probes_region(struct damon_region *r,
+		struct damon_probe *probe, struct damon_ctx *ctx)
+{
+	struct damon_prep *p;
+
+	damon_for_each_prep(p, probe) {
+		switch (p->action) {
+		case DAMON_PREP_SET_PGIDLE:
+			damon_pa_mkold(damon_pa_phys_addr(r->sampling_addr,
+						ctx->addr_unit));
+			break;

[Severity: Medium]
Will this result in redundant expensive rmap walks if multiple probes share the same prep action?

Quoted 5 lines

When iterating over all probes in damon_pa_prep_probes(), this is called for each probe. If a user configures multiple probes with the pgidle_unset filter in a single context, it looks like damon_pa_mkold() will be invoked multiple times for the same sampling_addr, causing duplicate folio rmap traversals.

Yes. But wise users wouldn't set preps in such ways. No issue.

Quoted 31 lines
Quoted 8 lines
mm/damon/paddr.c +7 -0
+		default:
+			break;
+		}
+	}
+}
+
+static void damon_pa_prep_probes(struct damon_ctx *ctx, bool set_samples)

mm/damon/paddr.c static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx) · line 135

Quoted 10 lines
mm/damon/paddr.c +10 -0
+{
+	struct damon_target *t;
+	struct damon_region *r;
+	struct damon_probe *p;
+
+	damon_for_each_target(t, ctx) {
+		damon_for_each_region(r, t) {
+			if (set_samples)
+				r->sampling_addr = damon_rand(ctx, r->ar.start,
+						r->ar.end);

[Severity: High]
Does this conditionally overwrite the sampling address that was already set and prepared?

In mm/damon/core.c:kdamond_fn(), prepare_access_checks() and prep_probes() can both be called in sequence:

    if (!access_check_disabled && ctx->ops.prepare_access_checks)
        ctx->ops.prepare_access_checks(ctx);
    if (ctx->ops.prep_probes)
        ctx->ops.prep_probes(ctx, has_prep);
Quoted 6 lines

If a user configures a probe with weight=0 and a prep action, access_check_disabled is false and has_prep is true. Since has_prep is passed as set_samples, damon_pa_prep_probes() will overwrite the r->sampling_addr that was just prepared by prepare_access_checks(). This would leave the originally prepared page orphaned and cause an unprepared page to be evaluated.

I told I will fix patch 7.

Quoted 9 lines
Quoted 6 lines
mm/damon/paddr.c +5 -0
+			damon_for_each_probe(p, ctx)
+				damon_pa_prep_probes_region(r, p, ctx);
+		}
+	}
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8

Thanks,
SJ

author maintainer
#21 lore raw

Re: [RFC PATCH 09/17] mm/damon/sysfs: implement preps directory

In reply to [email protected]
Quoted 21 lines · On Sat, 25 Jul 2026 21:13:38 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The damon_sysfs_preps_ktype static constant is defined but never referenced or attached to the sysfs hierarchy, resulting in an unused variable. --

--- Patch [9]: [RFC PATCH 09/17] mm/damon/sysfs: implement preps directory --- commit b804c7747bd623e2ca58a340a5342097faad4841
Author: SJ Park <[email protected]>

mm/damon/sysfs: implement preps directory

This commit implements a sysfs directory and a file for setting DAMON probe preps. It implements only the preparatory data structures and functions without generating the directories at the moment.

Quoted 4 lines
mm/damon/sysfs.c +0 -0
index 50ff1c172d746..6910a0f31697a 100644

[ ... ]

Quoted 16 lines

mm/damon/sysfs.c static const struct kobj_type damon_sysfs_intervals_ktype = { · line 819

Quoted 11 lines
mm/damon/sysfs.c +11 -0
+static struct attribute *damon_sysfs_preps_attrs[] = {
+	&damon_sysfs_preps_nr_attr.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(damon_sysfs_preps);
+
+static const struct kobj_type damon_sysfs_preps_ktype = {
+	.release = damon_sysfs_preps_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+	.default_groups = damon_sysfs_preps_groups,
+};

[Severity: Low]
This isn't a bug, but since damon_sysfs_preps_ktype is defined here without being referenced or attached to the sysfs hierarchy, will this cause unused variable compiler warnings?

Good catch. W=1 build shows the warning. I will fix this in the next version.

Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9

Thanks,
SJ

author maintainer
#25 lore raw

Re: [RFC PATCH 11/17] mm/damon/sysfs: implement probe prep directory

In reply to [email protected]
Quoted 38 lines · On Sat, 25 Jul 2026 21:10:40 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The static constant damon_sysfs_prep_ktype is defined but not used anywhere in the file. --

--- Patch [11]: [RFC PATCH 11/17] mm/damon/sysfs: implement probe prep directory --- commit a150eac865fe6562090f70dc8b3909c07dadeb09
Author: SJ Park <[email protected]>

mm/damon/sysfs: implement probe prep directory

Implement DAMON sysfs directory and files for specifying each probe prep action. Introduce only preparatory data structure and functions, without wiring them up yet.

Quoted 4 lines
mm/damon/sysfs.c +0 -0
index 38affef08d0fb..8f9a5df598c51 100644

[ ... ]

mm/damon/sysfs.c static const struct kobj_type damon_sysfs_intervals_ktype = { · line 834

Quoted 11 lines
mm/damon/sysfs.c +11 -0
+static struct attribute *damon_sysfs_prep_attrs[] = {
+	&damon_sysfs_prep_prep_action_attr.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(damon_sysfs_prep);
+
+static const struct kobj_type damon_sysfs_prep_ktype = {
+	.release = damon_sysfs_prep_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+	.default_groups = damon_sysfs_prep_groups,
+};

[Severity: Low]
Since this patch introduces preparatory data structures that are not yet wired up, the static constant damon_sysfs_prep_ktype is defined but not used anywhere in mm/damon/sysfs.c.

Quoted 2 lines

Could this trigger a -Wunused-const-variable warning when building the kernel with W=1?

Good catch. I will fix in the next revision.

Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11

Thanks,
SJ

author maintainer
#31 lore raw

Re: [RFC PATCH 15/17] Docs/mm/damon/design: document probe preps

In reply to [email protected]
Quoted 13 lines · On Sat, 25 Jul 2026 21:06:56 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Typo in the commit message: 'DAMN' instead of 'DAMON'.
--

--- Patch [15]: [RFC PATCH 15/17] Docs/mm/damon/design: document probe preps --- commit 8a47d1109fc79c6ddb959763fb0ede38e076501a
Author: SJ Park <[email protected]>

Docs/mm/damon/design: document probe preps

This commit updates the DAMON design document to include information about the newly added probe preps feature.

Quoted 6 lines
Quoted 2 lines

Update DAMON design document for the newly added DAMN probe preps feature.

[Severity: Low]
This isn't a bug, but there is a typo in the commit message body ("DAMN" instead of "DAMON").

Good catch, I will fix.

Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=15

Thanks,
SJ

author maintainer
#34 lore raw

Re: [RFC PATCH 16/17] Docs/admin-guide/mm/damon/usage: document probe preps sysfs files

In reply to [email protected]
Quoted 24 lines · On Sat, 25 Jul 2026 21:08:13 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Multiple typographical and grammatical errors in the newly added documentation. --

--- Patch [16]: [RFC PATCH 16/17] Docs/admin-guide/mm/damon/usage: document probe preps sysfs files --- commit b237c3e5209fc4981028c7362f98db1f8e443546
Author: SJ Park <[email protected]>

Docs/admin-guide/mm/damon/usage: document probe preps sysfs files

Update DAMON usage document for the newly added DAMON probe preps sysfs files.

Quoted 4 lines
Documentation/admin-guide/mm/damon/usage.rst +0 -0
index da5f9afd08aef..1f5a39e1fc38d 100644

[ ... ]

Quoted 4 lines
Documentation/admin-guide/mm/damon/usage.rst +0 -0
@@ -283,9 +286,18 @@ In the beginning, this directory has only one file, ``nr_probes``.  Writing a
 number (``N``) to the file creates the number of child directories named ``0``
 to ``N-1``.  Each directory represents each monitoring probe.
 
Quoted 9 lines

Documentation/admin-guide/mm/damon/usage.rst In the beginning, this directory has only one file, ``nr_probes``. Writing a · line 290

Quoted 5 lines
Documentation/admin-guide/mm/damon/usage.rst +2 -3
-In each probe directory, one directory, ``filters`` exists.  The directory
-contains files for installing filters for the probe, that is used to determine
-the data attribute for the probe.
+In each probe directory, two directories, ``preps`` and ``filters`` exists.
+The directories contains files for installing probing preparation actions and

[Severity: Low]
This isn't a bug, but there are grammatical errors here with "exists" and "contains".

I will rephrase.

Quoted 10 lines

Documentation/admin-guide/mm/damon/usage.rst In the beginning, this directory has only one file, ``nr_probes``. Writing a · line 296

Quoted 7 lines
Documentation/admin-guide/mm/damon/usage.rst +6 -0
+filters for the probe, that is used to determine the data attribute for the
+probe.
+
+In the beginning, ``preps`` directory has only one file, ``nr_preps``.
+Writiing a number (``N``) to the file creates the number of child directories
+names ``0`` to ``N-1``.  Each directory represents each preparation action.

[Severity: Low]
This isn't a bug, but there are typos here with "Writiing" and "names".

Good catch, I will fix.

Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=16

Thanks,
SJ

author maintainer
#37 lore raw

Re: [RFC PATCH 17/17] Docs/ABI/damon: document probe prep sysfs files

In reply to [email protected]
Quoted 27 lines · On Sat, 25 Jul 2026 21:12:47 +0000 [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The documented sysfs ABI path and filename for DAMON probe preparation actions do not match the actual kernel implementation, and the description contains a typographical error. --

--- Patch [17]: [RFC PATCH 17/17] Docs/ABI/damon: document probe prep sysfs files --- commit cfe472afe661c1a2901b08aa9b4dfa86ac237ee5
Author: SJ Park <[email protected]>

Docs/ABI/damon: document probe prep sysfs files

This commit updates the DAMON ABI document for the newly added DAMON probe prep sysfs files.

Quoted 4 lines
Documentation/ABI/testing/sysfs-kernel-mm-damon +0 -0
index e675a57145e36..6d596fb7fa1ff 100644

[ ... ]

Documentation/ABI/testing/sysfs-kernel-mm-damon Contact: SJ Park <[email protected]> · line 187

Quoted 5 lines
Documentation/ABI/testing/sysfs-kernel-mm-damon +5 -0
+What:		/sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/probes/<P>/prep/<R>/action
+Date:		Jun 2026
+Contact:	SJ Park <[email protected]>
+Description:	Writing to and reading from this file sets and gets the probing
+		preeparation action.

[Severity: Low]
Does this documented path match the actual sysfs implementation?

Quoted 6 lines

Looking at damon_sysfs_prep_prep_action_attr in mm/damon/sysfs.c, the attribute file appears to be created as prep_action instead of action, and it resides under the preps/ directory instead of prep/. Should the documented path be updated to preps/<R>/prep_action to align with the kernel code?

This isn't a bug, but there is a typo in the word preeparation.

Nice catches. I will fix.

Quoted 3 lines
Signature · 2 lines
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17

Thanks,
SJ