Commit 7a034fbb authored by SeongJae Park's avatar SeongJae Park Committed by Andrew Morton

mm/damon/lru_sort: enable and disable synchronously

Writing a value to DAMON_RECLAIM's 'enabled' parameter turns on or off
DAMON in an ansychronous way.  This means the parameter cannot be used to
read the current status of DAMON_RECLAIM.  'kdamond_pid' parameter should
be used instead for the purpose.  The documentation is easy to be read as
it works in a synchronous way, so it is a little bit confusing.  It also
makes the user space tooling dirty.

There's no real reason to have the asynchronous behavior, though.  Simply
make the parameter works synchronously, rather than updating the document.

Link: https://lkml.kernel.org/r/20221025173650.90624-4-sj@kernel.orgSigned-off-by: default avatarSeongJae Park <sj@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 4cc0ee77
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <linux/damon.h> #include <linux/damon.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/workqueue.h>
#include "modules-common.h" #include "modules-common.h"
...@@ -235,38 +234,31 @@ static int damon_lru_sort_turn(bool on) ...@@ -235,38 +234,31 @@ static int damon_lru_sort_turn(bool on)
return 0; return 0;
} }
static struct delayed_work damon_lru_sort_timer;
static void damon_lru_sort_timer_fn(struct work_struct *work)
{
static bool last_enabled;
bool now_enabled;
now_enabled = enabled;
if (last_enabled != now_enabled) {
if (!damon_lru_sort_turn(now_enabled))
last_enabled = now_enabled;
else
enabled = last_enabled;
}
}
static DECLARE_DELAYED_WORK(damon_lru_sort_timer, damon_lru_sort_timer_fn);
static bool damon_lru_sort_initialized;
static int damon_lru_sort_enabled_store(const char *val, static int damon_lru_sort_enabled_store(const char *val,
const struct kernel_param *kp) const struct kernel_param *kp)
{ {
int rc = param_set_bool(val, kp); bool is_enabled = enabled;
bool enable;
int err;
err = strtobool(val, &enable);
if (err)
return err;
if (rc < 0) if (is_enabled == enable)
return rc; return 0;
if (!damon_lru_sort_initialized) /* Called before init function. The function will handle this. */
return rc; if (!ctx)
goto set_param_out;
schedule_delayed_work(&damon_lru_sort_timer, 0); err = damon_lru_sort_turn(enable);
if (err)
return err;
return 0; set_param_out:
enabled = enable;
return err;
} }
static const struct kernel_param_ops enabled_param_ops = { static const struct kernel_param_ops enabled_param_ops = {
...@@ -320,10 +312,11 @@ static int __init damon_lru_sort_init(void) ...@@ -320,10 +312,11 @@ static int __init damon_lru_sort_init(void)
ctx->callback.after_wmarks_check = damon_lru_sort_after_wmarks_check; ctx->callback.after_wmarks_check = damon_lru_sort_after_wmarks_check;
ctx->callback.after_aggregation = damon_lru_sort_after_aggregation; ctx->callback.after_aggregation = damon_lru_sort_after_aggregation;
schedule_delayed_work(&damon_lru_sort_timer, 0); /* 'enabled' has set before this function, probably via command line */
if (enabled)
err = damon_lru_sort_turn(true);
damon_lru_sort_initialized = true; return err;
return 0;
} }
module_init(damon_lru_sort_init); module_init(damon_lru_sort_init);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment