Commit 7335084d446b83cbcb15da80497d03f0c1dc9e21
Committed by
Linus Torvalds
1 parent
5013473152
Exists in
master
and in
6 other branches
mm: vmscan: do not OOM if aborting reclaim to start compaction
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>
Showing 1 changed file with 7 additions and 1 deletions Side-by-side Diff
mm/vmscan.c
... | ... | @@ -2263,6 +2263,7 @@ |
2263 | 2263 | struct zoneref *z; |
2264 | 2264 | struct zone *zone; |
2265 | 2265 | unsigned long writeback_threshold; |
2266 | + bool should_abort_reclaim; | |
2266 | 2267 | |
2267 | 2268 | get_mems_allowed(); |
2268 | 2269 | delayacct_freepages_start(); |
... | ... | @@ -2274,7 +2275,8 @@ |
2274 | 2275 | sc->nr_scanned = 0; |
2275 | 2276 | if (!priority) |
2276 | 2277 | disable_swap_token(sc->target_mem_cgroup); |
2277 | - if (shrink_zones(priority, zonelist, sc)) | |
2278 | + should_abort_reclaim = shrink_zones(priority, zonelist, sc); | |
2279 | + if (should_abort_reclaim) | |
2278 | 2280 | break; |
2279 | 2281 | |
2280 | 2282 | /* |
... | ... | @@ -2341,6 +2343,10 @@ |
2341 | 2343 | */ |
2342 | 2344 | if (oom_killer_disabled) |
2343 | 2345 | return 0; |
2346 | + | |
2347 | + /* Aborting reclaim to try compaction? don't OOM, then */ | |
2348 | + if (should_abort_reclaim) | |
2349 | + return 1; | |
2344 | 2350 | |
2345 | 2351 | /* top priority shrink_zones still had more to do? don't OOM, then */ |
2346 | 2352 | if (global_reclaim(sc) && !all_unreclaimable(zonelist, sc)) |