Skip to content

Commit

Permalink
mm, page_alloc: warn for non-blockable __GFP_NOFAIL allocation failure
Browse files Browse the repository at this point in the history
__GFP_NOFAIL may return NULL when coupled with GFP_NOWAIT or GFP_ATOMIC.

Luckily, nothing currently does such craziness.  So instead of causing
such allocations to loop (potentially forever), we maintain the current
behavior and also warn about the new users of the deprecated flag.

Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
David Rientjes authored and Linus Torvalds committed Jan 22, 2014
1 parent 55b7c4c commit aed0a0e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2525,8 +2525,15 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
}

/* Atomic allocations - we can't balance anything */
if (!wait)
if (!wait) {
/*
* All existing users of the deprecated __GFP_NOFAIL are
* blockable, so warn of any new users that actually allow this
* type of allocation to fail.
*/
WARN_ON_ONCE(gfp_mask & __GFP_NOFAIL);
goto nopage;
}

/* Avoid recursion of direct reclaim */
if (current->flags & PF_MEMALLOC)
Expand Down

0 comments on commit aed0a0e

Please sign in to comment.