]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: vmscan: do not OOM if aborting reclaim to start compaction
authorMel Gorman <mgorman@suse.de>
Fri, 13 Jan 2012 01:19:33 +0000 (17:19 -0800)
committerJerry Snitselaar <jerry.snitselaar@oracle.com>
Sun, 7 Oct 2012 06:02:42 +0000 (23:02 -0700)
commit 7335084d446b83cbcb15da80497d03f0c1dc9e21 upstream.

Stable note: Not tracked in Bugzilla. This patch makes later patches
easier to apply but otherwise has little to justify it. The
problem it fixes was never observed but the source of the
theoretical problem did not exist for very long.

During direct reclaim it is possible that reclaim will be aborted so that
compaction can be attempted to satisfy a high-order allocation.  If this
decision is made before any pages are reclaimed, it is possible that 0 is
returned to the page allocator potentially triggering an OOM.  This has
not been observed but it is a possibility so this patch addresses it.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit da0dc52b5236e73d7d7b5a58e8e067236fd1323e)

Signed-off-by: Jerry Snitselaar <jerry.snitselaar@oracle.com>
mm/vmscan.c

index 91aa1842fe69bec4e1255f666089cb67621f9a1a..c85c5a8f31d87b8e62b010bb1d254c6f1ea6a38b 100644 (file)
@@ -2240,6 +2240,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();
@@ -2251,7 +2252,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;
 
                /*
@@ -2318,6 +2320,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;