diff mbox

mm: Reward slab shrinkers that reclaim more than they were asked

Message ID 20170812113437.7397-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Aug. 12, 2017, 11:34 a.m. UTC
Some shrinkers may only be able to free a bunch of objects at a time, and
so free more than the requested nr_to_scan in one pass. Account for the
extra freed objects against the total number of objects we intend to
free, otherwise we may end up penalising the slab far more than intended.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Shaohua Li <shli@fb.com>
Cc: linux-mm@kvack.org
---
 mm/vmscan.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox

Patch

diff --git a/mm/vmscan.c b/mm/vmscan.c
index a1af041930a6..8bf6f41f94fb 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -398,6 +398,7 @@  static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
 			break;
 		freed += ret;
 
+		nr_to_scan = max(nr_to_scan, ret);
 		count_vm_events(SLABS_SCANNED, nr_to_scan);
 		total_scan -= nr_to_scan;
 		scanned += nr_to_scan;