diff options
author | Andrew Morton <akpm@linux-foundation.org> | 2009-06-16 18:32:37 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-16 22:47:40 -0400 |
commit | dab48dab37d2770824420d1e01730a107fade1aa (patch) | |
tree | 81e949d2521d4d8d979808feaa9c2a570337a98c | |
parent | 720b17e759a50635c429ccaa2ec3d01edb4f92d6 (diff) |
page-allocator: warn if __GFP_NOFAIL is used for a large allocation
__GFP_NOFAIL is a bad fiction. Allocations _can_ fail, and callers should
detect and suitably handle this (and not by lamely moving the infinite
loop up to the caller level either).
Attempting to use __GFP_NOFAIL for a higher-order allocation is even
worse, so add a once-off runtime check for this to slap people around for
even thinking about trying it.
Cc: David Rientjes <rientjes@google.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/page_alloc.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 076463cb21ba..61290ea721c8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -1128,6 +1128,19 @@ again: | |||
1128 | list_del(&page->lru); | 1128 | list_del(&page->lru); |
1129 | pcp->count--; | 1129 | pcp->count--; |
1130 | } else { | 1130 | } else { |
1131 | if (unlikely(gfp_flags & __GFP_NOFAIL)) { | ||
1132 | /* | ||
1133 | * __GFP_NOFAIL is not to be used in new code. | ||
1134 | * | ||
1135 | * All __GFP_NOFAIL callers should be fixed so that they | ||
1136 | * properly detect and handle allocation failures. | ||
1137 | * | ||
1138 | * We most definitely don't want callers attempting to | ||
1139 | * allocate greater than single-page units with | ||
1140 | * __GFP_NOFAIL. | ||
1141 | */ | ||
1142 | WARN_ON_ONCE(order > 0); | ||
1143 | } | ||
1131 | spin_lock_irqsave(&zone->lock, flags); | 1144 | spin_lock_irqsave(&zone->lock, flags); |
1132 | page = __rmqueue(zone, order, migratetype); | 1145 | page = __rmqueue(zone, order, migratetype); |
1133 | __mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order)); | 1146 | __mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order)); |