From: Alex Rusuf <yorha.op@gmail.com>
To: damon@lists.linux.dev
Cc: sj@kernel.org
Subject: [RFC PATCH v1 4/7] mm/damon/reclaim: kdamon_struct abstraction layer
Date: Wed, 15 May 2024 18:24:54 +0300 [thread overview]
Message-ID: <20240515152457.603724-5-yorha.op@gmail.com> (raw)
In-Reply-To: <20240515152457.603724-1-yorha.op@gmail.com>
This patch implements support for DAMON_RECLAIM
to use kdamond_struct abstraction layer
brought in by previous patches.
Signed-off-by: Alex Rusuf <yorha.op@gmail.com>
---
mm/damon/reclaim.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c
index 9bd341d62..ee760cbcc 100644
--- a/mm/damon/reclaim.c
+++ b/mm/damon/reclaim.c
@@ -150,8 +150,18 @@ static struct damos_stat damon_reclaim_stat;
DEFINE_DAMON_MODULES_DAMOS_STATS_PARAMS(damon_reclaim_stat,
reclaim_tried_regions, reclaimed_regions, quota_exceeds);
-static struct damon_ctx *ctx;
-static struct damon_target *target;
+static struct kdamond_struct *kdamond;
+
+static inline struct damon_ctx *damon_reclaim_ctx(void)
+{
+ return damon_first_ctx(kdamond);
+}
+
+static inline struct damon_target *damon_reclaim_target(void)
+{
+ return damon_first_target(
+ damon_reclaim_ctx());
+}
static struct damos *damon_reclaim_new_scheme(void)
{
@@ -197,6 +207,7 @@ static int damon_reclaim_apply_parameters(void)
struct damos *scheme, *old_scheme;
struct damos_quota_goal *goal;
struct damos_filter *filter;
+ struct damon_ctx *ctx = damon_reclaim_ctx();
int err = 0;
err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs);
@@ -244,7 +255,8 @@ static int damon_reclaim_apply_parameters(void)
}
damon_set_schemes(ctx, &scheme, 1);
- return damon_set_region_biggest_system_ram_default(target,
+ return damon_set_region_biggest_system_ram_default(
+ damon_reclaim_target(),
&monitor_region_start,
&monitor_region_end);
}
@@ -254,7 +266,7 @@ static int damon_reclaim_turn(bool on)
int err;
if (!on) {
- err = damon_stop(&ctx, 1);
+ err = damon_stop(kdamond);
if (!err)
kdamond_pid = -1;
return err;
@@ -264,10 +276,10 @@ static int damon_reclaim_turn(bool on)
if (err)
return err;
- err = damon_start(&ctx, 1, true);
+ err = damon_start(kdamond, true);
if (err)
return err;
- kdamond_pid = ctx->kdamond->pid;
+ kdamond_pid = kdamond->self->pid;
return 0;
}
@@ -286,7 +298,7 @@ static int damon_reclaim_enabled_store(const char *val,
return 0;
/* Called before init function. The function will handle this. */
- if (!ctx)
+ if (!kdamond)
goto set_param_out;
err = damon_reclaim_turn(enable);
@@ -337,11 +349,13 @@ static int damon_reclaim_after_wmarks_check(struct damon_ctx *c)
static int __init damon_reclaim_init(void)
{
- int err = damon_modules_new_paddr_ctx_target(&ctx, &target);
+ struct damon_ctx *ctx;
+ int err = damon_modules_new_paddr_kdamond(&kdamond);
if (err)
return err;
+ ctx = damon_reclaim_ctx();
ctx->callback.after_wmarks_check = damon_reclaim_after_wmarks_check;
ctx->callback.after_aggregation = damon_reclaim_after_aggregation;
--
2.42.0
next prev parent reply other threads:[~2024-05-15 15:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 15:24 [RFC PATCH v1 0/7] DAMON multiple contexts support Alex Rusuf
2024-05-15 15:24 ` [RFC PATCH v1 1/7] mm/damon/core: kdamond_struct abstraction layer Alex Rusuf
2024-05-15 15:24 ` [RFC PATCH v1 2/7] mm/damon/core: list-based contexts organization Alex Rusuf
2024-05-15 15:24 ` [RFC PATCH v1 3/7] mm/damon/lru_sort: kdamond_struct abstraction layer Alex Rusuf
2024-05-15 15:24 ` Alex Rusuf [this message]
2024-05-15 15:24 ` [RFC PATCH v1 5/7] mm/damon/core: rename nr_running_ctxs -> nr_running_kdamonds Alex Rusuf
2024-05-15 15:24 ` [RFC PATCH v1 6/7] mm/damon/core: multi-context support Alex Rusuf
2024-05-15 15:24 ` [RFC PATCH v1 7/7] mm/damon/core: multi-context awarness for trace events Alex Rusuf
2024-05-16 22:17 ` [RFC PATCH v1 0/7] DAMON multiple contexts support SeongJae Park
2024-05-17 8:51 ` Alex Rusuf
2024-05-17 22:59 ` SeongJae Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240515152457.603724-5-yorha.op@gmail.com \
--to=yorha.op@gmail.com \
--cc=damon@lists.linux.dev \
--cc=sj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).