diff options
author | KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> | 2010-08-09 20:19:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-09 23:45:03 -0400 |
commit | 4dc4b3d971b23e12d483ba9f3b93b648c54b298a (patch) | |
tree | 845cc8debe146f683510841982323c338eb10000 | |
parent | 57250a5bf0f6ff68dc339572adbd881a11f366fa (diff) |
vmscan: shrink_slab() requires the number of lru_pages, not the page order
Presently shrink_slab() has the following scanning equation.
lru_scanned max_pass
basic_scan_objects = 4 x ------------- x -----------------------------
lru_pages shrinker->seeks (default:2)
scan_objects = min(basic_scan_objects, max_pass * 2)
If we pass very small value as lru_pages instead real number of lru pages,
shrink_slab() drop much objects rather than necessary. And now,
__zone_reclaim() pass 'order' as lru_pages by mistake. That produces a
bad result.
For example, if we receive very low memory pressure (scan = 32, order =
0), shrink_slab() via zone_reclaim() always drop _all_ icache/dcache
objects. (see above equation, very small lru_pages make very big
scan_objects result).
This patch fixes it.
[akpm@linux-foundation.org: fix layout, typos]
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
Acked-by: Christoph Lameter <cl@linux-foundation.org>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/vmscan.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c index a3d669f8e25e..9789a2c92563 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
@@ -2635,10 +2635,19 @@ static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order) | |||
2635 | * Note that shrink_slab will free memory on all zones and may | 2635 | * Note that shrink_slab will free memory on all zones and may |
2636 | * take a long time. | 2636 | * take a long time. |
2637 | */ | 2637 | */ |
2638 | while (shrink_slab(sc.nr_scanned, gfp_mask, order) && | 2638 | for (;;) { |
2639 | (zone_page_state(zone, NR_SLAB_RECLAIMABLE) + nr_pages > | 2639 | unsigned long lru_pages = zone_reclaimable_pages(zone); |
2640 | nr_slab_pages0)) | 2640 | |
2641 | ; | 2641 | /* No reclaimable slab or very low memory pressure */ |
2642 | if (!shrink_slab(sc.nr_scanned, gfp_mask, lru_pages)) | ||
2643 | break; | ||
2644 | |||
2645 | /* Freed enough memory */ | ||
2646 | nr_slab_pages1 = zone_page_state(zone, | ||
2647 | NR_SLAB_RECLAIMABLE); | ||
2648 | if (nr_slab_pages1 + nr_pages <= nr_slab_pages0) | ||
2649 | break; | ||
2650 | } | ||
2642 | 2651 | ||
2643 | /* | 2652 | /* |
2644 | * Update nr_reclaimed by the number of slab pages we | 2653 | * Update nr_reclaimed by the number of slab pages we |