Skip to content

Commit da7aaca

Browse files
sjp38torvalds
authored andcommitted
mm/damon/dbgfs: use damon_select_ops() instead of damon_{v,p}a_set_operations()
This commit makes DAMON debugfs interface to select the registered monitoring operations for the physical address space or virtual address spaces depending on user requests instead of setting it on its own. Note that DAMON debugfs interface is still dependent to DAMON_VADDR with this change, because it is also using its symbol, 'damon_va_target_valid'. Link: https://lkml.kernel.org/r/20220215184603.1479-6-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Xin Hao <xhao@linux.alibaba.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4d69c34 commit da7aaca

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

mm/damon/dbgfs.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,18 @@ static ssize_t dbgfs_target_ids_write(struct file *file,
474474

475475
/* remove previously set targets */
476476
dbgfs_set_targets(ctx, 0, NULL);
477+
if (!nr_targets) {
478+
ret = count;
479+
goto unlock_out;
480+
}
477481

478482
/* Configure the context for the address space type */
479483
if (id_is_pid)
480-
damon_va_set_operations(ctx);
484+
ret = damon_select_ops(ctx, DAMON_OPS_VADDR);
481485
else
482-
damon_pa_set_operations(ctx);
486+
ret = damon_select_ops(ctx, DAMON_OPS_PADDR);
487+
if (ret)
488+
goto unlock_out;
483489

484490
ret = dbgfs_set_targets(ctx, nr_targets, target_pids);
485491
if (!ret)
@@ -735,7 +741,11 @@ static struct damon_ctx *dbgfs_new_ctx(void)
735741
if (!ctx)
736742
return NULL;
737743

738-
damon_va_set_operations(ctx);
744+
if (damon_select_ops(ctx, DAMON_OPS_VADDR) && damon_select_ops(ctx,
745+
DAMON_OPS_PADDR)) {
746+
damon_destroy_ctx(ctx);
747+
return NULL;
748+
}
739749
ctx->callback.before_terminate = dbgfs_before_terminate;
740750
return ctx;
741751
}

0 commit comments

Comments
 (0)