Skip to content

Commit 66d9fae

Browse files
sjp38akpm00
authored andcommitted
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.org Signed-off-by: SeongJae Park <sj@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 18250e7 commit 66d9fae

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

mm/damon/reclaim.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ module_param(monitor_region_start, ulong, 0600);
9898
static unsigned long monitor_region_end __read_mostly;
9999
module_param(monitor_region_end, ulong, 0600);
100100

101+
/*
102+
* Skip anonymous pages reclamation.
103+
*
104+
* If this parameter is set as ``Y``, DAMON_RECLAIM does not reclaim anonymous
105+
* pages. By default, ``N``.
106+
*/
107+
static bool skip_anon __read_mostly;
108+
module_param(skip_anon, bool, 0600);
109+
101110
/*
102111
* PID of the DAMON thread
103112
*
@@ -142,6 +151,7 @@ static struct damos *damon_reclaim_new_scheme(void)
142151
static int damon_reclaim_apply_parameters(void)
143152
{
144153
struct damos *scheme;
154+
struct damos_filter *filter;
145155
int err = 0;
146156

147157
err = damon_set_attrs(ctx, &damon_reclaim_mon_attrs);
@@ -152,6 +162,15 @@ static int damon_reclaim_apply_parameters(void)
152162
scheme = damon_reclaim_new_scheme();
153163
if (!scheme)
154164
return -ENOMEM;
165+
if (skip_anon) {
166+
filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true);
167+
if (!filter) {
168+
/* Will be freed by next 'damon_set_schemes()' below */
169+
damon_destroy_scheme(scheme);
170+
return -ENOMEM;
171+
}
172+
damos_add_filter(scheme, filter);
173+
}
155174
damon_set_schemes(ctx, &scheme, 1);
156175

157176
return damon_set_region_biggest_system_ram_default(target,

0 commit comments

Comments
 (0)