Commit 66d9faec authored by SeongJae Park's avatar SeongJae Park Committed by Andrew Morton

mm/damon/reclaim: add a parameter called skip_anon for avoiding anonymous pages reclamation

In some cases, for example if users have confidence at anonymous pages
management or the swap device is too slow, users would want to avoid
DAMON_RECLAIM swapping the anonymous pages out.  For such case, add yet
another DAMON_RECLAIM parameter, namely 'skip_anon'.  When it is set as
'Y', DAMON_RECLAIM will avoid reclaiming anonymous pages using a DAMOS
filter.

Link: https://lkml.kernel.org/r/20221205230830.144349-4-sj@kernel.orgSigned-off-by: default avatarSeongJae Park <sj@kernel.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 18250e78
...@@ -98,6 +98,15 @@ module_param(monitor_region_start, ulong, 0600); ...@@ -98,6 +98,15 @@ module_param(monitor_region_start, ulong, 0600);
static unsigned long monitor_region_end __read_mostly; static unsigned long monitor_region_end __read_mostly;
module_param(monitor_region_end, ulong, 0600); module_param(monitor_region_end, ulong, 0600);
/*
* Skip anonymous pages reclamation.
*
* If this parameter is set as ``Y``, DAMON_RECLAIM does not reclaim anonymous
* pages. By default, ``N``.
*/
static bool skip_anon __read_mostly;
module_param(skip_anon, bool, 0600);
/* /*
* PID of the DAMON thread * PID of the DAMON thread
* *
...@@ -142,6 +151,7 @@ static struct damos *damon_reclaim_new_scheme(void) ...@@ -142,6 +151,7 @@ static struct damos *damon_reclaim_new_scheme(void)
static int damon_reclaim_apply_parameters(void) static int damon_reclaim_apply_parameters(void)
{ {
struct damos *scheme; struct damos *scheme;
struct damos_filter *filter;
int err = 0; int err = 0;
err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs); err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs);
...@@ -152,6 +162,15 @@ static int damon_reclaim_apply_parameters(void) ...@@ -152,6 +162,15 @@ static int damon_reclaim_apply_parameters(void)
scheme = damon_reclaim_new_scheme(); scheme = damon_reclaim_new_scheme();
if (!scheme) if (!scheme)
return -ENOMEM; return -ENOMEM;
if (skip_anon) {
filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true);
if (!filter) {
/* Will be freed by next 'damon_set_schemes()' below */
damon_destroy_scheme(scheme);
return -ENOMEM;
}
damos_add_filter(scheme, filter);
}
damon_set_schemes(ctx, &scheme, 1); damon_set_schemes(ctx, &scheme, 1);
return damon_set_region_biggest_system_ram_default(target, return damon_set_region_biggest_system_ram_default(target,
......
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