From 3b957b5eef4887273e87ba87c1412acefb347966 Mon Sep 17 00:00:00 2001 From: Vinayak Menon Date: Tue, 4 Feb 2020 16:28:09 +0530 Subject: [PATCH] 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 --- mm/process_reclaim.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/mm/process_reclaim.c b/mm/process_reclaim.c index 084131312d1f..44f812555a56 100644 --- a/mm/process_reclaim.c +++ b/mm/process_reclaim.c @@ -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; } - tasksize = get_mm_counter(p->mm, MM_ANONPAGES); + 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;