Skip to contentSkip to conversation

mm/damon: misc cleanups

PATCH Applied SeongJae Park 1 participant 7 messages Jul 5, 2025

Subsystems (4)
lore
Share & tools
lore

SeongJae Park

author maintainer
#0 lore raw

cover mm/damon: misc cleanups

Yet another round of miscellaneous DAMON cleanups.

SeongJae Park (6):
samples/damon/wsse: rename to have damon_sample_ prefix samples/damon/prcl: rename to have damon_sample_ prefix samples/damon/mtier: rename to have damon_sample_ prefix mm/damon/sysfs: use DAMON core API damon_is_running() mm/damon/sysfs: don't hold kdamond_lock in before_terminate() Docs/mm/damon/maintainer-profile: update for mm-new tree

 Documentation/mm/damon/maintainer-profile.rst | 35 ++++++++++---------
 include/linux/damon.h                         |  1 +
 mm/damon/core.c                               |  8 ++++-
 mm/damon/sysfs.c                              | 16 ++-------
 samples/damon/mtier.c                         |  5 +++
 samples/damon/prcl.c                          |  5 +++
 samples/damon/wsse.c                          |  5 +++
 7 files changed, 44 insertions(+), 31 deletions(-)

base-commit: 486593f91f44f469c920e73a4ef451d9bbbf400e

Signature · 1 line
2.39.5
author maintainer
#1 lore raw

PATCH 1/6 samples/damon/wsse: rename to have damon_sample_ prefix

DAMON sample module, wsse has its name 'wsse'. It could conflict with future modules, and not very easy to identify it by name. Use a prefix, "damon_sample_" for the name.

Note that this could break users if they depend on the old name. But it is just a sample, so no such usage is expected, or known. Even if such usage exists, updating it for the new name should be straightforward.

---
 samples/damon/wsse.c | 5 +++++
 1 file changed, 5 insertions(+)
samples/damon/wsse.c +5 -0
index e20238a249e7..1e8969a0a626 100644
@@ -12,6 +12,11 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 
+#ifdef MODULE_PARAM_PREFIX
+#undef MODULE_PARAM_PREFIX
+#endif
+#define MODULE_PARAM_PREFIX "damon_sample_wsse."
+
 static int target_pid __read_mostly;
 module_param(target_pid, int, 0600);
 
Signature · 1 line
2.39.5
author maintainer
#2 lore raw

PATCH 2/6 samples/damon/prcl: rename to have damon_sample_ prefix

In reply to SeongJae Park

DAMON sample module, prcl has its name 'prcl'. It could conflict with future modules, and not very easy to identify it by name. Use a prefix, "damon_sample_" for the name.

Note that this could break users if they depend on the old name. But it is just a sample, so no such usage is expected, or known. Even if such usage exists, updating it for the new name should be straightforward.

---
 samples/damon/prcl.c | 5 +++++
 1 file changed, 5 insertions(+)
samples/damon/prcl.c +5 -0
index 5597e6a08ab2..447ccba09e8a 100644
@@ -11,6 +11,11 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 
+#ifdef MODULE_PARAM_PREFIX
+#undef MODULE_PARAM_PREFIX
+#endif
+#define MODULE_PARAM_PREFIX "damon_sample_prcl."
+
 static int target_pid __read_mostly;
 module_param(target_pid, int, 0600);
 
Signature · 1 line
2.39.5
author maintainer
#3 lore raw

PATCH 3/6 samples/damon/mtier: rename to have damon_sample_ prefix

In reply to SeongJae Park

DAMON sample module, mtier has its name 'mtier'. It could conflict with future modules, and not very easy to identify it by name. Use a prefix, "damon_sample_" for the name.

Note that this could break users if they depend on the old name. But it is just a sample, so no such usage is expected, or known. Even if such usage exists, updating it for the new name should be straightforward.

---
 samples/damon/mtier.c | 5 +++++
 1 file changed, 5 insertions(+)
samples/damon/mtier.c +5 -0
index 97892ade7f31..af168e887f73 100644
@@ -12,6 +12,11 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 
+#ifdef MODULE_PARAM_PREFIX
+#undef MODULE_PARAM_PREFIX
+#endif
+#define MODULE_PARAM_PREFIX "damon_sample_mtier."
+
 static unsigned long node0_start_addr __read_mostly;
 module_param(node0_start_addr, ulong, 0600);
 
