mm: vmscan: do not OOM if aborting reclaim to start compaction
[pandora-kernel.git] / mm / vmscan.c
index fd47744..662a5ea 100644 (file)
@@ -2284,6 +2284,7 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
        struct zoneref *z;
        struct zone *zone;
        unsigned long writeback_threshold;
+       bool should_abort_reclaim;
 
        get_mems_allowed();
        delayacct_freepages_start();
@@ -2295,7 +2296,8 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
                sc->nr_scanned = 0;
                if (!priority)
                        disable_swap_token(sc->mem_cgroup);
-               if (shrink_zones(priority, zonelist, sc))
+               should_abort_reclaim = shrink_zones(priority, zonelist, sc);
+               if (should_abort_reclaim)
                        break;
 
                /*
@@ -2363,6 +2365,10 @@ out:
        if (oom_killer_disabled)
                return 0;
 
+       /* Aborting reclaim to try compaction? don't OOM, then */
+       if (should_abort_reclaim)
+               return 1;
+
        /* top priority shrink_zones still had more to do? don't OOM, then */
        if (scanning_global_lru(sc) && !all_unreclaimable(zonelist, sc))
                return 1;