Skip to content

Commit 7752925

Browse files
sjp38torvalds
authored andcommitted
mm/damon/paddr,vaddr: register themselves to DAMON in subsys_initcall
This commit makes the monitoring operations for the physical address space and virtual address spaces register themselves to DAMON in the subsys_initcall step. Later, in-kernel DAMON user code can use them via damon_select_ops() without have to unnecessarily depend on all possible monitoring operations implementations. Link: https://lkml.kernel.org/r/20220215184603.1479-4-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 9f7b053 commit 7752925

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

mm/damon/paddr.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,23 @@ void damon_pa_set_operations(struct damon_ctx *ctx)
273273
ctx->ops.apply_scheme = damon_pa_apply_scheme;
274274
ctx->ops.get_scheme_score = damon_pa_scheme_score;
275275
}
276+
277+
static int __init damon_pa_initcall(void)
278+
{
279+
struct damon_operations ops = {
280+
.id = DAMON_OPS_PADDR,
281+
.init = NULL,
282+
.update = NULL,
283+
.prepare_access_checks = damon_pa_prepare_access_checks,
284+
.check_accesses = damon_pa_check_accesses,
285+
.reset_aggregated = NULL,
286+
.target_valid = damon_pa_target_valid,
287+
.cleanup = NULL,
288+
.apply_scheme = damon_pa_apply_scheme,
289+
.get_scheme_score = damon_pa_scheme_score,
290+
};
291+
292+
return damon_register_ops(&ops);
293+
};
294+
295+
subsys_initcall(damon_pa_initcall);

mm/damon/vaddr.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,4 +752,24 @@ void damon_va_set_operations(struct damon_ctx *ctx)
752752
ctx->ops.get_scheme_score = damon_va_scheme_score;
753753
}
754754

755+
static int __init damon_va_initcall(void)
756+
{
757+
struct damon_operations ops = {
758+
.id = DAMON_OPS_VADDR,
759+
.init = damon_va_init,
760+
.update = damon_va_update,
761+
.prepare_access_checks = damon_va_prepare_access_checks,
762+
.check_accesses = damon_va_check_accesses,
763+
.reset_aggregated = NULL,
764+
.target_valid = damon_va_target_valid,
765+
.cleanup = NULL,
766+
.apply_scheme = damon_va_apply_scheme,
767+
.get_scheme_score = damon_va_scheme_score,
768+
};
769+
770+
return damon_register_ops(&ops);
771+
};
772+
773+
subsys_initcall(damon_va_initcall);
774+
755775
#include "vaddr-test.h"

0 commit comments

Comments
 (0)