Signature · 1 line
2.39.5
author maintainer
#4 lore raw

PATCH 4/6 mm/damon/sysfs: use DAMON core API damon_is_running()

In reply to SeongJae Park

DAMON core implements a static function to see if a given DAMON context is running. DAMON sysfs interface is implementing the same one on its own. Make the core function non-static and reuse it from the DAMON sysfs interface.

---
 include/linux/damon.h |  1 +
 mm/damon/core.c       |  8 +++++++-
 mm/damon/sysfs.c      | 14 ++------------
 3 files changed, 10 insertions(+), 13 deletions(-)
include/linux/damon.h +1 -0
index bb58e36f019e..e1fea3119538 100644
@@ -934,6 +934,7 @@ static inline unsigned int damon_max_nr_accesses(const struct damon_attrs *attrs
 
 int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive);
 int damon_stop(struct damon_ctx **ctxs, int nr_ctxs);
+bool damon_is_running(struct damon_ctx *ctx);
 
 int damon_call(struct damon_ctx *ctx, struct damon_call_control *control);
 int damos_walk(struct damon_ctx *ctx, struct damos_walk_control *control);
mm/damon/core.c +7 -1
index dc0ee2dd55d3..5357a18066b0 100644
@@ -1311,7 +1311,13 @@ int damon_stop(struct damon_ctx **ctxs, int nr_ctxs)
 	return err;
 }
 
-static bool damon_is_running(struct damon_ctx *ctx)
+/**
+ * damon_is_running() - Returns if a given DAMON context is running.
+ * @ctx:	The DAMON context to see if running.
+ *
+ * Return: true if @ctx is running, false otherwise.
+ */
+bool damon_is_running(struct damon_ctx *ctx)
 {
 	bool running;
 
mm/damon/sysfs.c +2 -12
index 1b1476b79cdb..79d65dcc9dd0 100644
@@ -1189,16 +1189,6 @@ static void damon_sysfs_kdamond_rm_dirs(struct damon_sysfs_kdamond *kdamond)
 	kobject_put(&kdamond->contexts->kobj);
 }
 
-static bool damon_sysfs_ctx_running(struct damon_ctx *ctx)
-{
-	bool running;
-
-	mutex_lock(&ctx->kdamond_lock);
-	running = ctx->kdamond != NULL;
-	mutex_unlock(&ctx->kdamond_lock);
-	return running;
-}
-
 /*
  * enum damon_sysfs_cmd - Commands for a specific kdamond.
  */
@@ -1275,7 +1265,7 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr,
 	if (!ctx)
 		running = false;
 	else
