mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-12-03 17:30:23 -05:00
mm: track actual nr_scanned during shrink_slab()
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. Whilst other shrinkers may find themselves even unable to scan as many objects as they counted, and so underreport. Account for the extra freed/scanned objects against the total number of objects we intend to scan, otherwise we may end up penalising the slab far more than intended. Similarly, we want to add the underperforming scan to the deferred pass so that we try harder and harder in future passes. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Chris Wilson <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Hillf Danton <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Shaohua Li <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: David Rientjes <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Joonas Lahtinen <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
ce6fa91b93
commit
d460acb5bd
2 changed files with 11 additions and 3 deletions
|
|
@ -18,6 +18,13 @@ struct shrink_control {
|
|||
*/
|
||||
unsigned long nr_to_scan;
|
||||
|
||||
/*
|
||||
* How many objects did scan_objects process?
|
||||
* This defaults to nr_to_scan before every call, but the callee
|
||||
* should track its actual progress.
|
||||
*/
|
||||
unsigned long nr_scanned;
|
||||
|
||||
/* current node being shrunk (for NUMA aware shrinkers) */
|
||||
int nid;
|
||||
|
||||
|
|
|
|||
|
|
@ -393,14 +393,15 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl,
|
|||
unsigned long nr_to_scan = min(batch_size, total_scan);
|
||||
|
||||
shrinkctl->nr_to_scan = nr_to_scan;
|
||||
shrinkctl->nr_scanned = nr_to_scan;
|
||||
ret = shrinker->scan_objects(shrinker, shrinkctl);
|
||||
if (ret == SHRINK_STOP)
|
||||
break;
|
||||
freed += ret;
|
||||
|
||||
count_vm_events(SLABS_SCANNED, nr_to_scan);
|
||||
total_scan -= nr_to_scan;
|
||||
scanned += nr_to_scan;
|
||||
count_vm_events(SLABS_SCANNED, shrinkctl->nr_scanned);
|
||||
total_scan -= shrinkctl->nr_scanned;
|
||||
scanned += shrinkctl->nr_scanned;
|
||||
|
||||
cond_resched();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue