]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/damon/sysfs: don't hold kdamond_lock in before_terminate()
authorSeongJae Park <sj@kernel.org>
Sat, 5 Jul 2025 17:49:59 +0000 (10:49 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 20 Jul 2025 01:59:44 +0000 (18:59 -0700)
damon_sysfs_before_terminate() is a DAMON callback that is executed from
the kdamond's context.  Hence it is safe to access DAMON context internal
data.  But the function is unnecessarily holding kdamond_lock of the
context.  It is just unnecessary.  Remove the locking code.

Link: https://lkml.kernel.org/r/20250705175000.56259-6-sj@kernel.org
Signed-off-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/sysfs.c

index 79d65dcc9dd03a940624b765d67795983bb55560..c0193de6fb9af0fbbece2d0813d319ca61bfe2b1 100644 (file)
@@ -1387,12 +1387,10 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx)
        if (!damon_target_has_pid(ctx))
                return;
 
-       mutex_lock(&ctx->kdamond_lock);
        damon_for_each_target_safe(t, next, ctx) {
                put_pid(t->pid);
                damon_destroy_target(t);
        }
-       mutex_unlock(&ctx->kdamond_lock);
 }
 
 /*