-		running = damon_sysfs_ctx_running(ctx);
+		running = damon_is_running(ctx);
 
 	return sysfs_emit(buf, "%s\n", running ?
 			damon_sysfs_cmd_strs[DAMON_SYSFS_CMD_ON] :
@@ -1429,7 +1419,7 @@ static inline bool damon_sysfs_kdamond_running(
 		struct damon_sysfs_kdamond *kdamond)
 {
 	return kdamond->damon_ctx &&
-		damon_sysfs_ctx_running(kdamond->damon_ctx);
+		damon_is_running(kdamond->damon_ctx);
 }
 
 static int damon_sysfs_apply_inputs(struct damon_ctx *ctx,
Signature · 1 line
2.39.5
author maintainer
#5 lore raw

PATCH 5/6 mm/damon/sysfs: don't hold kdamond_lock in before_terminate()

In reply to SeongJae Park

damon_sysfs_before_terminate() is a DAMON callback that is executed from the kdamond's context. Hence it is safe to access DAMON context internal data. But the function is unnecessarily holding kdamond_lock of the context. It is just unnecessary. Remove the locking code.

---
 mm/damon/sysfs.c | 2 --
 1 file changed, 2 deletions(-)
mm/damon/sysfs.c +0 -2
index 79d65dcc9dd0..c0193de6fb9a 100644
@@ -1387,12 +1387,10 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx)
 	if (!damon_target_has_pid(ctx))
 		return;
 
-	mutex_lock(&ctx->kdamond_lock);
 	damon_for_each_target_safe(t, next, ctx) {
 		put_pid(t->pid);
 		damon_destroy_target(t);
 	}
-	mutex_unlock(&ctx->kdamond_lock);
 }
 
 /*
Signature · 1 line
2.39.5
author maintainer
#6 lore raw

PATCH 6/6 Docs/mm/damon/maintainer-profile: update for mm-new tree

In reply to SeongJae Park

Recently a new mm tree for new patches, namely mm-new, has been added. Update DAMON maintainer's profile doc for DAMON patches life cycle, which depend on those of mm trees.

---
 Documentation/mm/damon/maintainer-profile.rst | 35 ++++++++++---------
 1 file changed, 19 insertions(+), 16 deletions(-)
Documentation/mm/damon/maintainer-profile.rst +19 -16
index ce3e98458339..5cd07905a193 100644
@@ -7,9 +7,9 @@ The DAMON subsystem covers the files that are listed in 'DATA ACCESS MONITOR'
 section of 'MAINTAINERS' file.
 
 The mailing lists for the subsystem are [email protected] and
[email protected].  Patches should be made against the `mm-unstable tree
-<https://git.kernel.org/akpm/mm/h/mm-unstable>`_ whenever possible and posted
-to the mailing lists.
[email protected].  Patches should be made against the `mm-new tree
+<https://git.kernel.org/akpm/mm/h/mm-new>`_ whenever possible and posted to the
+mailing lists.
 
 SCM Trees
 ---------
@@ -17,17 +17,19 @@ SCM Trees
 There are multiple Linux trees for DAMON development.  Patches under
 development or testing are queued in `damon/next
 <https://git.kernel.org/sj/h/damon/next>`_ by the DAMON maintainer.
-Sufficiently reviewed patches will be queued in `mm-unstable
-<https://git.kernel.org/akpm/mm/h/mm-unstable>`_ by the memory management
-subsystem maintainer.  After more sufficient tests, the patches will be queued
-in `mm-stable <https://git.kernel.org/akpm/mm/h/mm-stable>`_, and finally
-pull-requested to the mainline by the memory management subsystem maintainer.
-
-Note again the patches for `mm-unstable tree
-<https://git.kernel.org/akpm/mm/h/mm-unstable>`_ are queued by the memory
-management subsystem maintainer.  If the patches requires some patches in
-`damon/next tree <https://git.kernel.org/sj/h/damon/next>`_ which not yet merged
-in mm-unstable, please make sure the requirement is clearly specified.
+Sufficiently reviewed patches will be queued in `mm-new
+<https://git.kernel.org/akpm/mm/h/mm-new>`_ by the memory management subsystem
+maintainer.  As more sufficient tests are done, the patches will move to
+`mm-unstable <https://git.kernel.org/akpm/mm/h/mm-unstable>`_ and then to
+`mm-stable <https://git.kernel.org/akpm/mm/h/mm-stable>`_.  And finally those
+will be pull-requested to the mainline by the memory management subsystem
+maintainer.
+
+Note again the patches for `mm-new tree
+<https://git.kernel.org/akpm/mm/h/mm-new>`_ are queued by the memory management
+subsystem maintainer.  If the patches requires some patches in `damon/next tree
+<https://git.kernel.org/sj/h/damon/next>`_ which not yet merged in mm-new,
+please make sure the requirement is clearly specified.
 
 Submit checklist addendum
 -------------------------
@@ -53,8 +55,9 @@ Further doing below and putting the results will be helpful.
 Key cycle dates
 ---------------
 
-Patches can be sent anytime.  Key cycle dates of the `mm-unstable
-<https://git.kernel.org/akpm/mm/h/mm-unstable>`_ and `mm-stable
+Patches can be sent anytime.  Key cycle dates of the `mm-new
+<https://git.kernel.org/akpm/mm/h/mm-new>`_, `mm-unstable
+<https://git.kernel.org/akpm/mm/h/mm-unstable>`_and `mm-stable
 <https://git.kernel.org/akpm/mm/h/mm-stable>`_ trees depend on the memory
 management subsystem maintainer.
 
Signature · 1 line
2.39.5