mm: process_reclaim: allow nomap-only reclaim

Allow userspace to disable anon reclaim and enable nomap
reclaim. Also, let userspace set the per task nomap reclaim
size.

Change-Id: I4b52376b02b3590206aaec68e3135ecb54ca0830
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
This commit is contained in:
Vinayak Menon 2020-02-04 16:28:09 +05:30 committed by Gerrit - the friendly Code Review server
parent 055a204262
commit 3b957b5eef

View file

@ -29,6 +29,10 @@ module_param_named(enable_process_reclaim, enable_process_reclaim, int, 0644);
int per_swap_size = SWAP_CLUSTER_MAX * 32;
module_param_named(per_swap_size, per_swap_size, int, 0644);
/* The per task max number of nomap pages to be reclaimed */
int tsk_nomap_swap_sz;
module_param_named(tsk_nomap_swap_sz, tsk_nomap_swap_sz, int, 0644);
int reclaim_avg_efficiency;
module_param_named(reclaim_avg_efficiency, reclaim_avg_efficiency, int, 0444);
@ -108,7 +112,7 @@ static void swap_fn(struct work_struct *work)
struct selected_task selected[MAX_SWAP_TASKS] = {{0, 0, 0},};
int si = 0;
int i;
int tasksize;
int tasksize = 0;
int total_sz = 0;
short min_score_adj = 360;
int total_scan = 0;
@ -116,6 +120,9 @@ static void swap_fn(struct work_struct *work)
int nr_to_reclaim;
int efficiency;
if (!tsk_nomap_swap_sz && !per_swap_size)
return;
rcu_read_lock();
for_each_process(tsk) {
struct task_struct *p;
@ -137,7 +144,11 @@ static void swap_fn(struct work_struct *work)
continue;
}
if (per_swap_size)
tasksize = get_mm_counter(p->mm, MM_ANONPAGES);
else if (tsk_nomap_swap_sz)
tasksize = get_mm_rss(p->mm);
task_unlock(p);
if (tasksize <= 0)
@ -175,6 +186,9 @@ static void swap_fn(struct work_struct *work)
rcu_read_unlock();
while (si--) {
if (!per_swap_size)
goto nomap;
nr_to_reclaim =
(selected[si].tasksize * per_swap_size) / total_sz;
/* scan atleast a page */
@ -190,7 +204,9 @@ static void swap_fn(struct work_struct *work)
total_scan += rp.nr_scanned;
total_reclaimed += rp.nr_reclaimed;
reclaimed_anon += rp.nr_reclaimed;
nomap:
if (tsk_nomap_swap_sz)
nr_to_reclaim = tsk_nomap_swap_sz;
rp = reclaim_task_nomap(selected[si].p, nr_to_reclaim);
total_scan += rp.nr_scanned;
total_reclaimed += rp.nr_reclaimed;