Skip to content

Commit

Permalink
mm: avoid endless looping for oom killed tasks
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David Rientjes <[email protected]>
Acked-by: Hugh Dickins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rientjes authored and torvalds committed Jul 30, 2009
1 parent e084b2d commit 6583bb6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,10 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
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,
Expand Down

0 comments on commit 6583bb6

Please sign in to comment.