]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/damon/paddr,vaddr: register themselves to DAMON in subsys_initcall
authorSeongJae Park <sj@kernel.org>
Tue, 22 Mar 2022 21:48:52 +0000 (14:48 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2022 22:57:12 +0000 (15:57 -0700)
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>
mm/damon/paddr.c
mm/damon/vaddr.c

index 9f0abd0369bc8e43ea9b9191f1cd7f01cf8b6e3c..d968bb38bd5da29aa30fe2552fbb35d3d8f45485 100644 (file)
@@ -273,3 +273,23 @@ void damon_pa_set_operations(struct damon_ctx *ctx)
        ctx->ops.apply_scheme = damon_pa_apply_scheme;
        ctx->ops.get_scheme_score = damon_pa_scheme_score;
 }
+
+static int __init damon_pa_initcall(void)
+{
+       struct damon_operations ops = {
+               .id = DAMON_OPS_PADDR,
+               .init = NULL,
+               .update = NULL,
+               .prepare_access_checks = damon_pa_prepare_access_checks,
+               .check_accesses = damon_pa_check_accesses,
+               .reset_aggregated = NULL,
+               .target_valid = damon_pa_target_valid,
+               .cleanup = NULL,
+               .apply_scheme = damon_pa_apply_scheme,
+               .get_scheme_score = damon_pa_scheme_score,
+       };
+
+       return damon_register_ops(&ops);
+};
+
+subsys_initcall(damon_pa_initcall);
index c0eb32025f9ba2a7fedd6da5a70b816383de06b2..87475ba37bec9f48c70d9f18262d792b4ae7a4c8 100644 (file)
@@ -752,4 +752,24 @@ void damon_va_set_operations(struct damon_ctx *ctx)
        ctx->ops.get_scheme_score = damon_va_scheme_score;
 }
 
+static int __init damon_va_initcall(void)
+{
+       struct damon_operations ops = {
+               .id = DAMON_OPS_VADDR,
+               .init = damon_va_init,
+               .update = damon_va_update,
+               .prepare_access_checks = damon_va_prepare_access_checks,
+               .check_accesses = damon_va_check_accesses,
+               .reset_aggregated = NULL,
+               .target_valid = damon_va_target_valid,
+               .cleanup = NULL,
+               .apply_scheme = damon_va_apply_scheme,
+               .get_scheme_score = damon_va_scheme_score,
+       };
+
+       return damon_register_ops(&ops);
+};
+
+subsys_initcall(damon_va_initcall);
+
 #include "vaddr-test.h"