mm/damon: simplify damon_ctx check in damon_sysfs_before_terminate
authorXin Hao <xhao@linux.alibaba.com>
Wed, 7 Sep 2022 08:41:16 +0000 (16:41 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 3 Oct 2022 21:03:03 +0000 (14:03 -0700)
In damon_sysfs_before_terminate(), it needs to check whether ctx->ops.id
supports 'DAMON_OPS_VADDR' or 'DAMON_OPS_FVADDR', there we can use
damon_target_has_pid() instead.

Link: https://lkml.kernel.org/r/20220907084116.62053-1-xhao@linux.alibaba.com
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/sysfs.c

index fe6c6870cf868676399ea8ff7a4e4c33fc38071a..1719bb3531e30cbd2ec232e8201267532bf0e87e 100644 (file)
@@ -2309,7 +2309,7 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx)
 {
        struct damon_target *t, *next;
 
-       if (ctx->ops.id != DAMON_OPS_VADDR && ctx->ops.id != DAMON_OPS_FVADDR)
+       if (!damon_target_has_pid(ctx))
                return;
 
        mutex_lock(&ctx->kdamond_lock);