summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2009-07-30 00:02:06 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2009-07-30 04:10:34 +0200
commit6583bb64fc370842b32a87c67750c26f6d559af0 (patch)
tree321681ebc6ff893318d67859b24f199b9111cbc8
parentpage-allocator: preserve PFN ordering when __GFP_COLD is set (diff)
downloadlinux-6583bb64fc370842b32a87c67750c26f6d559af0.tar.xz
linux-6583bb64fc370842b32a87c67750c26f6d559af0.zip
mm: avoid endless looping for oom killed tasks
If a task is oom killed and still cannot find memory when trying with no watermarks, it's better to fail the allocation attempt than to loop endlessly. Direct reclaim has already failed and the oom killer will be a no-op since current has yet to die, so there is no other alternative for allocations that are not __GFP_NOFAIL. Acked-by: Mel Gorman <mel@csn.ul.ie> Signed-off-by: David Rientjes <rientjes@google.com> Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/page_alloc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ae28c22a7fdb..2dbb2fc68837 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1794,6 +1794,10 @@ rebalance:
if (p->flags & PF_MEMALLOC)
goto nopage;
+ /* Avoid allocations with no watermarks from looping endlessly */
+ if (test_thread_flag(TIF_MEMDIE) && !(gfp_mask & __GFP_NOFAIL))
+ goto nopage;
+
/* Try direct reclaim and then allocating */
page = __alloc_pages_direct_reclaim(gfp_mask, order,
zonelist, high_zoneidx,