linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights
@ 2025-06-21 17:31 SeongJae Park
  2025-06-21 17:31 ` [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest SeongJae Park
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: SeongJae Park @ 2025-06-21 17:31 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, damon, kernel-team,
	linux-kernel, linux-mm

DAMOS_MIGRATE_{HOT,COLD} action can migrate pages to only single node.
It could be useful to allow it migrates pages to multiple nodes with
different weights.  A work for dynamic interleaving[1] is in progress.
We also discussed this could be useful for memory tiering, e.g., when we
want to move pages to multiple noes of same tier.

Extend the API and ABI interface for specifying the multiple destination
nodes and their weights.

Note that this RFC is a prototype of the interface change for Bijan's
interleaving work[1].  Hence this patch series is only implementing the
interface part, not the real implementation of the migration behavior.

[1] https://lore.kernel.org/20250620180458.5041-1-bijan311@gmail.com
[2] https://lore.kernel.org/20240408175228.91414-1-sj@kernel.org

SeongJae Park (4):
  mm/damon: add struct damos_migrate_dest
  mm/damon/core: add damos->migrate_dest field
  mm/damon/sysfs-schemes: implement DAMOS action destinations directory
  mm/damon/sysfs-schemes: set damos->migrate_dest

 include/linux/damon.h    |  29 ++++-
 mm/damon/core.c          |   4 +
 mm/damon/sysfs-schemes.c | 253 ++++++++++++++++++++++++++++++++++++++-
 3 files changed, 282 insertions(+), 4 deletions(-)


base-commit: 78745efafbb93197e476717385616ed57ea2df22
-- 
2.39.5


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest
  2025-06-21 17:31 [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights SeongJae Park
@ 2025-06-21 17:31 ` SeongJae Park
  2025-07-01 22:43   ` Bijan Tabatabai
  2025-06-21 17:31 ` [RFC PATCH 2/4] mm/damon/core: add damos->migrate_dest field SeongJae Park
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: SeongJae Park @ 2025-06-21 17:31 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, damon, kernel-team,
	linux-kernel, linux-mm

Introduce a new struct, namely damos_migrate_dest, for specifying
multiple DAMOS' migration destination nodes and their weights.

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

diff --git a/include/linux/damon.h b/include/linux/damon.h
index bb58e36f019e..d60addd0b7c8 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -447,6 +447,22 @@ struct damos_access_pattern {
 	unsigned int max_age_region;
 };
 
