Commit f943e7e3 authored by SeongJae Park's avatar SeongJae Park Committed by akpm

mm/damon/reclaim: make 'enabled' checking timer simpler

DAMON_RECLAIM's 'enabled' parameter store callback ('enabled_store()')
schedules the parameter check timer ('damon_reclaim_timer') if the
parameter is set as 'Y'.  Then, the timer schedules itself to check if
user has set the parameter as 'N'.  It's unnecessarily complex.

This commit makes it simpler by making the parameter store callback to
schedule the timer regardless of the parameter value and disabling the
timer's self scheduling.

Link: https://lkml.kernel.org/r/20220606182310.48781-6-sj@kernel.orgSigned-off-by: default avatarSeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent a79b68ee
...@@ -353,7 +353,6 @@ static int damon_reclaim_turn(bool on) ...@@ -353,7 +353,6 @@ static int damon_reclaim_turn(bool on)
return 0; return 0;
} }
#define ENABLE_CHECK_INTERVAL_MS 1000
static struct delayed_work damon_reclaim_timer; static struct delayed_work damon_reclaim_timer;
static void damon_reclaim_timer_fn(struct work_struct *work) static void damon_reclaim_timer_fn(struct work_struct *work)
{ {
...@@ -367,10 +366,6 @@ static void damon_reclaim_timer_fn(struct work_struct *work) ...@@ -367,10 +366,6 @@ static void damon_reclaim_timer_fn(struct work_struct *work)
else else
enabled = last_enabled; enabled = last_enabled;
} }
if (enabled)
schedule_delayed_work(&damon_reclaim_timer,
msecs_to_jiffies(ENABLE_CHECK_INTERVAL_MS));
} }
static DECLARE_DELAYED_WORK(damon_reclaim_timer, damon_reclaim_timer_fn); static DECLARE_DELAYED_WORK(damon_reclaim_timer, damon_reclaim_timer_fn);
...@@ -388,9 +383,7 @@ static int enabled_store(const char *val, ...@@ -388,9 +383,7 @@ static int enabled_store(const char *val,
if (!damon_reclaim_initialized) if (!damon_reclaim_initialized)
return rc; return rc;
if (enabled) schedule_delayed_work(&damon_reclaim_timer, 0);
schedule_delayed_work(&damon_reclaim_timer, 0);
return 0; return 0;
} }
......
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