* [RFC PATCH 1/8] mm/damon: add data structure for monitoring intervals auto-tuning
2025-02-13 1:44 [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
@ 2025-02-13 1:44 ` SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 2/8] mm/damon/core: implement " SeongJae Park
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: SeongJae Park @ 2025-02-13 1:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, kernel-team, linux-kernel, linux-mm
Add data structures for using DAMON sampling and aggregation intervals
automatic tuning aiming specific amount of access events per snapshot.
Specificaslly, define a data structure to define the tuning goal, namely
target ratio of positive access check samples, link it to monitoring
attributes data structure so that DAMON kernel API users can make the
request, and update parameters setup DAMON function to respect the new
data.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
include/linux/damon.h | 27 +++++++++++++++++++++++++++
mm/damon/core.c | 22 ++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 0adfc2f4ca75..4368ba1a942f 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -651,12 +651,38 @@ struct damon_call_control {
bool canceled;
};
+/**
+ * struct damon_intervals_goal - Monitoring intervals auto-tuning goal.
+ *
+ * @samples_bp: Positive access check samples ratio to achieve.
+ * @aggrs: Number of aggregations to acheive @samples_bp within.
+ * @min_sample_us: Minimum resulting sampling interval in microseconds.
+ * @max_sample_us: Maximum resulting sampling interval in microseconds.
+ *
+ * DAMON automatically tunes &damon_attrs->sample_interval and
+ * &damon_attrs->aggr_interval aiming the ratio in bp (1/10,000) of access
+ * check samples that shown positive result (was accessed) to total samples
+ * within @aggrs aggregations be same to @samples_bp. The logic increases
+ * &damon_attrs->aggr_interval and &damon_attrs->sampling_interval in same
+ * ratio if the current positive access samples ratio is lower than the target
+ * for each @aggrs aggregations, and vice versa.
+ *
+ * If @aggrs is zero, the tuning is disabled and hence this struct is ignored.
+ */
+struct damon_intervals_goal {
+ unsigned long samples_bp;
+ unsigned long aggrs;
+ unsigned long min_sample_us;
+ unsigned long max_sample_us;
+};
+
/**
* struct damon_attrs - Monitoring attributes for accuracy/overhead control.
*
* @sample_interval: The time between access samplings.
* @aggr_interval: The time between monitor results aggregations.
* @ops_update_interval: The time between monitoring operations updates.
+ * @intervals_goal: Intervals auto-tuning goal.
* @min_nr_regions: The minimum number of adaptive monitoring
* regions.
* @max_nr_regions: The maximum number of adaptive monitoring
@@ -676,6 +702,7 @@ struct damon_attrs {
unsigned long sample_interval;
unsigned long aggr_interval;
unsigned long ops_update_interval;
+ struct damon_intervals_goal intervals_goal;
unsigned long min_nr_regions;
unsigned long max_nr_regions;
};
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 38f545fea585..2fad800271a4 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -614,6 +614,25 @@ static void damon_update_monitoring_results(struct damon_ctx *ctx,
r, old_attrs, new_attrs);
}
+/*
+ * damon_valid_intervals_goal() - return if the intervals goal of @attrs is
+ * valid.
+ */
+static bool damon_valid_intervals_goal(struct damon_attrs *attrs)
+{
+ struct damon_intervals_goal *goal = &attrs->intervals_goal;
+
+ /* tuning is disabled */
+ if (!goal->aggrs)
+ return true;
+ if (goal->min_sample_us > goal->max_sample_us)
+ return false;
+ if (attrs->sample_interval < goal->min_sample_us ||
+ goal->max_sample_us < attrs->sample_interval)
+ return false;
+ return true;
+}
+
/**
* damon_set_attrs() - Set attributes for the monitoring.
* @ctx: monitoring context
@@ -634,6 +653,9 @@ int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs)
attrs->sample_interval : 1;
struct damos *s;
+ if (!damon_valid_intervals_goal(attrs))
+ return -EINVAL;
+
if (attrs->min_nr_regions < 3)
return -EINVAL;
if (attrs->min_nr_regions > attrs->max_nr_regions)
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread* [RFC PATCH 2/8] mm/damon/core: implement intervals auto-tuning
2025-02-13 1:44 [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 1/8] mm/damon: add data structure for monitoring intervals auto-tuning SeongJae Park
@ 2025-02-13 1:44 ` SeongJae Park
2025-02-25 18:14 ` SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 3/8] mm/damon/sysfs: implement intervals tuning goal directory SeongJae Park
` (6 subsequent siblings)
8 siblings, 1 reply; 11+ messages in thread
From: SeongJae Park @ 2025-02-13 1:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, kernel-team, linux-kernel, linux-mm
Implement the DAMON sampling and aggregation intervals auto-tuning
mechanism as designed on the cover letter of this patch series. The
mechanism reuses the feedback loop function for DAMOS quotas
auto-tuning. Unlike the DAMOS quotas auto-tuning use case, limit the
maximum decreasing amount after the adjustment to 50% of the current
value. This is because the intervals have no good merits at rapidly
reducing, and it is assumed the user will set the range of tunable
values not very wide.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
include/linux/damon.h | 16 ++++++++++
mm/damon/core.c | 68 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 84 insertions(+)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 4368ba1a942f..a205843fcf5a 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -705,6 +705,17 @@ struct damon_attrs {
struct damon_intervals_goal intervals_goal;
unsigned long min_nr_regions;
unsigned long max_nr_regions;
+/* private: internal use only */
+ /*
+ * @aggr_interval to @sample_interval ratio.
+ * Core-external components call damon_set_attrs() with &damon_attrs
+ * that this field is unset. In the case, damon_set_attrs() sets this
+ * field of resulting &damon_attrs. Core-internal components such as
+ * kdamond_tune_intervals() calls damon_set_attrs() with &damon_attrs
+ * that this field is set. In the case, damon_set_attrs() just keep
+ * it.
+ */
+ unsigned long aggr_samples;
};
/**
@@ -753,6 +764,11 @@ struct damon_ctx {
* update
*/
unsigned long next_ops_update_sis;
+ /*
+ * number of sample intervals that should be passed before next
+ * intervals tuning
+ */
+ unsigned long next_intervals_tune_sis;
/* for waiting until the execution of the kdamond_fn is started */
struct completion kdamond_started;
/* for scheme quotas prioritization */
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 2fad800271a4..227bdb856157 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -663,6 +663,10 @@ int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs)
if (attrs->sample_interval > attrs->aggr_interval)
return -EINVAL;
+ /* calls from core-external doesn't set this. */
+ if (!attrs->aggr_samples)
+ attrs->aggr_samples = attrs->aggr_interval / sample_interval;
+
ctx->next_aggregation_sis = ctx->passed_sample_intervals +
attrs->aggr_interval / sample_interval;
ctx->next_ops_update_sis = ctx->passed_sample_intervals +
@@ -1300,6 +1304,60 @@ static void kdamond_reset_aggregated(struct damon_ctx *c)
}
}
+static unsigned long damon_feed_loop_next_input(unsigned long last_input,
+ unsigned long score);
+
+static unsigned long damon_get_intervals_adaptation_bp(struct damon_ctx *c)
+{
+ struct damon_target *t;
+ struct damon_region *r;
+ unsigned long nr_regions = 0, access_samples = 0;
+ struct damon_intervals_goal *goal = &c->attrs.intervals_goal;
+ unsigned long max_samples, target_samples, score_bp;
+ unsigned long adaptation_bp;
+
+ damon_for_each_target(t, c) {
+ nr_regions = damon_nr_regions(t);
+ damon_for_each_region(r, t)
+ access_samples += r->nr_accesses;
+ }
+ max_samples = nr_regions * c->attrs.aggr_samples;
+ target_samples = max_samples * goal->samples_bp / 10000;
+ score_bp = access_samples * 10000 / target_samples;
+ adaptation_bp = damon_feed_loop_next_input(100000000, score_bp) /
+ 10000;
+ /*
+ * adaptaion_bp ranges from 1 to 20,000. Avoid too rapid reduction of
+ * the intervals by rescaling [1,10,000] to [5000, 10,000].
+ */
+ if (adaptation_bp <= 10000)
+ adaptation_bp = 5000 + adaptation_bp / 2;
+
+ return adaptation_bp;
+}
+
+static void kdamond_tune_intervals(struct damon_ctx *c)
+{
+ unsigned long adaptation_bp;
+ struct damon_attrs new_attrs;
+ struct damon_intervals_goal *goal;
+
+ adaptation_bp = damon_get_intervals_adaptation_bp(c);
+ if (adaptation_bp == 10000)
+ return;
+
+ new_attrs = c->attrs;
+ goal = &c->attrs.intervals_goal;
+ new_attrs.sample_interval = min(
+ c->attrs.sample_interval * adaptation_bp / 10000,
+ goal->max_sample_us);
+ new_attrs.sample_interval = max(new_attrs.sample_interval,
+ goal->min_sample_us);
+ new_attrs.aggr_interval = new_attrs.sample_interval *
+ c->attrs.aggr_samples;
+ damon_set_attrs(c, &new_attrs);
+}
+
static void damon_split_region_at(struct damon_target *t,
struct damon_region *r, unsigned long sz_r);
@@ -2204,6 +2262,8 @@ static void kdamond_init_intervals_sis(struct damon_ctx *ctx)
ctx->next_aggregation_sis = ctx->attrs.aggr_interval / sample_interval;
ctx->next_ops_update_sis = ctx->attrs.ops_update_interval /
sample_interval;
+ ctx->next_intervals_tune_sis = ctx->next_aggregation_sis *
+ ctx->attrs.intervals_goal.aggrs;
damon_for_each_scheme(scheme, ctx) {
apply_interval = scheme->apply_interval_us ?
@@ -2290,6 +2350,14 @@ static int kdamond_fn(void *data)
if (ctx->passed_sample_intervals >= next_aggregation_sis) {
ctx->next_aggregation_sis = next_aggregation_sis +
ctx->attrs.aggr_interval / sample_interval;
+ if (ctx->attrs.intervals_goal.aggrs &&
+ ctx->passed_sample_intervals >=
+ ctx->next_intervals_tune_sis) {
+ ctx->next_intervals_tune_sis +=
+ ctx->attrs.aggr_samples *
+ ctx->attrs.intervals_goal.aggrs;
+ kdamond_tune_intervals(ctx);
+ }
kdamond_reset_aggregated(ctx);
kdamond_split_regions(ctx);
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFC PATCH 2/8] mm/damon/core: implement intervals auto-tuning
2025-02-13 1:44 ` [RFC PATCH 2/8] mm/damon/core: implement " SeongJae Park
@ 2025-02-25 18:14 ` SeongJae Park
0 siblings, 0 replies; 11+ messages in thread
From: SeongJae Park @ 2025-02-25 18:14 UTC (permalink / raw)
To: SeongJae Park; +Cc: Andrew Morton, damon, kernel-team, linux-kernel, linux-mm
On Wed, 12 Feb 2025 17:44:32 -0800 SeongJae Park <sj@kernel.org> wrote:
> Implement the DAMON sampling and aggregation intervals auto-tuning
> mechanism as designed on the cover letter of this patch series. The
> mechanism reuses the feedback loop function for DAMOS quotas
> auto-tuning. Unlike the DAMOS quotas auto-tuning use case, limit the
> maximum decreasing amount after the adjustment to 50% of the current
> value. This is because the intervals have no good merits at rapidly
> reducing, and it is assumed the user will set the range of tunable
> values not very wide.
>
> Signed-off-by: SeongJae Park <sj@kernel.org>
> ---
> include/linux/damon.h | 16 ++++++++++
> mm/damon/core.c | 68 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 84 insertions(+)
[...]
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index 2fad800271a4..227bdb856157 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[...]
> +static unsigned long damon_get_intervals_adaptation_bp(struct damon_ctx *c)
> +{
> + struct damon_target *t;
> + struct damon_region *r;
> + unsigned long nr_regions = 0, access_samples = 0;
> + struct damon_intervals_goal *goal = &c->attrs.intervals_goal;
> + unsigned long max_samples, target_samples, score_bp;
> + unsigned long adaptation_bp;
> +
> + damon_for_each_target(t, c) {
> + nr_regions = damon_nr_regions(t);
This should use '+=' instead of '='.
> + damon_for_each_region(r, t)
> + access_samples += r->nr_accesses;
> + }
> + max_samples = nr_regions * c->attrs.aggr_samples;
> + target_samples = max_samples * goal->samples_bp / 10000;
> + score_bp = access_samples * 10000 / target_samples;
> + adaptation_bp = damon_feed_loop_next_input(100000000, score_bp) /
> + 10000;
> + /*
> + * adaptaion_bp ranges from 1 to 20,000. Avoid too rapid reduction of
> + * the intervals by rescaling [1,10,000] to [5000, 10,000].
> + */
> + if (adaptation_bp <= 10000)
> + adaptation_bp = 5000 + adaptation_bp / 2;
> +
> + return adaptation_bp;
> +}
[...]
> @@ -2204,6 +2262,8 @@ static void kdamond_init_intervals_sis(struct damon_ctx *ctx)
> ctx->next_aggregation_sis = ctx->attrs.aggr_interval / sample_interval;
> ctx->next_ops_update_sis = ctx->attrs.ops_update_interval /
> sample_interval;
> + ctx->next_intervals_tune_sis = ctx->next_aggregation_sis *
> + ctx->attrs.intervals_goal.aggrs;
>
> damon_for_each_scheme(scheme, ctx) {
> apply_interval = scheme->apply_interval_us ?
> @@ -2290,6 +2350,14 @@ static int kdamond_fn(void *data)
> if (ctx->passed_sample_intervals >= next_aggregation_sis) {
> ctx->next_aggregation_sis = next_aggregation_sis +
> ctx->attrs.aggr_interval / sample_interval;
> + if (ctx->attrs.intervals_goal.aggrs &&
> + ctx->passed_sample_intervals >=
> + ctx->next_intervals_tune_sis) {
> + ctx->next_intervals_tune_sis +=
> + ctx->attrs.aggr_samples *
> + ctx->attrs.intervals_goal.aggrs;
> + kdamond_tune_intervals(ctx);
> + }
kdamond_tune_intervals() may increase ctx->next_aggregation_sis inside
damon_set_attrs(). So it should be called before the above
ctx->next_ops_update_sis update.
>
> kdamond_reset_aggregated(ctx);
> kdamond_split_regions(ctx);
> --
> 2.39.5
>
Thanks,
SJ
^ permalink raw reply [flat|nested] 11+ messages in thread
* [RFC PATCH 3/8] mm/damon/sysfs: implement intervals tuning goal directory
2025-02-13 1:44 [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 1/8] mm/damon: add data structure for monitoring intervals auto-tuning SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 2/8] mm/damon/core: implement " SeongJae Park
@ 2025-02-13 1:44 ` SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 4/8] mm/damon/sysfs: commit intervals tuning goal SeongJae Park
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: SeongJae Park @ 2025-02-13 1:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, kernel-team, linux-kernel, linux-mm
Implement DAMON sysfs interface directory and its files for setting
DAMON sampling and aggregation intervals auto-tuning goal. Nearly all
kernel API data structures that newly introduced for this new feature
are directly exposed.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 189 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 189 insertions(+)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index deeab04d3b46..ff774cc19d1f 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -408,6 +408,164 @@ static const struct kobj_type damon_sysfs_targets_ktype = {
.default_groups = damon_sysfs_targets_groups,
};
+/*
+ * intervals goal directory
+ */
+
+struct damon_sysfs_intervals_goal {
+ struct kobject kobj;
+ unsigned long samples_bp;
+ unsigned long aggrs;
+ unsigned long min_sample_us;
+ unsigned long max_sample_us;
+};
+
+static struct damon_sysfs_intervals_goal *damon_sysfs_intervals_goal_alloc(
+ unsigned long samples_bp, unsigned long aggrs,
+ unsigned long min_sample_us, unsigned long max_sample_us)
+{
+ struct damon_sysfs_intervals_goal *goal = kmalloc(sizeof(*goal),
+ GFP_KERNEL);
+
+ if (!goal)
+ return NULL;
+
+ goal->kobj = (struct kobject){};
+ goal->samples_bp = samples_bp;
+ goal->aggrs = aggrs;
+ goal->min_sample_us = min_sample_us;
+ goal->max_sample_us = max_sample_us;
+ return goal;
+}
+
+static ssize_t samples_bp_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct damon_sysfs_intervals_goal *goal = container_of(kobj,
+ struct damon_sysfs_intervals_goal, kobj);
+
+ return sysfs_emit(buf, "%lu\n", goal->samples_bp);
+}
+
+static ssize_t samples_bp_store(struct kobject *kobj,
+ struct kobj_attribute *attr, const char *buf, size_t count)
+{
+ struct damon_sysfs_intervals_goal *goal = container_of(kobj,
+ struct damon_sysfs_intervals_goal, kobj);
+ unsigned long nr;
+ int err = kstrtoul(buf, 0, &nr);
+
+ if (err)
+ return err;
+
+ goal->samples_bp = nr;
+ return count;
+}
+
+static ssize_t aggrs_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct damon_sysfs_intervals_goal *goal = container_of(kobj,
+ struct damon_sysfs_intervals_goal, kobj);
+
+ return sysfs_emit(buf, "%lu\n", goal->aggrs);
+}
+
+static ssize_t aggrs_store(struct kobject *kobj,
+ struct kobj_attribute *attr, const char *buf, size_t count)
+{
+ struct damon_sysfs_intervals_goal *goal = container_of(kobj,
+ struct damon_sysfs_intervals_goal, kobj);
+ unsigned long nr;
+ int err = kstrtoul(buf, 0, &nr);
+
+ if (err)
+ return err;
+
+ goal->aggrs = nr;
+ return count;
+}
+
+static ssize_t min_sample_us_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct damon_sysfs_intervals_goal *goal = container_of(kobj,
+ struct damon_sysfs_intervals_goal, kobj);
+
+ return sysfs_emit(buf, "%lu\n", goal->min_sample_us);
+}
+
+static ssize_t min_sample_us_store(struct kobject *kobj,
+ struct kobj_attribute *attr, const char *buf, size_t count)
+{
+ struct damon_sysfs_intervals_goal *goal = container_of(kobj,
+ struct damon_sysfs_intervals_goal, kobj);
+ unsigned long nr;
+ int err = kstrtoul(buf, 0, &nr);
+
+ if (err)
+ return err;
+
+ goal->min_sample_us = nr;
+ return count;
+}
+
+static ssize_t max_sample_us_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ struct damon_sysfs_intervals_goal *goal = container_of(kobj,
+ struct damon_sysfs_intervals_goal, kobj);
+
+ return sysfs_emit(buf, "%lu\n", goal->max_sample_us);
+}
+
+static ssize_t max_sample_us_store(struct kobject *kobj,
+ struct kobj_attribute *attr, const char *buf, size_t count)
+{
+ struct damon_sysfs_intervals_goal *goal = container_of(kobj,
+ struct damon_sysfs_intervals_goal, kobj);
+ unsigned long nr;
+ int err = kstrtoul(buf, 0, &nr);
+
+ if (err)
+ return err;
+
+ goal->max_sample_us = nr;
+ return count;
+}
+
+static void damon_sysfs_intervals_goal_release(struct kobject *kobj)
+{
+ kfree(container_of(kobj, struct damon_sysfs_intervals_goal, kobj));
+}
+
+static struct kobj_attribute damon_sysfs_intervals_goal_samples_bp_attr =
+ __ATTR_RW_MODE(samples_bp, 0600);
+
+static struct kobj_attribute damon_sysfs_intervals_goal_aggrs_attr =
+ __ATTR_RW_MODE(aggrs, 0600);
+
+static struct kobj_attribute damon_sysfs_intervals_goal_min_sample_us_attr =
+ __ATTR_RW_MODE(min_sample_us, 0600);
+
+static struct kobj_attribute damon_sysfs_intervals_goal_max_sample_us_attr =
+ __ATTR_RW_MODE(max_sample_us, 0600);
+
+static struct attribute *damon_sysfs_intervals_goal_attrs[] = {
+ &damon_sysfs_intervals_goal_samples_bp_attr.attr,
+ &damon_sysfs_intervals_goal_aggrs_attr.attr,
+ &damon_sysfs_intervals_goal_min_sample_us_attr.attr,
+ &damon_sysfs_intervals_goal_max_sample_us_attr.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(damon_sysfs_intervals_goal);
+
+static const struct kobj_type damon_sysfs_intervals_goal_ktype = {
+ .release = damon_sysfs_intervals_goal_release,
+ .sysfs_ops = &kobj_sysfs_ops,
+ .default_groups = damon_sysfs_intervals_goal_groups,
+};
+
/*
* intervals directory
*/
@@ -417,6 +575,7 @@ struct damon_sysfs_intervals {
unsigned long sample_us;
unsigned long aggr_us;
unsigned long update_us;
+ struct damon_sysfs_intervals_goal *intervals_goal;
};
static struct damon_sysfs_intervals *damon_sysfs_intervals_alloc(
@@ -436,6 +595,32 @@ static struct damon_sysfs_intervals *damon_sysfs_intervals_alloc(
return intervals;
}
+static int damon_sysfs_intervals_add_dirs(struct damon_sysfs_intervals *intervals)
+{
+ struct damon_sysfs_intervals_goal *goal;
+ int err;
+
+ goal = damon_sysfs_intervals_goal_alloc(0, 0, 0, 0);
+ if (!goal)
+ return -ENOMEM;
+
+ err = kobject_init_and_add(&goal->kobj,
+ &damon_sysfs_intervals_goal_ktype, &intervals->kobj,
+ "intervals_goal");
+ if (err) {
+ kobject_put(&goal->kobj);
+ intervals->intervals_goal = NULL;
+ return err;
+ }
+ intervals->intervals_goal = goal;
+ return 0;
+}
+
+static void damon_sysfs_intervals_rm_dirs(struct damon_sysfs_intervals *intervals)
+{
+ kobject_put(&intervals->intervals_goal->kobj);
+}
+
static ssize_t sample_us_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
@@ -569,6 +754,9 @@ static int damon_sysfs_attrs_add_dirs(struct damon_sysfs_attrs *attrs)
err = kobject_init_and_add(&intervals->kobj,
&damon_sysfs_intervals_ktype, &attrs->kobj,
"intervals");
+ if (err)
+ goto put_intervals_out;
+ err = damon_sysfs_intervals_add_dirs(intervals);
if (err)
goto put_intervals_out;
attrs->intervals = intervals;
@@ -599,6 +787,7 @@ static int damon_sysfs_attrs_add_dirs(struct damon_sysfs_attrs *attrs)
static void damon_sysfs_attrs_rm_dirs(struct damon_sysfs_attrs *attrs)
{
kobject_put(&attrs->nr_regions_range->kobj);
+ damon_sysfs_intervals_rm_dirs(attrs->intervals);
kobject_put(&attrs->intervals->kobj);
}
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread* [RFC PATCH 4/8] mm/damon/sysfs: commit intervals tuning goal
2025-02-13 1:44 [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
` (2 preceding siblings ...)
2025-02-13 1:44 ` [RFC PATCH 3/8] mm/damon/sysfs: implement intervals tuning goal directory SeongJae Park
@ 2025-02-13 1:44 ` SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 5/8] mm/damon/sysfs: implement a command to update auto-tuned monitoring intervals SeongJae Park
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: SeongJae Park @ 2025-02-13 1:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, kernel-team, linux-kernel, linux-mm
Connect DAMON sysfs interface for sampling and aggregation intervals
auto-tuning with DAMON core API, so that users can really use the
feature using the sysfs files.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index ff774cc19d1f..f9bfe9ea0ae6 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1273,11 +1273,18 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx,
struct damon_sysfs_attrs *sys_attrs)
{
struct damon_sysfs_intervals *sys_intervals = sys_attrs->intervals;
+ struct damon_sysfs_intervals_goal *sys_goal =
+ sys_intervals->intervals_goal;
struct damon_sysfs_ul_range *sys_nr_regions =
sys_attrs->nr_regions_range;
struct damon_attrs attrs = {
.sample_interval = sys_intervals->sample_us,
.aggr_interval = sys_intervals->aggr_us,
+ .intervals_goal = {
+ .samples_bp = sys_goal->samples_bp,
+ .aggrs = sys_goal->aggrs,
+ .min_sample_us = sys_goal->min_sample_us,
+ .max_sample_us = sys_goal->max_sample_us},
.ops_update_interval = sys_intervals->update_us,
.min_nr_regions = sys_nr_regions->min,
.max_nr_regions = sys_nr_regions->max,
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread* [RFC PATCH 5/8] mm/damon/sysfs: implement a command to update auto-tuned monitoring intervals
2025-02-13 1:44 [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
` (3 preceding siblings ...)
2025-02-13 1:44 ` [RFC PATCH 4/8] mm/damon/sysfs: commit intervals tuning goal SeongJae Park
@ 2025-02-13 1:44 ` SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 6/8] Docs/mm/damon/design: document for intervals auto-tuning SeongJae Park
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: SeongJae Park @ 2025-02-13 1:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, kernel-team, linux-kernel, linux-mm
DAMON kernel API callers can show auto-tuned sampling and aggregation
intervals from the monmitoring attributes data structure. That can be
useful for debugging or tuning of the feature. DAMON user-space ABI
users has no way to see that, though. Implement a new DAMON sysfs
interface kdamond state command, namely 'update_tuned_intervals', for
the purpose. Once the command is written to the kdamond state file, the
tuned sampling and aggregation intervals will be updated to the
corresponding sysfs interface.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index f9bfe9ea0ae6..b1829ee67762 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1213,6 +1213,11 @@ enum damon_sysfs_cmd {
* effective size quota of the scheme in bytes.
*/
DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS,
+ /*
+ * @DAMON_SYSFS_CMD_UPDATE_TUNED_INTERVALS: Update the tuned monitoring
+ * intevals.
+ */
+ DAMON_SYSFS_CMD_UPDATE_TUNED_INTERVALS,
/*
* @NR_DAMON_SYSFS_CMDS: Total number of DAMON sysfs commands.
*/
@@ -1230,6 +1235,7 @@ static const char * const damon_sysfs_cmd_strs[] = {
"update_schemes_tried_regions",
"clear_schemes_tried_regions",
"update_schemes_effective_quotas",
+ "update_tuned_intervals",
};
/*
@@ -1502,6 +1508,17 @@ static int damon_sysfs_upd_schemes_effective_quotas(void *data)
return 0;
}
+static int damon_sysfs_upd_tuned_intervals(void *data)
+{
+ struct damon_sysfs_kdamond *kdamond = data;
+ struct damon_ctx *ctx = kdamond->damon_ctx;
+
+ kdamond->contexts->contexts_arr[0]->attrs->intervals->sample_us =
+ ctx->attrs.sample_interval;
+ kdamond->contexts->contexts_arr[0]->attrs->intervals->aggr_us =
+ ctx->attrs.aggr_interval;
+ return 0;
+}
/*
* damon_sysfs_cmd_request_callback() - DAMON callback for handling requests.
@@ -1723,6 +1740,9 @@ static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd,
return damon_sysfs_damon_call(
damon_sysfs_upd_schemes_effective_quotas,
kdamond);
+ case DAMON_SYSFS_CMD_UPDATE_TUNED_INTERVALS:
+ return damon_sysfs_damon_call(
+ damon_sysfs_upd_tuned_intervals, kdamond);
default:
break;
}
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread* [RFC PATCH 6/8] Docs/mm/damon/design: document for intervals auto-tuning
2025-02-13 1:44 [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
` (4 preceding siblings ...)
2025-02-13 1:44 ` [RFC PATCH 5/8] mm/damon/sysfs: implement a command to update auto-tuned monitoring intervals SeongJae Park
@ 2025-02-13 1:44 ` SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 7/8] Docs/ABI/damon: document intervals auto-tuning ABI SeongJae Park
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: SeongJae Park @ 2025-02-13 1:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Jonathan Corbet, damon,
kernel-team, linux-doc, linux-kernel, linux-mm
Document DAMON sampling and aggregation intervals auto-tuning design.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/mm/damon/design.rst | 34 +++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index e28c6a1b40ae..c8e906ac3965 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -313,6 +313,10 @@ sufficient for the given purpose, it shouldn't be unnecessarily further
lowered. It is recommended to be set proportional to ``aggregation interval``.
By default, the ratio is set as ``1/20``, and it is still recommended.
+Based on the manual tuning guide, DAMON provides more intuitive knob-based
+intervals auto tuning mechanism. Please refer to :ref:`the design document of
+the feature <damon_design_monitoring_intervals_autotuning>` for detail.
+
Refer to below documents for an example tuning based on the above guide.
.. toctree::
@@ -321,6 +325,36 @@ Refer to below documents for an example tuning based on the above guide.
monitoring_intervals_tuning_example
+.. _damon_design_monitoring_intervals_autotuning:
+
+Monitoring Intervals Auto-tuning
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+DAMON provides automatic tuning of the ``sampling interval`` and ``aggregation
+interval`` based on the :ref:`the tuning guide idea
+<damon_design_monitoring_params_tuning_guide>`. The tuning mechanism allows
+users to set the aimed amount of heats to observe with DAMON within given time
+interval. The target can be specified by the user as a ratio of access check
+samples that gave positive result to the total samples (``samples_bp``) that
+measured within a given number of aggregations (``aggrs``). The mechanism
+calculates the ratio of access check samples for ``aggrs`` aggregations, and
+increases or decrease the ``sampleing interval`` and ``aggregation interval``
+in same ratio, if the samples ratio is lower or higher than the target,
+respectively. The ratio of the intervals change is decided in proportion to
+the distance between current samples ratio and the target ratio.
+
+The user can further set the minimum and maximum ``sampling interval`` that can
+be set by the tuning mechanism using two parameters (``min_sample_us`` and
+``max_sample_us``). Because the tuning mechanism changes ``sampling interval``
+and ``aggregation interval`` in same ratio always, the minimum and maximum
+``aggregation interval`` after each of the tuning changes can automatically set
+together.
+
+The tuning is turned off by default, and need to be set explicitly by the user.
+As a rule of thumbs and the Parreto principle, 20% access samples ratio target
+is recommended.
+
+
.. _damon_design_damos:
Operation Schemes
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread* [RFC PATCH 7/8] Docs/ABI/damon: document intervals auto-tuning ABI
2025-02-13 1:44 [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
` (5 preceding siblings ...)
2025-02-13 1:44 ` [RFC PATCH 6/8] Docs/mm/damon/design: document for intervals auto-tuning SeongJae Park
@ 2025-02-13 1:44 ` SeongJae Park
2025-02-13 1:44 ` [RFC PATCH 8/8] Docs/admin-guide/mm/damon/usage: add intervals_goal directory on the hierarchy SeongJae Park
2025-02-21 1:09 ` [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
8 siblings, 0 replies; 11+ messages in thread
From: SeongJae Park @ 2025-02-13 1:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, kernel-team, linux-kernel, linux-mm
Document the DAMON user-space ABI for DAMON sampling and aggregation
intervals auto-tuning.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
.../ABI/testing/sysfs-kernel-mm-damon | 30 +++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon
index ccd13ca668c8..77603b5f7c0c 100644
--- a/Documentation/ABI/testing/sysfs-kernel-mm-damon
+++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon
@@ -91,6 +91,36 @@ Description: Writing a value to this file sets the update interval of the
DAMON context in microseconds as the value. Reading this file
returns the value.
+What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/samples_bp
+Date: Feb 2025
+Contact: SeongJae Park <sj@kernel.org>
+Description: Writing a value to this file sets the monitoring intervals
+ auto-tuning target positive access check samples ratio within
+ the given time interval (aggrs in same directory), in bp
+ (1/10,000). Reading this file returns the value.
+
+What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/aggrs
+Date: Feb 2025
+Contact: SeongJae Park <sj@kernel.org>
+Description: Writing a value to this file sets the time interval to achieve
+ the monitoring intervals auto-tuning target positive access
+ check samples ratio (samples_bp in same directory) within.
+ Reading this file returns the value.
+
+What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/min_sample_us
+Date: Feb 2025
+Contact: SeongJae Park <sj@kernel.org>
+Description: Writing a value to this file sets the minimum value of
+ auto-tuned sampling interval in microseconds. Reading this
+ file returns the value.
+
+What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/intervals/intrvals_goal/max_sample_us
+Date: Feb 2025
+Contact: SeongJae Park <sj@kernel.org>
+Description: Writing a value to this file sets the maximum value of
+ auto-tuned sampling interval in microseconds. Reading this
+ file returns the value.
+
What: /sys/kernel/mm/damon/admin/kdamonds/<K>/contexts/<C>/monitoring_attrs/nr_regions/min
WDate: Mar 2022
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread* [RFC PATCH 8/8] Docs/admin-guide/mm/damon/usage: add intervals_goal directory on the hierarchy
2025-02-13 1:44 [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
` (6 preceding siblings ...)
2025-02-13 1:44 ` [RFC PATCH 7/8] Docs/ABI/damon: document intervals auto-tuning ABI SeongJae Park
@ 2025-02-13 1:44 ` SeongJae Park
2025-02-21 1:09 ` [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
8 siblings, 0 replies; 11+ messages in thread
From: SeongJae Park @ 2025-02-13 1:44 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, Jonathan Corbet, damon,
kernel-team, linux-doc, linux-kernel, linux-mm
Document DAMON sysfs interface usage for DAMON sampling and aggregation
intervals auto-tuning.
Signed-off-by: SeongJae Park <sj@kernel.org>
---
Documentation/admin-guide/mm/damon/usage.rst | 25 ++++++++++++++++++++
Documentation/mm/damon/design.rst | 4 ++++
2 files changed, 29 insertions(+)
diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst
index 51af66c208c5..8970efce32f0 100644
--- a/Documentation/admin-guide/mm/damon/usage.rst
+++ b/Documentation/admin-guide/mm/damon/usage.rst
@@ -64,6 +64,7 @@ comma (",").
│ │ │ │ :ref:`0 <sysfs_context>`/avail_operations,operations
│ │ │ │ │ :ref:`monitoring_attrs <sysfs_monitoring_attrs>`/
│ │ │ │ │ │ intervals/sample_us,aggr_us,update_us
+ │ │ │ │ │ │ │ intervals_goal/samples_bp,aggrs,min_sample_us,max_sample_us
│ │ │ │ │ │ nr_regions/min,max
│ │ │ │ │ :ref:`targets <sysfs_targets>`/nr_targets
│ │ │ │ │ │ :ref:`0 <sysfs_target>`/pid_target
@@ -132,6 +133,11 @@ Users can write below commands for the kdamond to the ``state`` file.
- ``off``: Stop running.
- ``commit``: Read the user inputs in the sysfs files except ``state`` file
again.
+- ``update_tuned_intervals``: Update the contents of ``sample_us`` and
+ ``aggr_us`` files of the kdamond with the auto-tuning applied ``sampling
+ interval`` and ``aggregation interval`` for the files. Please refer to
+ :ref:`intervals_goal section <damon_usage_sysfs_monitoring_intervals_goal>`
+ for more details.
- ``commit_schemes_quota_goals``: Read the DAMON-based operation schemes'
:ref:`quota goals <sysfs_schemes_quota_goals>`.
- ``update_schemes_stats``: Update the contents of stats files for each
@@ -213,6 +219,25 @@ writing to and rading from the files.
For more details about the intervals and monitoring regions range, please refer
to the Design document (:doc:`/mm/damon/design`).
+.. _damon_usage_sysfs_monitoring_intervals_goal:
+
+contexts/<N>/monitoring_attrs/intervals/intervals_goal/
+-------------------------------------------------------
+
+Under the ``intervals`` directory, one directory for automated tuning of
+``sample_us`` and ``aggr_us``, namely ``intervals_goal`` directory also exists.
+Under the directory, four files for the auto-tuning control, namely
+``samples_bp``, ``aggrs``, ``min_sample_us`` and ``max_sample_us`` exist.
+Please refer to the :ref:`design document of the feature
+<damon_design_monitoring_intervals_autotuning>` for the internal of the tuning
+mechanism. Reading and writing the four files under ``intervals_goal``
+directory shows and updates the tuning parameters that described in the
+:ref:design doc <damon_design_monitoring_intervals_autotuning>` with the same
+names. The tuning starts with the user-set ``sample_us`` and ``aggr_us``. The
+tuning-applied current values of the two intervals can be read from the
+``sample_us`` and ``aggr_us`` files after writing ``update_tuned_intervals`` to
+the ``state`` file.
+
.. _sysfs_targets:
contexts/<N>/targets/
diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst
index c8e906ac3965..940409abc23f 100644
--- a/Documentation/mm/damon/design.rst
+++ b/Documentation/mm/damon/design.rst
@@ -354,6 +354,10 @@ The tuning is turned off by default, and need to be set explicitly by the user.
As a rule of thumbs and the Parreto principle, 20% access samples ratio target
is recommended.
+To know how user-space can use this feature via :ref:`DAMON sysfs interface
+<sysfs_interface>`, refer to :ref:`intervals_goal <sysfs_scheme>` part of
+the documentation.
+
.. _damon_design_damos:
--
2.39.5
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval
2025-02-13 1:44 [RFC PATCH 0/8] mm/damon: auto-tune aggregation interval SeongJae Park
` (7 preceding siblings ...)
2025-02-13 1:44 ` [RFC PATCH 8/8] Docs/admin-guide/mm/damon/usage: add intervals_goal directory on the hierarchy SeongJae Park
@ 2025-02-21 1:09 ` SeongJae Park
8 siblings, 0 replies; 11+ messages in thread
From: SeongJae Park @ 2025-02-21 1:09 UTC (permalink / raw)
To: SeongJae Park
Cc: Andrew Morton, Jonathan Corbet, damon, kernel-team, linux-doc,
linux-kernel, linux-mm
On Wed, 12 Feb 2025 17:44:30 -0800 SeongJae Park <sj@kernel.org> wrote:
> DAMON requires time-consuming and repetitive aggregation interval
> tuning. Introduce a feature for automating it using a feedback loop
> that aims an amount of observed access events, like auto-exposing
> cameras.
[...]
> Aim-oriented Feedback-driven Auto-Tuning
> =========================================
[...]
> we design an automation of aggregation
> interval tuning, in a way similar to that of camera auto-exposure
> feature. It defines the amount of interesting information as the ratio
> of captured access events to total capturing attempts of single snapshot,
> or more technically speaking, the ratio of positive access check samples
> to total samples within the aggregation interval. It allows the users
> to set the target value of the ratio. Once the target is set, the
> automation periodically measures the current value of the ratio and
> increase or decrease the aggregation interval if the ratio value is
> lower or higher than the target. The amount of the change is proportion
> to the distance between current value and the target value.
>
> To avoid auto-tuning goes too long way, let users set minimum and
> maximum aggregation interval time. Changing only aggregation interval
> while sampling interval is kept make the maximum level of access
> frequency in each snapshot, or discernment of regions inconsistent.
> Also, unnecessarily short sampling interval causes meaningless
> monitoring overhed. The automation therefore adjusts the sampling
> interval together with aggregation interval, while keeping the ratio
> between the two intervals. Users can set the ratio, or the discernment.
I received a concern about a corner case of the metric (positive access check
samples ratio) offline. In short, DAMON might find a few discontiguous
extremely hot and small regions and let those achieve the target positive
access check samples ratio, even with very short aggregation interval.
I was able to show the corner case indeed. It started to increase the
aggregatiopn interval at the beginning, but it gets reduced as time goes by and
region boundaries get converged. It was showing a few very hot 4-8 KiB memory
regions that showing maximum nr_accesses even with the low aggregation
interval. They made the target samples ratio on their own. So most of other
regions looked pretty cold.
This means the logic is implemented and designed and work as expected. But,
the resulting snapshot is not what we wanted. We wanted the snapshot to show
practical amount of differences between regions that we can utilize for better
memory management, not the dark and cold space with a few flaming but tiny red
dots. It might seem ok if that's the true access pattern of the workload. And
that's true. Some workloads would have really biased access pattern that we
cannot make useful memory management decision. But, if that's the case,
according to our tuning theory, the logic should have maximum aggregation
interval.
I also worried about this corner case when starting the design. I hence
considered[1] having two feedback loop goals, namely the positive access check
samples ratio and total size of >0 nr_accesses regions. But I ended up making
this RFC with the first metric only for starting with simpler design. I'm
still bit skeptical about having multiple goals, and looking for a better
single metric.
Now I'm thinking observed total access events ratio might make sense to be used
instead. That is, DAMON's regions concept assumes every byte of single region
shares similar access frequency. For example, having a DAMON region of size 4
KiB and nr_accesses 20 can be interpreted as DAMON has observed 4 * 1024 * 20
access events. For example, below diff on top of this patch series would
explain what I'm saying about better than my text.
I will do more tests and share more findings on this thread until I post the
next spin of this patch series.
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 3c1f401fcbbb..0635882751cc 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1428,19 +1428,20 @@ static unsigned long damon_get_intervals_adaptation_bp(struct damon_ctx *c)
{
struct damon_target *t;
struct damon_region *r;
- unsigned long nr_regions = 0, access_samples = 0;
+ unsigned long sz_regions = 0, heats = 0;
struct damon_intervals_goal *goal = &c->attrs.intervals_goal;
- unsigned long max_samples, target_samples, score_bp;
+ unsigned long max_heats, target_heats, score_bp;
unsigned long adaptation_bp;
damon_for_each_target(t, c) {
- nr_regions = damon_nr_regions(t);
- damon_for_each_region(r, t)
- access_samples += r->nr_accesses;
+ damon_for_each_region(r, t) {
+ sz_regions += r->ar.end - r->ar.start;
+ heats += (r->ar.end - r->ar.start) * r->nr_accesses;
+ }
}
- max_samples = nr_regions * c->attrs.aggr_samples;
- target_samples = max_samples * goal->samples_bp / 10000;
- score_bp = access_samples * 10000 / target_samples;
+ max_heats = sz_regions * c->attrs.aggr_samples;
+ target_heats = max_heats * goal->samples_bp / 10000;
+ score_bp = heats * 10000 / target_heats;
adaptation_bp = damon_feed_loop_next_input(100000000, score_bp) /
10000;
/*
[1] https://git.kernel.org/sj/damon-hack/c/b01238ded409828bc427cd037095686483d39faf
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 11+ messages in thread