1 From 0cee34fd72c582b4f8ad8ce00645b75fb4168199 Mon Sep 17 00:00:00 2001
2 From: Mel Gorman <mgorman@suse.de>
3 Date: Thu, 12 Jan 2012 17:19:49 -0800
4 Subject: mm: vmscan: check if reclaim should really abort even if compaction_ready() is true for one zone
6 From: Mel Gorman <mgorman@suse.de>
8 commit 0cee34fd72c582b4f8ad8ce00645b75fb4168199 upstream.
10 Stable note: Not tracked on Bugzilla. THP and compaction was found to
11 aggressively reclaim pages and stall systems under different
12 situations that was addressed piecemeal over time.
14 If compaction can proceed for a given zone, shrink_zones() does not
15 reclaim any more pages from it. After commit [e0c2327: vmscan: abort
16 reclaim/compaction if compaction can proceed], do_try_to_free_pages()
17 tries to finish as soon as possible once one zone can compact.
19 This was intended to prevent slabs being shrunk unnecessarily but there
20 are side-effects. One is that a small zone that is ready for compaction
21 will abort reclaim even if the chances of successfully allocating a THP
22 from that zone is small. It also means that reclaim can return too early
23 even though sc->nr_to_reclaim pages were not reclaimed.
25 This partially reverts the commit until it is proven that slabs are really
26 being shrunk unnecessarily but preserves the check to return 1 to avoid
27 OOM if reclaim was aborted prematurely.
29 [aarcange@redhat.com: This patch replaces a revert from Andrea]
30 Signed-off-by: Mel Gorman <mgorman@suse.de>
31 Reviewed-by: Rik van Riel <riel@redhat.com>
32 Cc: Andrea Arcangeli <aarcange@redhat.com>
33 Cc: Minchan Kim <minchan.kim@gmail.com>
34 Cc: Dave Jones <davej@redhat.com>
35 Cc: Jan Kara <jack@suse.cz>
36 Cc: Andy Isaacson <adi@hexapodia.org>
37 Cc: Nai Xia <nai.xia@gmail.com>
38 Cc: Johannes Weiner <jweiner@redhat.com>
39 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
40 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
41 Signed-off-by: Mel Gorman <mgorman@suse.de>
42 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
45 mm/vmscan.c | 19 +++++++++----------
46 1 file changed, 9 insertions(+), 10 deletions(-)
50 @@ -2129,7 +2129,8 @@ static inline bool compaction_ready(stru
52 * This function returns true if a zone is being reclaimed for a costly
53 * high-order allocation and compaction is ready to begin. This indicates to
54 - * the caller that it should retry the allocation or fail.
55 + * the caller that it should consider retrying the allocation instead of
58 static bool shrink_zones(int priority, struct zonelist *zonelist,
59 struct scan_control *sc)
60 @@ -2138,7 +2139,7 @@ static bool shrink_zones(int priority, s
62 unsigned long nr_soft_reclaimed;
63 unsigned long nr_soft_scanned;
64 - bool should_abort_reclaim = false;
65 + bool aborted_reclaim = false;
67 for_each_zone_zonelist_nodemask(zone, z, zonelist,
68 gfp_zone(sc->gfp_mask), sc->nodemask) {
69 @@ -2164,7 +2165,7 @@ static bool shrink_zones(int priority, s
72 if (compaction_ready(zone, sc)) {
73 - should_abort_reclaim = true;
74 + aborted_reclaim = true;
78 @@ -2186,7 +2187,7 @@ static bool shrink_zones(int priority, s
79 shrink_zone(priority, zone, sc);
82 - return should_abort_reclaim;
83 + return aborted_reclaim;
86 static bool zone_reclaimable(struct zone *zone)
87 @@ -2240,7 +2241,7 @@ static unsigned long do_try_to_free_page
90 unsigned long writeback_threshold;
91 - bool should_abort_reclaim;
92 + bool aborted_reclaim;
95 delayacct_freepages_start();
96 @@ -2252,9 +2253,7 @@ static unsigned long do_try_to_free_page
99 disable_swap_token(sc->mem_cgroup);
100 - should_abort_reclaim = shrink_zones(priority, zonelist, sc);
101 - if (should_abort_reclaim)
103 + aborted_reclaim = shrink_zones(priority, zonelist, sc);
106 * Don't shrink slabs when reclaiming memory from
107 @@ -2320,8 +2319,8 @@ out:
108 if (oom_killer_disabled)
111 - /* Aborting reclaim to try compaction? don't OOM, then */
112 - if (should_abort_reclaim)
113 + /* Aborted reclaim to try compaction? don't OOM, then */
114 + if (aborted_reclaim)
117 /* top priority shrink_zones still had more to do? don't OOM, then */