+/**
+ * struct damos_migrate_dest - Migration destination nodes and their weights.
+ * @node_id_arr:	Array of migration destination node ids.
+ * @weight_arr:		Array of migration weights for @node_id_arr.
+ * @nr_dests:		Length of the @node_id_arr and @weight_arr arrays.
+ *
+ * @node_id_arr is an array of the ids of migration destination nodes.
+ * @weight_arr is an array of the weights for those.  The weights in
+ * @weight_arr are for nodes in @node_id_arr of same array index.
+ */
+struct damos_migrate_dest {
+	unsigned int *node_id_arr;
+	unsigned int *weight_arr;
+	size_t nr_dests;
+};
+
 /**
  * struct damos - Represents a Data Access Monitoring-based Operation Scheme.
  * @pattern:		Access pattern of target regions.
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [RFC PATCH 2/4] mm/damon/core: add damos->migrate_dest field
  2025-06-21 17:31 [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights SeongJae Park
  2025-06-21 17:31 ` [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest SeongJae Park
@ 2025-06-21 17:31 ` SeongJae Park
  2025-06-21 17:31 ` [RFC PATCH 3/4] mm/damon/sysfs-schemes: implement DAMOS action destinations directory SeongJae Park
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2025-06-21 17:31 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, damon, kernel-team,
	linux-kernel, linux-mm

Add a new field to 'struct damos', namely migrate_dest, to allow DAMON
API callers specify multiple migration destination nodes and their
weights.  Also update 'struct damos' creation and destruction functions
accordingly to initialize the new field and free up the API
caller-allocated buffers on those, respectively.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 include/linux/damon.h | 13 ++++++++++---
 mm/damon/core.c       |  4 ++++
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index d60addd0b7c8..6370cf44486f 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -470,6 +470,7 @@ struct damos_migrate_dest {
  * @apply_interval_us:	The time between applying the @action.
  * @quota:		Control the aggressiveness of this scheme.
  * @wmarks:		Watermarks for automated (in)activation of this scheme.
+ * @migrate_dest:	Destination nodes if @action is "migrate_{hot,cold}".
  * @target_nid:		Destination node if @action is "migrate_{hot,cold}".
  * @filters:		Additional set of &struct damos_filter for &action.
  * @ops_filters:	ops layer handling &struct damos_filter objects list.
@@ -488,9 +489,12 @@ struct damos_migrate_dest {
  * monitoring context are inactive, DAMON stops monitoring either, and just
  * repeatedly checks the watermarks.
  *
+ * @migrate_dest specifies multiple migration target nodes with different
+ * weights for migrate_hot or migrate_cold actions.  @target_nid is ignored if
+ * this is set.
+ *
  * @target_nid is used to set the migration target node for migrate_hot or
- * migrate_cold actions, which means it's only meaningful when @action is either
- * "migrate_hot" or "migrate_cold".
+ * migrate_cold actions, and @migrate_dest is unset.
  *
  * Before applying the &action to a memory region, &struct damon_operations
  * implementation could check pages of the region and skip &action to respect
@@ -533,7 +537,10 @@ struct damos {
 	struct damos_quota quota;
 	struct damos_watermarks wmarks;
 	union {
-		int target_nid;
+		struct {
+			int target_nid;
+			struct damos_migrate_dest migrate_dest;
+		};
 	};
 	struct list_head filters;
 	struct list_head ops_filters;
diff --git a/mm/damon/core.c b/mm/damon/core.c
index b217e0120e09..ea2a17b2dee7 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -407,6 +407,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern,
 	scheme->wmarks = *wmarks;
 	scheme->wmarks.activated = true;
 
+	scheme->migrate_dest = (struct damos_migrate_dest){};
 	scheme->target_nid = target_nid;
 
 	return scheme;
@@ -449,6 +450,9 @@ void damon_destroy_scheme(struct damos *s)
 
 	damos_for_each_filter_safe(f, next, s)
 		damos_destroy_filter(f);
+
+	kfree(s->migrate_dest.node_id_arr);
+	kfree(s->migrate_dest.weight_arr);
 	damon_del_scheme(s);
 	damon_free_scheme(s);
 }
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [RFC PATCH 3/4] mm/damon/sysfs-schemes: implement DAMOS action destinations directory
  2025-06-21 17:31 [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights SeongJae Park
  2025-06-21 17:31 ` [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest SeongJae Park
  2025-06-21 17:31 ` [RFC PATCH 2/4] mm/damon/core: add damos->migrate_dest field SeongJae Park
@ 2025-06-21 17:31 ` SeongJae Park
  2025-06-21 17:31 ` [RFC PATCH 4/4] mm/damon/sysfs-schemes: set damos->migrate_dest SeongJae Park
  2025-07-01 22:39 ` [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights Bijan Tabatabai
  4 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2025-06-21 17:31 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, damon, kernel-team,
	linux-kernel, linux-mm

DAMOS_MIGRATE_{HOT,COLD} can have multiple action destinations and their
weights.  Implement sysfs directory named 'dests' under each scheme
directory to let DAMON sysfs ABI users utilize the feature.  The
interface is similar to other multiple parameters directory like
kdamonds or filters.  The directory contains only nr_dests file
initially.  Writing a number of desired destinations to nr_dests creates
directories of the number that has files named id and weight.  Users can
then write the destination id (node id in case of DAMOS_MIGRATE_*) and
their weight to the files.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/sysfs-schemes.c | 225 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 224 insertions(+), 1 deletion(-)

diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 30ae7518ffbf..e04cd8d592b8 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -1568,6 +1568,204 @@ static const struct kobj_type damon_sysfs_access_pattern_ktype = {
 	.default_groups = damon_sysfs_access_pattern_groups,
 };
 
+/*
+ * dest (action destination) directory
+ */
+
+struct damos_sysfs_dest {
+	struct kobject kobj;
+	unsigned int id;
+	unsigned int weight;
+};
+
+static struct damos_sysfs_dest *damos_sysfs_dest_alloc(void)
+{
+	return kzalloc(sizeof(struct damos_sysfs_dest), GFP_KERNEL);
+}
+
+static ssize_t id_show(
+		struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+	struct damos_sysfs_dest *dest = container_of(kobj,
+			struct damos_sysfs_dest, kobj);
+
+	return sysfs_emit(buf, "%u\n", dest->id);
+}
+
+static ssize_t id_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	struct damos_sysfs_dest *dest = container_of(kobj,
+			struct damos_sysfs_dest, kobj);
+	int err = kstrtouint(buf, 0, &dest->id);
+
+	return err ? err : count;
+}
+
+static ssize_t weight_show(
+		struct kobject *kobj, struct kobj_attribute *attr, char *buf)
+{
+	struct damos_sysfs_dest *dest = container_of(kobj,
+			struct damos_sysfs_dest, kobj);
+
+	return sysfs_emit(buf, "%u\n", dest->weight);
+}
+
+static ssize_t weight_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	struct damos_sysfs_dest *dest = container_of(kobj,
+			struct damos_sysfs_dest, kobj);
+	int err = kstrtouint(buf, 0, &dest->weight);
+
+	return err ? err : count;
+}
+
+static void damos_sysfs_dest_release(struct kobject *kobj)
+{
+	struct damos_sysfs_dest *dest = container_of(kobj,
+			struct damos_sysfs_dest, kobj);
+	kfree(dest);
+}
+
+static struct kobj_attribute damos_sysfs_dest_id_attr =
+		__ATTR_RW_MODE(id, 0600);
+
+static struct kobj_attribute damos_sysfs_dest_weight_attr =
+		__ATTR_RW_MODE(weight, 0600);
+
+static struct attribute *damos_sysfs_dest_attrs[] = {
+	&damos_sysfs_dest_id_attr.attr,
+	&damos_sysfs_dest_weight_attr.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(damos_sysfs_dest);
+
+static const struct kobj_type damos_sysfs_dest_ktype = {
+	.release = damos_sysfs_dest_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+	.default_groups = damos_sysfs_dest_groups,
+};
+
+/*
+ * dests (action destinations) directory
+ */
+
+struct damos_sysfs_dests {
+	struct kobject kobj;
+	struct damos_sysfs_dest **dests_arr;
+	int nr;
+};
+
+static struct damos_sysfs_dests *
+damos_sysfs_dests_alloc(void)
+{
+	return kzalloc(sizeof(struct damos_sysfs_dests), GFP_KERNEL);
+}
+
+static void damos_sysfs_dests_rm_dirs(
+		struct damos_sysfs_dests *dests)
+{
+	struct damos_sysfs_dest **dests_arr = dests->dests_arr;
+	int i;
+
+	for (i = 0; i < dests->nr; i++)
+		kobject_put(&dests_arr[i]->kobj);
+	dests->nr = 0;
+	kfree(dests_arr);
+	dests->dests_arr = NULL;
+}
+
+static int damos_sysfs_dests_add_dirs(
+		struct damos_sysfs_dests *dests, int nr_dests)
+{
+	struct damos_sysfs_dest **dests_arr, *dest;
+	int err, i;
+
+	damos_sysfs_dests_rm_dirs(dests);
+	if (!nr_dests)
+		return 0;
+
+	dests_arr = kmalloc_array(nr_dests, sizeof(*dests_arr),
+			GFP_KERNEL | __GFP_NOWARN);
+	if (!dests_arr)
+		return -ENOMEM;
+	dests->dests_arr = dests_arr;
+
+	for (i = 0; i < nr_dests; i++) {
+		dest = damos_sysfs_dest_alloc();
+		if (!dest) {
+			damos_sysfs_dests_rm_dirs(dests);
+			return -ENOMEM;
+		}
+
+		err = kobject_init_and_add(&dest->kobj,
+				&damos_sysfs_dest_ktype,
+				&dests->kobj, "%d", i);
+		if (err) {
+			kobject_put(&dest->kobj);
+			damos_sysfs_dests_rm_dirs(dests);
+			return err;
+		}
+
+		dests_arr[i] = dest;
+		dests->nr++;
+	}
+	return 0;
+}
+
+static ssize_t nr_dests_show(struct kobject *kobj,
+		struct kobj_attribute *attr, char *buf)
+{
+	struct damos_sysfs_dests *dests = container_of(kobj,
+			struct damos_sysfs_dests, kobj);
+
+	return sysfs_emit(buf, "%d\n", dests->nr);
+}
+
+static ssize_t nr_dests_store(struct kobject *kobj,
+		struct kobj_attribute *attr, const char *buf, size_t count)
+{
+	struct damos_sysfs_dests *dests;
+	int nr, err = kstrtoint(buf, 0, &nr);
+
+	if (err)
+		return err;
+	if (nr < 0)
+		return -EINVAL;
+
+	dests = container_of(kobj, struct damos_sysfs_dests, kobj);
+
+	if (!mutex_trylock(&damon_sysfs_lock))
+		return -EBUSY;
+	err = damos_sysfs_dests_add_dirs(dests, nr);
+	mutex_unlock(&damon_sysfs_lock);
+	if (err)
+		return err;
+
+	return count;
+}
+
+static void damos_sysfs_dests_release(struct kobject *kobj)
+{
+	kfree(container_of(kobj, struct damos_sysfs_dests, kobj));
+}
+
+static struct kobj_attribute damos_sysfs_dests_nr_attr =
+		__ATTR_RW_MODE(nr_dests, 0600);
+
+static struct attribute *damos_sysfs_dests_attrs[] = {
+	&damos_sysfs_dests_nr_attr.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(damos_sysfs_dests);
+
+static const struct kobj_type damos_sysfs_dests_ktype = {
+	.release = damos_sysfs_dests_release,
+	.sysfs_ops = &kobj_sysfs_ops,
+	.default_groups = damos_sysfs_dests_groups,
+};
+
 /*
  * scheme directory
  */
@@ -1585,6 +1783,7 @@ struct damon_sysfs_scheme {
 	struct damon_sysfs_stats *stats;
 	struct damon_sysfs_scheme_regions *tried_regions;
 	int target_nid;
+	struct damos_sysfs_dests *dests;
 };
 
 /* This should match with enum damos_action */
@@ -1641,6 +1840,22 @@ static int damon_sysfs_scheme_set_access_pattern(
 	return err;
 }
 
+static int damos_sysfs_set_dests(struct damon_sysfs_scheme *scheme)
+{
+	struct damos_sysfs_dests *dests = damos_sysfs_dests_alloc();
+	int err;
+
+	if (!dests)
+		return -ENOMEM;
+	err = kobject_init_and_add(&dests->kobj, &damos_sysfs_dests_ktype,
+			&scheme->kobj, "dests");
+	if (err)
+		kobject_put(&dests->kobj);
+	else
+		scheme->dests = dests;
+	return err;
+}
+
 static int damon_sysfs_scheme_set_quotas(struct damon_sysfs_scheme *scheme)
 {
 	struct damon_sysfs_quotas *quotas = damon_sysfs_quotas_alloc();
@@ -1773,9 +1988,12 @@ static int damon_sysfs_scheme_add_dirs(struct damon_sysfs_scheme *scheme)
 	err = damon_sysfs_scheme_set_access_pattern(scheme);
 	if (err)
 		return err;
-	err = damon_sysfs_scheme_set_quotas(scheme);
+	err = damos_sysfs_set_dests(scheme);
 	if (err)
 		goto put_access_pattern_out;
+	err = damon_sysfs_scheme_set_quotas(scheme);
+	if (err)
+		goto put_dests_out;
 	err = damon_sysfs_scheme_set_watermarks(scheme);
 	if (err)
 		goto put_quotas_access_pattern_out;
@@ -1806,6 +2024,9 @@ static int damon_sysfs_scheme_add_dirs(struct damon_sysfs_scheme *scheme)
 put_quotas_access_pattern_out:
 	kobject_put(&scheme->quotas->kobj);
 	scheme->quotas = NULL;
+put_dests_out:
+	kobject_put(&scheme->dests->kobj);
+	scheme->dests = NULL;
 put_access_pattern_out:
 	kobject_put(&scheme->access_pattern->kobj);
 	scheme->access_pattern = NULL;
@@ -1816,6 +2037,8 @@ static void damon_sysfs_scheme_rm_dirs(struct damon_sysfs_scheme *scheme)
 {
 	damon_sysfs_access_pattern_rm_dirs(scheme->access_pattern);
 	kobject_put(&scheme->access_pattern->kobj);
+	kobject_put(&scheme->dests->kobj);
+	damos_sysfs_dests_rm_dirs(scheme->dests);
 	damon_sysfs_quotas_rm_dirs(scheme->quotas);
 	kobject_put(&scheme->quotas->kobj);
 	kobject_put(&scheme->watermarks->kobj);
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [RFC PATCH 4/4] mm/damon/sysfs-schemes: set damos->migrate_dest
  2025-06-21 17:31 [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights SeongJae Park
                   ` (2 preceding siblings ...)
  2025-06-21 17:31 ` [RFC PATCH 3/4] mm/damon/sysfs-schemes: implement DAMOS action destinations directory SeongJae Park
@ 2025-06-21 17:31 ` SeongJae Park
  2025-07-01 22:39 ` [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights Bijan Tabatabai
  4 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2025-06-21 17:31 UTC (permalink / raw)
  Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, damon, kernel-team,
	linux-kernel, linux-mm

Pass user-specified multiple DAMOS action destinations and their weights
to DAMON core API, so that user requests can really work.

Signed-off-by: SeongJae Park <sj@kernel.org>
---
 mm/damon/sysfs-schemes.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index e04cd8d592b8..158a2be3fd45 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2445,6 +2445,29 @@ void damos_sysfs_update_effective_quotas(
 	}
 }
 
+static int damos_sysfs_add_migrate_dest(struct damos *scheme,
+		struct damos_sysfs_dests *sysfs_dests)
+{
+	struct damos_migrate_dest *dest = &scheme->migrate_dest;
+	int i;
+
+	dest->node_id_arr = kmalloc_array(sysfs_dests->nr,
+			sizeof(*dest->node_id_arr), GFP_KERNEL);
+	if (!dest->node_id_arr)
+		return -ENOMEM;
+	dest->weight_arr = kmalloc_array(sysfs_dests->nr,
+			sizeof(*dest->weight_arr), GFP_KERNEL);
+	if (!dest->weight_arr)
+		/* ->node_id_arr will be freed by scheme destruction */
+		return -ENOMEM;
+	for (i = 0; i < sysfs_dests->nr; i++) {
+		dest->node_id_arr[i] = sysfs_dests->dests_arr[i]->id;
+		dest->weight_arr[i] = sysfs_dests->dests_arr[i]->weight;
+	}
+	dest->nr_dests = sysfs_dests->nr;
+	return 0;
+}
+
 static struct damos *damon_sysfs_mk_scheme(
 		struct damon_sysfs_scheme *sysfs_scheme)
 {
@@ -2507,6 +2530,11 @@ static struct damos *damon_sysfs_mk_scheme(
 		damon_destroy_scheme(scheme);
 		return NULL;
 	}
+	err = damos_sysfs_add_migrate_dest(scheme, sysfs_scheme->dests);
+	if (err) {
+		damon_destroy_scheme(scheme);
+		return NULL;
+	}
 	return scheme;
 }
 
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights
  2025-06-21 17:31 [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights SeongJae Park
                   ` (3 preceding siblings ...)
  2025-06-21 17:31 ` [RFC PATCH 4/4] mm/damon/sysfs-schemes: set damos->migrate_dest SeongJae Park
@ 2025-07-01 22:39 ` Bijan Tabatabai
  2025-07-02  0:23   ` SeongJae Park
  4 siblings, 1 reply; 12+ messages in thread
From: Bijan Tabatabai @ 2025-07-01 22:39 UTC (permalink / raw)
  To: bijan311, SeongJae Park
  Cc: Andrew Morton, Bijan Tabatabai, damon, kernel-team, linux-kernel,
	linux-mm

On Sat, 21 Jun 2025 10:31:27 -0700 SeongJae Park <sj@kernel.org> wrote:

> DAMOS_MIGRATE_{HOT,COLD} action can migrate pages to only single node.
> It could be useful to allow it migrates pages to multiple nodes with
> different weights.  A work for dynamic interleaving[1] is in progress.
> We also discussed this could be useful for memory tiering, e.g., when we
> want to move pages to multiple noes of same tier.
> 
> Extend the API and ABI interface for specifying the multiple destination
> nodes and their weights.
> 
> Note that this RFC is a prototype of the interface change for Bijan's
> interleaving work[1].  Hence this patch series is only implementing the
> interface part, not the real implementation of the migration behavior.
> 
> [1] https://lore.kernel.org/20250620180458.5041-1-bijan311@gmail.com
> [2] https://lore.kernel.org/20240408175228.91414-1-sj@kernel.org
> 
> SeongJae Park (4):
>   mm/damon: add struct damos_migrate_dest
>   mm/damon/core: add damos->migrate_dest field
>   mm/damon/sysfs-schemes: implement DAMOS action destinations directory
>   mm/damon/sysfs-schemes: set damos->migrate_dest
> 
>  include/linux/damon.h    |  29 ++++-
>  mm/damon/core.c          |   4 +
>  mm/damon/sysfs-schemes.c | 253 ++++++++++++++++++++++++++++++++++++++-
>  3 files changed, 282 insertions(+), 4 deletions(-)
> 
> 
> base-commit: 78745efafbb93197e476717385616ed57ea2df22
> -- 
> 2.39.5

Hi SeongJae,

Thanks for putting this patch together. Sorry for taking a while to
respond to it.

I am finishing up V3 of the interleave patchset using these patches. It
has mostly worked great, but I noticed that damos->migrate_dest was not
being updated in damos_commit(), so new weights would not be applied. This
meant that you could not update the interleave weights by committing the
damon state. I also saw that damos->target_nid was also not being updated
here. I will will have a patch fixing this with the V3 of the interleave
patchset that I will hopefully send out tomorrow.

Thanks,
Bijan


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest
  2025-06-21 17:31 ` [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest SeongJae Park
@ 2025-07-01 22:43   ` Bijan Tabatabai
  2025-07-02  0:25     ` SeongJae Park
  0 siblings, 1 reply; 12+ messages in thread
From: Bijan Tabatabai @ 2025-07-01 22:43 UTC (permalink / raw)
  To: SeongJae Park
  Cc: Bijan Tabatabai, Andrew Morton, Bijan Tabatabai, damon,
	kernel-team, linux-kernel, linux-mm

On Sat, 21 Jun 2025 10:31:28 -0700 SeongJae Park <sj@kernel.org> wrote:

> Introduce a new struct, namely damos_migrate_dest, for specifying
> multiple DAMOS' migration destination nodes and their weights.
> 
> Signed-off-by: SeongJae Park <sj@kernel.org>
> ---
>  include/linux/damon.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/include/linux/damon.h b/include/linux/damon.h
> index bb58e36f019e..d60addd0b7c8 100644
> --- a/include/linux/damon.h
> +++ b/include/linux/damon.h
> @@ -447,6 +447,22 @@ struct damos_access_pattern {
>  	unsigned int max_age_region;
>  };
>  
> +/**
> + * struct damos_migrate_dest - Migration destination nodes and their weights.

Nit: Can this be renamed to damos_migrate_dests?
I think plural fits better because it stores a list of destinations.

Thanks,
Bijan

> + * @node_id_arr:	Array of migration destination node ids.
> + * @weight_arr:		Array of migration weights for @node_id_arr.
> + * @nr_dests:		Length of the @node_id_arr and @weight_arr arrays.
> + *
> + * @node_id_arr is an array of the ids of migration destination nodes.
> + * @weight_arr is an array of the weights for those.  The weights in
> + * @weight_arr are for nodes in @node_id_arr of same array index.
> + */
> +struct damos_migrate_dest {
> +	unsigned int *node_id_arr;
> +	unsigned int *weight_arr;
> +	size_t nr_dests;
> +};
> +
>  /**
>   * struct damos - Represents a Data Access Monitoring-based Operation Scheme.
>   * @pattern:		Access pattern of target regions.
> -- 
> 2.39.5


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights
  2025-07-01 22:39 ` [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights Bijan Tabatabai
@ 2025-07-02  0:23   ` SeongJae Park
  2025-07-02  5:23     ` SeongJae Park
  0 siblings, 1 reply; 12+ messages in thread
From: SeongJae Park @ 2025-07-02  0:23 UTC (permalink / raw)
  To: Bijan Tabatabai
  Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, damon, kernel-team,
	linux-kernel, linux-mm

On Tue,  1 Jul 2025 17:39:37 -0500 Bijan Tabatabai <bijan311@gmail.com> wrote:

> On Sat, 21 Jun 2025 10:31:27 -0700 SeongJae Park <sj@kernel.org> wrote:
> 
> > DAMOS_MIGRATE_{HOT,COLD} action can migrate pages to only single node.
> > It could be useful to allow it migrates pages to multiple nodes with
> > different weights.  A work for dynamic interleaving[1] is in progress.
> > We also discussed this could be useful for memory tiering, e.g., when we
> > want to move pages to multiple noes of same tier.
> > 
> > Extend the API and ABI interface for specifying the multiple destination
> > nodes and their weights.
> > 
> > Note that this RFC is a prototype of the interface change for Bijan's
> > interleaving work[1].  Hence this patch series is only implementing the
> > interface part, not the real implementation of the migration behavior.
> > 
> > [1] https://lore.kernel.org/20250620180458.5041-1-bijan311@gmail.com
> > [2] https://lore.kernel.org/20240408175228.91414-1-sj@kernel.org
> > 
> > SeongJae Park (4):
> >   mm/damon: add struct damos_migrate_dest
> >   mm/damon/core: add damos->migrate_dest field
> >   mm/damon/sysfs-schemes: implement DAMOS action destinations directory
> >   mm/damon/sysfs-schemes: set damos->migrate_dest
> > 
> >  include/linux/damon.h    |  29 ++++-
> >  mm/damon/core.c          |   4 +
> >  mm/damon/sysfs-schemes.c | 253 ++++++++++++++++++++++++++++++++++++++-
> >  3 files changed, 282 insertions(+), 4 deletions(-)
> > 
> > 
> > base-commit: 78745efafbb93197e476717385616ed57ea2df22
> > -- 
> > 2.39.5
> 
> Hi SeongJae,
> 
> Thanks for putting this patch together. Sorry for taking a while to
> respond to it.

No worry!

> 
> I am finishing up V3 of the interleave patchset using these patches. It
> has mostly worked great, but I noticed that damos->migrate_dest was not
> being updated in damos_commit(), so new weights would not be applied. This
> meant that you could not update the interleave weights by committing the
> damon state. I also saw that damos->target_nid was also not being updated
> here. I will will have a patch fixing

Nice catch, thank you for finding the bug and making the fix!

> this with the V3 of the interleave
> patchset that I will hopefully send out tomorrow.

I cannot wait, but please take your time! :)


Thanks,
SJ

[...]


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest
  2025-07-01 22:43   ` Bijan Tabatabai
@ 2025-07-02  0:25     ` SeongJae Park
  2025-07-02  1:43       ` Bijan Tabatabai
  0 siblings, 1 reply; 12+ messages in thread
From: SeongJae Park @ 2025-07-02  0:25 UTC (permalink / raw)
  To: Bijan Tabatabai
  Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, damon, kernel-team,
	linux-kernel, linux-mm

On Tue,  1 Jul 2025 17:43:30 -0500 Bijan Tabatabai <bijan311@gmail.com> wrote:

> On Sat, 21 Jun 2025 10:31:28 -0700 SeongJae Park <sj@kernel.org> wrote:
> 
> > Introduce a new struct, namely damos_migrate_dest, for specifying
> > multiple DAMOS' migration destination nodes and their weights.
> > 
> > Signed-off-by: SeongJae Park <sj@kernel.org>
> > ---
> >  include/linux/damon.h | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/include/linux/damon.h b/include/linux/damon.h
> > index bb58e36f019e..d60addd0b7c8 100644
> > --- a/include/linux/damon.h
> > +++ b/include/linux/damon.h
> > @@ -447,6 +447,22 @@ struct damos_access_pattern {
> >  	unsigned int max_age_region;
> >  };
> >  
> > +/**
> > + * struct damos_migrate_dest - Migration destination nodes and their weights.
> 
> Nit: Can this be renamed to damos_migrate_dests?
> I think plural fits better because it stores a list of destinations.

Makes sense, agreed.  I guess you will do that on your own when you add this on
your patch series?  Please let me know if you prefer different ways.  I could
also do that and send it again as RFC v2 of this series.


Thanks,
SJ

[...]


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest
  2025-07-02  0:25     ` SeongJae Park
@ 2025-07-02  1:43       ` Bijan Tabatabai
  2025-07-02  3:02         ` SeongJae Park
  0 siblings, 1 reply; 12+ messages in thread
From: Bijan Tabatabai @ 2025-07-02  1:43 UTC (permalink / raw)
  To: SeongJae Park
  Cc: Andrew Morton, Bijan Tabatabai, damon, kernel-team, linux-kernel,
	linux-mm

On Tue, Jul 1, 2025 at 7:25 PM SeongJae Park <sj@kernel.org> wrote:
>
> On Tue,  1 Jul 2025 17:43:30 -0500 Bijan Tabatabai <bijan311@gmail.com> wrote:
>
> > On Sat, 21 Jun 2025 10:31:28 -0700 SeongJae Park <sj@kernel.org> wrote:
> >
> > > Introduce a new struct, namely damos_migrate_dest, for specifying
> > > multiple DAMOS' migration destination nodes and their weights.
> > >
> > > Signed-off-by: SeongJae Park <sj@kernel.org>
> > > ---
> > >  include/linux/damon.h | 16 ++++++++++++++++
> > >  1 file changed, 16 insertions(+)
> > >
> > > diff --git a/include/linux/damon.h b/include/linux/damon.h
> > > index bb58e36f019e..d60addd0b7c8 100644
> > > --- a/include/linux/damon.h
> > > +++ b/include/linux/damon.h
> > > @@ -447,6 +447,22 @@ struct damos_access_pattern {
> > >     unsigned int max_age_region;
> > >  };
> > >
> > > +/**
> > > + * struct damos_migrate_dest - Migration destination nodes and their weights.
> >
> > Nit: Can this be renamed to damos_migrate_dests?
> > I think plural fits better because it stores a list of destinations.
>
> Makes sense, agreed.  I guess you will do that on your own when you add this on
> your patch series?  Please let me know if you prefer different ways.  I could
> also do that and send it again as RFC v2 of this series.

I can do this in my patch series.
Would the best way for me to do that be to send modified versions of
this patch series with my patches, or should I send one additional
patch that just renames the struct with my patches?

Bijan

[...]


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest
  2025-07-02  1:43       ` Bijan Tabatabai
@ 2025-07-02  3:02         ` SeongJae Park
  0 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2025-07-02  3:02 UTC (permalink / raw)
  To: Bijan Tabatabai
  Cc: SeongJae Park, Andrew Morton, Bijan Tabatabai, damon, kernel-team,
	linux-kernel, linux-mm

On Tue, 1 Jul 2025 20:43:46 -0500 Bijan Tabatabai <bijan311@gmail.com> wrote:

> On Tue, Jul 1, 2025 at 7:25 PM SeongJae Park <sj@kernel.org> wrote:
> >
> > On Tue,  1 Jul 2025 17:43:30 -0500 Bijan Tabatabai <bijan311@gmail.com> wrote:
> >
> > > On Sat, 21 Jun 2025 10:31:28 -0700 SeongJae Park <sj@kernel.org> wrote:
> > >
> > > > Introduce a new struct, namely damos_migrate_dest, for specifying
> > > > multiple DAMOS' migration destination nodes and their weights.
> > > >
> > > > Signed-off-by: SeongJae Park <sj@kernel.org>
> > > > ---
> > > >  include/linux/damon.h | 16 ++++++++++++++++
> > > >  1 file changed, 16 insertions(+)
> > > >
> > > > diff --git a/include/linux/damon.h b/include/linux/damon.h
> > > > index bb58e36f019e..d60addd0b7c8 100644
> > > > --- a/include/linux/damon.h
> > > > +++ b/include/linux/damon.h
> > > > @@ -447,6 +447,22 @@ struct damos_access_pattern {
> > > >     unsigned int max_age_region;
> > > >  };
> > > >
> > > > +/**
> > > > + * struct damos_migrate_dest - Migration destination nodes and their weights.
> > >
> > > Nit: Can this be renamed to damos_migrate_dests?
> > > I think plural fits better because it stores a list of destinations.
> >
> > Makes sense, agreed.  I guess you will do that on your own when you add this on
> > your patch series?  Please let me know if you prefer different ways.  I could
> > also do that and send it again as RFC v2 of this series.
> 
> I can do this in my patch series.

Thank you!

> Would the best way for me to do that be to send modified versions of
> this patch series with my patches, or should I send one additional
> patch that just renames the struct with my patches?

I think the former (making modification in place of this patch) is better, for
people who will read the commit log in future.  Please don't forget adding your
Singed-off-by: tag, and let me know if any help is needed!


Thanks,
SJ

[...]


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights
  2025-07-02  0:23   ` SeongJae Park
@ 2025-07-02  5:23     ` SeongJae Park
  0 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2025-07-02  5:23 UTC (permalink / raw)
  To: SeongJae Park
  Cc: Bijan Tabatabai, Andrew Morton, Bijan Tabatabai, damon,
	kernel-team, linux-kernel, linux-mm

On Tue,  1 Jul 2025 17:23:16 -0700 SeongJae Park <sj@kernel.org> wrote:

> On Tue,  1 Jul 2025 17:39:37 -0500 Bijan Tabatabai <bijan311@gmail.com> wrote:
> 
> > On Sat, 21 Jun 2025 10:31:27 -0700 SeongJae Park <sj@kernel.org> wrote:
[...]
> > I am finishing up V3 of the interleave patchset using these patches. It
> > has mostly worked great, but I noticed that damos->migrate_dest was not
> > being updated in damos_commit(), so new weights would not be applied. This
> > meant that you could not update the interleave weights by committing the
> > damon state. I also saw that damos->target_nid was also not being updated
> > here. I will will have a patch fixing
> 
> Nice catch, thank you for finding the bug and making the fix!
> 
> > this with the V3 of the interleave
> > patchset that I will hopefully send out tomorrow.
> 
> I cannot wait, but please take your time! :)

I just realized this series is missing documentation updates.  So I just
posted[1] RFC v2 of this series with two documentation update patches and
trivial commit messages wordsmithing.  Note that other parts are same to RFC
v1, including the damos_commit() bug and damos_migrate_dest name.

Please pick the version to your v3 of interleave patch series if possible.

[1] https://lore.kernel.org/20250702051558.54138-1-sj@kernel.org


Thanks,
SJ

[...]


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-07-02  5:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-21 17:31 [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights SeongJae Park
2025-06-21 17:31 ` [RFC PATCH 1/4] mm/damon: add struct damos_migrate_dest SeongJae Park
2025-07-01 22:43   ` Bijan Tabatabai
2025-07-02  0:25     ` SeongJae Park
2025-07-02  1:43       ` Bijan Tabatabai
2025-07-02  3:02         ` SeongJae Park
2025-06-21 17:31 ` [RFC PATCH 2/4] mm/damon/core: add damos->migrate_dest field SeongJae Park
2025-06-21 17:31 ` [RFC PATCH 3/4] mm/damon/sysfs-schemes: implement DAMOS action destinations directory SeongJae Park
2025-06-21 17:31 ` [RFC PATCH 4/4] mm/damon/sysfs-schemes: set damos->migrate_dest SeongJae Park
2025-07-01 22:39 ` [RFC PATCH 0/4] mm/damon: add DAMOS_MIGRATE_{HOT,COLD} destination nodes and weights Bijan Tabatabai
2025-07-02  0:23   ` SeongJae Park
2025-07-02  5:23     ` SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).