[PATCH] mm/damon/core: do not overwrite wmarks.activated in damos_commit()
From: Yifan Feng
Date: Sat Nov 21 2026 - 19:29:42 EST
damos_commit() copies the whole wmarks struct from the source scheme,
including the private 'activated' field. The source scheme is a new
one, so the field is always true there.
As a result, a commit turns on a scheme that the watermarks turned off.
If the metric is between mid and high at that time, the scheme keeps
running, though it should stay off until the metric goes below mid.
DAMON_RECLAIM and DAMON_LRU_SORT use the same path for commit_inputs.
Save 'activated' before the copy and restore it after. Do not restore
it for DAMOS_WMARK_NONE, because nothing sets it again in that case and
the scheme would stay off.
Fixes: 9cb3d0b9dfce ("mm/damon/core: implement DAMON context commit function")
Cc: <stable@xxxxxxxxxxxxxxx> # 6.11.x
Signed-off-by: Yifan Feng <evanfengff@xxxxxxxxx>
---
Tested in QEMU: without the fix a commit turns the scheme on, with the fix it stays off. kunit and selftests results do not change (13 pass, 2 need drgn).
Found and written with the help of an AI coding assistant.
mm/damon/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/damon/core.c b/mm/damon/core.c
index b8678a53b0a9..9ae77e4d6e57 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1567,6 +1567,7 @@ static struct damos *damon_nth_scheme(int n, struct damon_ctx *ctx)
static int damos_commit(struct damos *dst, struct damos *src)
{
+ bool activated = dst->wmarks.activated;
int err;
dst->pattern = src->pattern;
@@ -1578,6 +1579,8 @@ static int damos_commit(struct damos *dst, struct damos *src)
return err;
dst->wmarks = src->wmarks;
+ if (dst->wmarks.metric != DAMOS_WMARK_NONE)
+ dst->wmarks.activated = activated;
dst->target_nid = src->target_nid;
err = damos_commit_dests(&dst->migrate_dests, &src->migrate_dests);
base-commit: 4405c18c95d2d0f99f6c581ef0ee8591a1aa6ccd
--
2.39.3 (Apple Git-146)