[RFC PATCH v1.1 2/9] mm/damon/core: initialize damos_quota_goal->last_psi_total
SJ Park <[email protected]> Sun, 2 Aug 2026 09:26:23 -0700
| Newsgroups | dev.linux.lists.damon,org.kernel.vger.linux-kernel,org.kernel.vger.stable,org.kvack.linux-mm |
|---|---|
| Message-ID | <[email protected]> |
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/[email protected] Fixes: 2dbb60f789cb ("mm/damon/core: implement PSI metric DAMOS quota goal") Cc: <[email protected]> # 6.9.x Signed-off-by: SJ Park <[email protected]> --- 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