[PATCH] mm/damon/core: fixup: care corruption and cancel damos_walk() immediately

From: SeongJae Park

Date: Sat Mar 21 2026 - 16:22:52 EST


As Sashiko suggested and I agreed.

Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
mm/damon/core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index ce010009ca136..0ab2cfa848e69 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -3005,12 +3005,12 @@ static int kdamond_fn(void *data)
if (ctx->maybe_corrupted)
break;
while (ctx->pause) {
- if (kdamond_need_stop(ctx))
- goto done;
+ damos_walk_cancel(ctx);
kdamond_usleep(ctx->attrs.sample_interval);
/* allow caller unset pause via damon_call() */
kdamond_call(ctx, false);
- damos_walk_cancel(ctx);
+ if (kdamond_need_stop(ctx) || ctx->maybe_corrupted)
+ goto done;
}
if (!list_empty(&ctx->schemes))
kdamond_apply_schemes(ctx);
--
2.47.3