[RFC PATCH 2/9] mm/damon/core: initialize damos_quota_goal->last_psi_total
From: SJ Park
Date: Sat Aug 01 2026 - 13:40:46 EST
When DAMOS_QUOTA_SOME_MEM_PSI_US metric damos quota goal is set, the PSI
delta for the feedback loop is calculated using
damos_quota_goal->last_psi_total. It is not initialized at the
beginning. So the first iteration of the feedback loop uses the
uninitialized value and makes an unexpected starting point quota.
Initialize the value at the beginning of kdamond.
The user impact would be trivial because the issue impacts only the
initial iteration of the feedback loop. The feedback loop also has an
internal cap of the quota adjustment. The wrong adjustment will soon be
corrected over a few iterations.
The issue was discovered [1] by Sashiko.
[1] https://lore.kernel.org/20260718005316.89585-1-sj@xxxxxxxxxx
Fixes: 2dbb60f789cb ("mm/damon/core: implement PSI metric DAMOS quota goal")
Cc: <stable@xxxxxxxxxxxxxxx> # 6.9.x
Signed-off-by: SJ Park <sj@xxxxxxxxxx>
---
mm/damon/core.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index e2900d0c984c9..3bdbf4fbf7147 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3728,6 +3728,17 @@ static int kdamond_wait_activation(struct damon_ctx *ctx)
return -EBUSY;
}
+static void damos_init_quota_goal_last_psi(struct damos *s)
+{
+ struct damos_quota_goal *goal;
+
+ damos_for_each_quota_goal(goal, &s->quota) {
+ if (goal->metric != DAMOS_QUOTA_SOME_MEM_PSI_US)
+ continue;
+ goal->last_psi_total = damos_get_some_mem_psi_total();
+ }
+}
+
static void kdamond_init_ctx(struct damon_ctx *ctx)
{
unsigned long sample_interval = ctx->attrs.sample_interval ?
@@ -3744,6 +3755,7 @@ static void kdamond_init_ctx(struct damon_ctx *ctx)
damon_for_each_scheme(scheme, ctx) {
damos_set_next_apply_sis(scheme, ctx);
damos_set_filters_default_reject(scheme);
+ damos_init_quota_goal_last_psi(scheme);
}
}
--
2.47.3