From 1b45604c21da15e188e5a4c65cc25033cbc19617 Mon Sep 17 00:00:00 2001 From: Liam Mark Date: Tue, 25 Nov 2014 14:43:42 -0800 Subject: [PATCH] mm: vmscan: support complete shrinker reclaim Ensure that shrinkers are given the option to completely drop their caches even when their caches are smaller than the batch size. This change helps improve memory headroom by ensuring that under significant memory pressure shrinkers can drop all of their caches. This change only attempts to more aggressively call the shrinkers during background memory reclaim, inorder to avoid hurting the perforamnce of direct memory reclaim. Change-Id: I8dbc29c054add639e4810e36fd2c8a063e5c52f3 Signed-off-by: Liam Mark Signed-off-by: Patrick Daly Signed-off-by: Sudarshan Rajagopalan Signed-off-by: Isaac J. Manjarres --- mm/vmscan.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index c6659bb758a4..8603c405c9a0 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -471,6 +471,10 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, long batch_size = shrinker->batch ? shrinker->batch : SHRINK_BATCH; long scanned = 0, next_deferred; + long min_cache_size = batch_size; + + if (current_is_kswapd()) + min_cache_size = 0; if (!(shrinker->flags & SHRINKER_NUMA_AWARE)) nid = 0; @@ -550,7 +554,7 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, * scanning at high prio and therefore should try to reclaim as much as * possible. */ - while (total_scan >= batch_size || + while (total_scan > min_cache_size || total_scan >= freeable) { unsigned long ret; unsigned long nr_to_scan = min(batch_size, total_scan);