From: Bijan Tabatabai <bijantabatab@micron.com>
To update DAMOS migration dests, users need to write "commit" to the
"state" file of kdamond, which will recommit all of the damon parameters.
This patch implements another state file input command,
"commit_scheme_dests," that only commits the DAMOS migration dests.
This provides two benefits:
1) It is slightly more efficient
2) When the "commit" command is sent to the state file,
ctx->next_{aggregation/ops_update}_sis are reset. If a user sends the
"commit" command frequently (relative to the aggregation and
ops_update periods) to update the migration dests, the aggregation and
ops_update events will be prevented from triggering. Having a
separate command side steps this problem.
Signed-off-by: Bijan Tabatabai <bijantabatab@micron.com>
---
mm/damon/sysfs-common.h | 3 +++
mm/damon/sysfs-schemes.c | 35 ++++++++++++++++++++++++++++++++---
mm/damon/sysfs.c | 27 +++++++++++++++++++++++++++
3 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h
index 2099adee11d0..3189b2bda079 100644
--- a/mm/damon/sysfs-common.h
+++ b/mm/damon/sysfs-common.h
@@ -59,3 +59,6 @@ int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes,
void damos_sysfs_update_effective_quotas(
struct damon_sysfs_schemes *sysfs_schemes,
struct damon_ctx *ctx);
+
+int damos_sysfs_set_schemes_dests(struct damon_sysfs_schemes *sysfs_schemes,
+ struct damon_ctx *ctx);
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index d355f6c42a98..d30c8b6575c2 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2445,10 +2445,9 @@ void damos_sysfs_update_effective_quotas(
}
}
-static int damos_sysfs_add_migrate_dest(struct damos *scheme,
+static int damos_sysfs_add_migrate_dest(struct damos_migrate_dests *dests,
struct damos_sysfs_dests *sysfs_dests)
{
- struct damos_migrate_dests *dests = &scheme->migrate_dests;
int i;
dests->node_id_arr = kmalloc_array(sysfs_dests->nr,
@@ -2468,6 +2467,35 @@ static int damos_sysfs_add_migrate_dest(struct damos *scheme,
return 0;
}
+int damos_sysfs_set_schemes_dests(struct damon_sysfs_schemes *sysfs_schemes,
+ struct damon_ctx *ctx)
+{
+ struct damos *scheme;
+ int i = 0;
+
+ damon_for_each_scheme(scheme, ctx) {
+ struct damos_sysfs_dests *sysfs_dests;
+ struct damos_migrate_dests dests = {};
+ int err;
+
+ /* user could have removed the scheme sysfs dir */
+ if (i >= sysfs_schemes->nr)
+ break;
+
+ sysfs_dests = sysfs_schemes->schemes_arr[i]->dests;
+ err = damos_sysfs_add_migrate_dest(&dests, sysfs_dests);
+ if (err) {
+ damos_destroy_dests(&dests);
+ return err;
+ }
+
+ damos_destroy_dests(&scheme->migrate_dests);
+ scheme->migrate_dests = dests;
+ }
+
+ return 0;
+}
+
static struct damos *damon_sysfs_mk_scheme(
struct damon_sysfs_scheme *sysfs_scheme)
{
@@ -2530,7 +2558,8 @@ static struct damos *damon_sysfs_mk_scheme(
damon_destroy_scheme(scheme);
return NULL;
}
- err = damos_sysfs_add_migrate_dest(scheme, sysfs_scheme->dests);
+ err = damos_sysfs_add_migrate_dest(&scheme->migrate_dests,
+ sysfs_scheme->dests);
if (err) {
damon_destroy_scheme(scheme);
return NULL;
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 1af6aff35d84..c2b036abb25b 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1188,6 +1188,11 @@ enum damon_sysfs_cmd {
* to DAMON.
*/
DAMON_SYSFS_CMD_COMMIT_SCHEMES_QUOTA_GOALS,
+ /*
+ * @DAMON_SYSFS_CMD_COMMIT_SCHEMES_DESTS: Commit the scheme dests to
+ * DAMON.
+ */
+ DAMON_SYSFS_CMD_COMMIT_SCHEMES_DESTS,
/*
* @DAMON_SYSFS_CMD_UPDATE_SCHEMES_STATS: Update scheme stats sysfs
* files.
@@ -1230,6 +1235,7 @@ static const char * const damon_sysfs_cmd_strs[] = {
"off",
"commit",
"commit_schemes_quota_goals",
+ "commit_schemes_dests",
"update_schemes_stats",
"update_schemes_tried_bytes",
"update_schemes_tried_regions",
@@ -1478,6 +1484,23 @@ static int damon_sysfs_commit_schemes_quota_goals(void *data)
return damos_sysfs_set_quota_scores(sysfs_ctx->schemes, ctx);
}
+static int damon_sysfs_commit_schemes_dests(void *data)
+{
+ struct damon_sysfs_kdamond *sysfs_kdamond = data;
+ struct damon_ctx *ctx;
+ struct damon_sysfs_context *sysfs_ctx;
+
+ if (!damon_sysfs_kdamond_running(sysfs_kdamond))
+ return -EINVAL;
+ /* TODO: Support multiple contexts per kdamond */
+ if (sysfs_kdamond->contexts->nr != 1)
+ return -EINVAL;
+
+ ctx = sysfs_kdamond->damon_ctx;
+ sysfs_ctx = sysfs_kdamond->contexts->contexts_arr[0];
+ return damos_sysfs_set_schemes_dests(sysfs_ctx->schemes, ctx);
+}
+
/*
* damon_sysfs_upd_schemes_effective_quotas() - Update schemes effective quotas
* sysfs files.
@@ -1644,6 +1667,10 @@ static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd,
return damon_sysfs_damon_call(
damon_sysfs_commit_schemes_quota_goals,
kdamond);
+ case DAMON_SYSFS_CMD_COMMIT_SCHEMES_DESTS:
+ return damon_sysfs_damon_call(
+ damon_sysfs_commit_schemes_dests,
+ kdamond);
case DAMON_SYSFS_CMD_UPDATE_SCHEMES_STATS:
return damon_sysfs_damon_call(
damon_sysfs_upd_schemes_stats, kdamond);
--
2.43.5
Hi Bijan, kernel test robot noticed the following build warnings: url: https://github.com/intel-lab-lkp/linux/commits/Bijan-Tabatabai/mm-damon-core-Add-damos_destroy_dests/20250806-120845 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20250805162022.4920-3-bijan311%40gmail.com patch subject: [PATCH 2/5] mm/damon/sysfs: Implement a command to only commit scheme dests config: microblaze-randconfig-r072-20250810 (https://download.01.org/0day-ci/archive/20250810/202508101330.XRQqvfiN-lkp@intel.com/config) compiler: microblaze-linux-gcc (GCC) 8.5.0 If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org> | Closes: https://lore.kernel.org/r/202508101330.XRQqvfiN-lkp@intel.com/ smatch warnings: mm/damon/sysfs-schemes.c:2605 damos_sysfs_set_schemes_dests() warn: iterator 'i' not incremented vim +/i +2605 mm/damon/sysfs-schemes.c 8014d822c9939b Bijan Tabatabai 2025-08-05 2601 int damos_sysfs_set_schemes_dests(struct damon_sysfs_schemes *sysfs_schemes, 8014d822c9939b Bijan Tabatabai 2025-08-05 2602 struct damon_ctx *ctx) 8014d822c9939b Bijan Tabatabai 2025-08-05 2603 { 8014d822c9939b Bijan Tabatabai 2025-08-05 2604 struct damos *scheme; 8014d822c9939b Bijan Tabatabai 2025-08-05 @2605 int i = 0; 8014d822c9939b Bijan Tabatabai 2025-08-05 2606 8014d822c9939b Bijan Tabatabai 2025-08-05 2607 damon_for_each_scheme(scheme, ctx) { 8014d822c9939b Bijan Tabatabai 2025-08-05 2608 struct damos_sysfs_dests *sysfs_dests; 8014d822c9939b Bijan Tabatabai 2025-08-05 2609 struct damos_migrate_dests dests = {}; 8014d822c9939b Bijan Tabatabai 2025-08-05 2610 int err; 8014d822c9939b Bijan Tabatabai 2025-08-05 2611 8014d822c9939b Bijan Tabatabai 2025-08-05 2612 /* user could have removed the scheme sysfs dir */ 8014d822c9939b Bijan Tabatabai 2025-08-05 2613 if (i >= sysfs_schemes->nr) i is always zero. 8014d822c9939b Bijan Tabatabai 2025-08-05 2614 break; 8014d822c9939b Bijan Tabatabai 2025-08-05 2615 8014d822c9939b Bijan Tabatabai 2025-08-05 2616 sysfs_dests = sysfs_schemes->schemes_arr[i]->dests; 8014d822c9939b Bijan Tabatabai 2025-08-05 2617 err = damos_sysfs_add_migrate_dest(&dests, sysfs_dests); 8014d822c9939b Bijan Tabatabai 2025-08-05 2618 if (err) { 8014d822c9939b Bijan Tabatabai 2025-08-05 2619 damos_destroy_dests(&dests); 8014d822c9939b Bijan Tabatabai 2025-08-05 2620 return err; 8014d822c9939b Bijan Tabatabai 2025-08-05 2621 } 8014d822c9939b Bijan Tabatabai 2025-08-05 2622 8014d822c9939b Bijan Tabatabai 2025-08-05 2623 damos_destroy_dests(&scheme->migrate_dests); 8014d822c9939b Bijan Tabatabai 2025-08-05 2624 scheme->migrate_dests = dests; 8014d822c9939b Bijan Tabatabai 2025-08-05 2625 } 8014d822c9939b Bijan Tabatabai 2025-08-05 2626 8014d822c9939b Bijan Tabatabai 2025-08-05 2627 return 0; 8014d822c9939b Bijan Tabatabai 2025-08-05 2628 } -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On Mon, 11 Aug 2025 10:00:50 +0300 Dan Carpenter <dan.carpenter@linaro.org> wrote: > Hi Bijan, > > kernel test robot noticed the following build warnings: > > url: https://github.com/intel-lab-lkp/linux/commits/Bijan-Tabatabai/mm-damon-core-Add-damos_destroy_dests/20250806-120845 > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything > patch link: https://lore.kernel.org/r/20250805162022.4920-3-bijan311%40gmail.com > patch subject: [PATCH 2/5] mm/damon/sysfs: Implement a command to only commit scheme dests > config: microblaze-randconfig-r072-20250810 (https://download.01.org/0day-ci/archive/20250810/202508101330.XRQqvfiN-lkp@intel.com/config) > compiler: microblaze-linux-gcc (GCC) 8.5.0 > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Reported-by: Dan Carpenter <dan.carpenter@linaro.org> > | Closes: https://lore.kernel.org/r/202508101330.XRQqvfiN-lkp@intel.com/ > > smatch warnings: > mm/damon/sysfs-schemes.c:2605 damos_sysfs_set_schemes_dests() warn: iterator 'i' not incremented Thank you for this report. Nonetheless, this patch has replaced with another one[1]. Hence, we have no plan to make this patch be merged into the mainline, and we have no action item for this report. Please let me know if I'm missing something. [1] https://lore.kernel.org/20250806234254.10572-1-bijan311@gmail.com Thanks, SJ [...]
© 2016 - 2025 Red Hat, Inc.