summaryrefslogtreecommitdiff
path: root/mm/damon/lru_sort.c
diff options
context:
space:
mode:
authorSeongJae Park <sj@kernel.org>2022-10-26 22:59:42 +0000
committerAndrew Morton <akpm@linux-foundation.org>2022-11-30 15:01:26 -0800
commit7ae2c17f53d5054d1fe5c1a103ad46068034617d (patch)
tree8f6fb2b8ce5811dd56dbb17592975acb8796dd6d /mm/damon/lru_sort.c
parentc8e7b4d0ba348a8ef14956a80c780f152f433764 (diff)
mm/damon/modules: deduplicate init steps for DAMON context setup
DAMON_RECLAIM and DAMON_LRU_SORT has duplicated code for DAMON context and target initializations. Deduplicate the part by implementing a function for the initialization in 'modules-common.c' and using it. Link: https://lkml.kernel.org/r/20221026225943.100429-12-sj@kernel.org Signed-off-by: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/damon/lru_sort.c')
-rw-r--r--mm/damon/lru_sort.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index efbc2bda8b9c..a1896c5acfe9 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -314,25 +314,14 @@ static int damon_lru_sort_after_wmarks_check(struct damon_ctx *c)
static int __init damon_lru_sort_init(void)
{
- ctx = damon_new_ctx();
- if (!ctx)
- return -ENOMEM;
+ int err = damon_modules_new_paddr_ctx_target(&ctx, &target);
- if (damon_select_ops(ctx, DAMON_OPS_PADDR)) {
- damon_destroy_ctx(ctx);
- return -EINVAL;
- }
+ if (err)
+ return err;
ctx->callback.after_wmarks_check = damon_lru_sort_after_wmarks_check;
ctx->callback.after_aggregation = damon_lru_sort_after_aggregation;
- target = damon_new_target();
- if (!target) {
- damon_destroy_ctx(ctx);
- return -ENOMEM;
- }
- damon_add_target(ctx, target);
-
schedule_delayed_work(&damon_lru_sort_timer, 0);
damon_lru_sort_initialized = true;