[RFC PATCH 1/7] mm/damon/core: introduce damos_quota_goal->complement

From: SJ Park

Date: Fri Sep 18 2026 - 11:06:02 EST


Introduce damos_quota_goal->complement for specifying whether to use a
complemented value of the given goal target metric. Add the field to
the data structure and implement essential core support. Handle the
flag in the quota goal commit and current quota goal metric value
retrieval.

Signed-off-by: SJ Park <sj@xxxxxxxxxx>
---
include/linux/damon.h | 2 ++
mm/damon/core.c | 14 ++++++++++++++
2 files changed, 16 insertions(+)

diff --git a/include/linux/damon.h b/include/linux/damon.h
index 844b175120f09..78b227875287d 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -175,6 +175,7 @@ enum damos_quota_goal_metric {
/**
* struct damos_quota_goal - DAMOS scheme quota auto-tuning goal.
* @metric: Metric to be used for representing the goal.
+ * @complement: Use the complement of the metric.
* @target_value: Target value of @metric to achieve with the tuning.
* @current_value: Current value of @metric.
* @nid: Node id.
@@ -197,6 +198,7 @@ enum damos_quota_goal_metric {
*/
struct damos_quota_goal {
enum damos_quota_goal_metric metric;
+ bool complement;
unsigned long target_value;
unsigned long current_value;
/* metric-dependent fields */
diff --git a/mm/damon/core.c b/mm/damon/core.c
index 4687b909d42c9..98cf6bab9fc6e 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1224,6 +1224,7 @@ static int damos_commit_quota_goal(
if (!src->target_value)
return -EINVAL;
dst->metric = src->metric;
+ dst->complement = src->complement;
dst->target_value = src->target_value;
if (dst->metric == DAMOS_QUOTA_USER_INPUT)
dst->current_value = src->current_value;
@@ -3239,6 +3240,19 @@ static void damos_set_quota_goal_current_value(struct damon_ctx *c,
default:
break;
}
+ if (!goal->complement)
+ return;
+
+ /* updte current_value to complemented value */
+
+ /* for user_input, users set complemented value on their own */
+ if (goal->metric == DAMOS_QUOTA_USER_INPUT)
+ return;
+ if (goal->metric == DAMOS_QUOTA_SOME_MEM_PSI_US)
+ goal->current_value = s->quota.reset_interval * 1000 -
+ goal->current_value;
+ else
+ goal->current_value = 10000 - goal->current_value;
}

/* Return the highest score since it makes schemes least aggressive */
--
2.47.3