[PATCH] mm/damon/core: recalculate intervals tuning deadline on attrs update

From: niecheng

Date: Thu May 14 2026 - 03:50:16 EST


damon_set_attrs() refreshes next_aggregation_sis and
next_ops_update_sis for online monitoring attribute updates, but it
does not refresh next_intervals_tune_sis.

Because of that, enabling intervals auto-tuning via an online attrs
commit can leave next_intervals_tune_sis stale. If a context starts
with intervals_goal.aggrs == 0 and later updates attrs online to set it
non-zero, kdamond_fn() can treat the tuning deadline as already expired
and tune the intervals earlier than intended.

This has been possible since the intervals auto-tuning feature was
introduced, because that commit initialized the deadline at kdamond
start but did not refresh it on later attrs updates.

Fix it by recalculating next_intervals_tune_sis in damon_set_attrs(),
using the same passed_sample_intervals-based schedule as the other
runtime deadlines.

Fixes: f04b0fedbe71 ("mm/damon/core: implement intervals auto-tuning")
Signed-off-by: niecheng <niecheng1@xxxxxxxxxxxxx>
---
mm/damon/core.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 3dbbbfdeff71..501694d4a590 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -797,6 +797,8 @@ int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs)
attrs->aggr_interval / sample_interval;
ctx->next_ops_update_sis = ctx->passed_sample_intervals +
attrs->ops_update_interval / sample_interval;
+ ctx->next_intervals_tune_sis = ctx->passed_sample_intervals +
+ attrs->aggr_samples * attrs->intervals_goal.aggrs;

damon_update_monitoring_results(ctx, attrs, aggregating);
ctx->attrs = *attrs;
--
2.51.0