mm/damon/sysfs: prohibit multiple physical address space monitoring targets
authorSeongJae Park <sj@kernel.org>
Tue, 10 May 2022 01:20:55 +0000 (18:20 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 13 May 2022 14:20:08 +0000 (07:20 -0700)
Having multiple targets for physical address space monitoring makes no
sense.  This commit prohibits such a ridiculous DAMON context setup my
making the DAMON context build function to check and return an error for
the case.

Link: https://lkml.kernel.org/r/20220429160606.127307-7-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 f753bb4..3d2da79 100644 (file)
@@ -2125,6 +2125,10 @@ static int damon_sysfs_set_targets(struct damon_ctx *ctx,
 {
        int i, err;
 
+       /* Multiple physical address space monitoring targets makes no sense */
+       if (ctx->ops.id == DAMON_OPS_PADDR && sysfs_targets->nr > 1)
+               return -EINVAL;
+
        for (i = 0; i < sysfs_targets->nr; i++) {
                struct damon_sysfs_target *sys_target =
                        sysfs_targets->targets_arr[i];