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

mm/damon/reclaim: deduplicate 'commit_inputs' handling

DAMON_RECLAIM's handling of 'commit_inputs' parameter is duplicated in
'after_aggregation()' and 'after_wmarks_check()' callbacks.  This commit
deduplicates the code for better maintenance.

Link: https://lkml.kernel.org/r/20220606182310.48781-4-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 c9e124e0
...@@ -403,10 +403,21 @@ module_param_cb(enabled, &enabled_param_ops, &enabled, 0600); ...@@ -403,10 +403,21 @@ module_param_cb(enabled, &enabled_param_ops, &enabled, 0600);
MODULE_PARM_DESC(enabled, MODULE_PARM_DESC(enabled,
"Enable or disable DAMON_RECLAIM (default: disabled)"); "Enable or disable DAMON_RECLAIM (default: disabled)");
static int damon_reclaim_handle_commit_inputs(void)
{
int err;
if (!commit_inputs)
return 0;
err = damon_reclaim_apply_parameters();
commit_inputs = false;
return err;
}
static int damon_reclaim_after_aggregation(struct damon_ctx *c) static int damon_reclaim_after_aggregation(struct damon_ctx *c)
{ {
struct damos *s; struct damos *s;
int err = 0;
/* update the stats parameter */ /* update the stats parameter */
damon_for_each_scheme(s, c) { damon_for_each_scheme(s, c) {
...@@ -417,22 +428,12 @@ static int damon_reclaim_after_aggregation(struct damon_ctx *c) ...@@ -417,22 +428,12 @@ static int damon_reclaim_after_aggregation(struct damon_ctx *c)
nr_quota_exceeds = s->stat.qt_exceeds; nr_quota_exceeds = s->stat.qt_exceeds;
} }
if (commit_inputs) { return damon_reclaim_handle_commit_inputs();
err = damon_reclaim_apply_parameters();
commit_inputs = false;
}
return err;
} }
static int damon_reclaim_after_wmarks_check(struct damon_ctx *c) static int damon_reclaim_after_wmarks_check(struct damon_ctx *c)
{ {
int err = 0; return damon_reclaim_handle_commit_inputs();
if (commit_inputs) {
err = damon_reclaim_apply_parameters();
commit_inputs = false;
}
return err;
} }
static int __init damon_reclaim_init(void) static int __init damon_reclaim_init(void)
......
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