1 From b39415b2731d7dec5e612d2d12595da82399eedf Mon Sep 17 00:00:00 2001
2 From: Rik van Riel <riel@redhat.com>
3 Date: Mon, 14 Dec 2009 17:59:48 -0800
4 Subject: vmscan: do not evict inactive pages when skipping an active list scan
6 From: Rik van Riel <riel@redhat.com>
8 commit b39415b2731d7dec5e612d2d12595da82399eedf upstream.
10 In AIM7 runs, recent kernels start swapping out anonymous pages well
11 before they should. This is due to shrink_list falling through to
12 shrink_inactive_list if !inactive_anon_is_low(zone, sc), when all we
13 really wanted to do is pre-age some anonymous pages to give them extra
14 time to be referenced while on the inactive list.
16 The obvious fix is to make sure that shrink_list does not fall through to
17 scanning/reclaiming inactive pages when we called it to scan one of the
20 This change should be safe because the loop in shrink_zone ensures that we
21 will still shrink the anon and file inactive lists whenever we should.
23 [kosaki.motohiro@jp.fujitsu.com: inactive_file_is_low() should be inactive_anon_is_low()]
24 Reported-by: Larry Woodman <lwoodman@redhat.com>
25 Signed-off-by: Rik van Riel <riel@redhat.com>
26 Acked-by: Johannes Weiner <hannes@cmpxchg.org>
27 Cc: Tomasz Chmielewski <mangoo@wpkg.org>
28 Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
29 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
30 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
31 Cc: Rik Theys <rik.theys@gmail.com>
32 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
35 mm/vmscan.c | 18 ++++++++++++------
36 1 file changed, 12 insertions(+), 6 deletions(-)
40 @@ -1464,20 +1464,26 @@ static int inactive_file_is_low(struct z
44 +static int inactive_list_is_low(struct zone *zone, struct scan_control *sc,
48 + return inactive_file_is_low(zone, sc);
50 + return inactive_anon_is_low(zone, sc);
53 static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
54 struct zone *zone, struct scan_control *sc, int priority)
56 int file = is_file_lru(lru);
58 - if (lru == LRU_ACTIVE_FILE && inactive_file_is_low(zone, sc)) {
59 - shrink_active_list(nr_to_scan, zone, sc, priority, file);
60 + if (is_active_lru(lru)) {
61 + if (inactive_list_is_low(zone, sc, file))
62 + shrink_active_list(nr_to_scan, zone, sc, priority, file);
66 - if (lru == LRU_ACTIVE_ANON && inactive_anon_is_low(zone, sc)) {
67 - shrink_active_list(nr_to_scan, zone, sc, priority, file);
70 return shrink_inactive_list(nr_to_scan, zone, sc, priority, file);