aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmscan.c
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2012-01-12 20:19:49 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-12 23:13:09 -0500
commit0cee34fd72c582b4f8ad8ce00645b75fb4168199 (patch)
tree3b3bd79df0a2ebc869dba091d922c252784ffd23 /mm/vmscan.c
parentfe4b1b244bdb96136855f2c694071cb09d140766 (diff)
mm: vmscan: check if reclaim should really abort even if compaction_ready() is true for one zone
If compaction can proceed for a given zone, shrink_zones() does not reclaim any more pages from it. After commit [e0c2327: vmscan: abort reclaim/compaction if compaction can proceed], do_try_to_free_pages() tries to finish as soon as possible once one zone can compact. This was intended to prevent slabs being shrunk unnecessarily but there are side-effects. One is that a small zone that is ready for compaction will abort reclaim even if the chances of successfully allocating a THP from that zone is small. It also means that reclaim can return too early even though sc->nr_to_reclaim pages were not reclaimed. This partially reverts the commit until it is proven that slabs are really being shrunk unnecessarily but preserves the check to return 1 to avoid OOM if reclaim was aborted prematurely. [aarcange@redhat.com: This patch replaces a revert from Andrea] Signed-off-by: Mel Gorman <mgorman@suse.de> Reviewed-by: Rik van Riel <riel@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Minchan Kim <minchan.kim@gmail.com> Cc: Dave Jones <davej@redhat.com> Cc: Jan Kara <jack@suse.cz> Cc: Andy Isaacson <adi@hexapodia.org> Cc: Nai Xia <nai.xia@gmail.com> Cc: Johannes Weiner <jweiner@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 3b8ede882396..25f90383b391 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -2217,7 +2217,8 @@ static inline bool compaction_ready(struct zone *zone, struct scan_control *sc)
2217 * 2217 *
2218 * This function returns true if a zone is being reclaimed for a costly 2218 * This function returns true if a zone is being reclaimed for a costly
2219 * high-order allocation and compaction is ready to begin. This indicates to 2219 * high-order allocation and compaction is ready to begin. This indicates to
2220 * the caller that it should retry the allocation or fail. 2220 * the caller that it should consider retrying the allocation instead of
2221 * further reclaim.
2221 */ 2222 */
2222static bool shrink_zones(int priority, struct zonelist *zonelist, 2223static bool shrink_zones(int priority, struct zonelist *zonelist,
2223 struct scan_control *sc) 2224 struct scan_control *sc)
@@ -2226,7 +2227,7 @@ static bool shrink_zones(int priority, struct zonelist *zonelist,
2226 struct zone *zone; 2227 struct zone *zone;
2227 unsigned long nr_soft_reclaimed; 2228 unsigned long nr_soft_reclaimed;
2228 unsigned long nr_soft_scanned; 2229 unsigned long nr_soft_scanned;
2229 bool should_abort_reclaim = false; 2230 bool aborted_reclaim = false;
2230 2231
2231 for_each_zone_zonelist_nodemask(zone, z, zonelist, 2232 for_each_zone_zonelist_nodemask(zone, z, zonelist,
2232 gfp_zone(sc->gfp_mask), sc->nodemask) { 2233 gfp_zone(sc->gfp_mask), sc->nodemask) {
@@ -2252,7 +2253,7 @@ static bool shrink_zones(int priority, struct zonelist *zonelist,
2252 * allocations. 2253 * allocations.
2253 */ 2254 */
2254 if (compaction_ready(zone, sc)) { 2255 if (compaction_ready(zone, sc)) {
2255 should_abort_reclaim = true; 2256 aborted_reclaim = true;
2256 continue; 2257 continue;
2257 } 2258 }
2258 } 2259 }
@@ -2274,7 +2275,7 @@ static bool shrink_zones(int priority, struct zonelist *zonelist,
2274 shrink_zone(priority, zone, sc); 2275 shrink_zone(priority, zone, sc);
2275 } 2276 }
2276 2277
2277 return should_abort_reclaim; 2278 return aborted_reclaim;
2278} 2279}
2279 2280
2280static bool zone_reclaimable(struct zone *zone) 2281static bool zone_reclaimable(struct zone *zone)
@@ -2328,7 +2329,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
2328 struct zoneref *z; 2329 struct zoneref *z;
2329 struct zone *zone; 2330 struct zone *zone;
2330 unsigned long writeback_threshold; 2331 unsigned long writeback_threshold;
2331 bool should_abort_reclaim; 2332 bool aborted_reclaim;
2332 2333
2333 get_mems_allowed(); 2334 get_mems_allowed();
2334 delayacct_freepages_start(); 2335 delayacct_freepages_start();
@@ -2340,9 +2341,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
2340 sc->nr_scanned = 0; 2341 sc->nr_scanned = 0;
2341 if (!priority) 2342 if (!priority)
2342 disable_swap_token(sc->target_mem_cgroup); 2343 disable_swap_token(sc->target_mem_cgroup);
2343 should_abort_reclaim = shrink_zones(priority, zonelist, sc); 2344 aborted_reclaim = shrink_zones(priority, zonelist, sc);
2344 if (should_abort_reclaim)
2345 break;
2346 2345
2347 /* 2346 /*
2348 * Don't shrink slabs when reclaiming memory from 2347 * Don't shrink slabs when reclaiming memory from
@@ -2409,8 +2408,8 @@ out:
2409 if (oom_killer_disabled) 2408 if (oom_killer_disabled)
2410 return 0; 2409 return 0;
2411 2410
2412 /* Aborting reclaim to try compaction? don't OOM, then */ 2411 /* Aborted reclaim to try compaction? don't OOM, then */
2413 if (should_abort_reclaim) 2412 if (aborted_reclaim)
2414 return 1; 2413 return 1;
2415 2414
2416 /* top priority shrink_zones still had more to do? don't OOM, then */ 2415 /* top priority shrink_zones still had more to do? don't OOM, then */