]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - mm/page_alloc.c
page-allocator: warn if __GFP_NOFAIL is used for a large allocation
[net-next-2.6.git] / mm / page_alloc.c
index 076463cb21ba52d04f0e7828fbcb3709aef248f8..61290ea721c8b778adb89c2e1af24a1f1a7154d3 100644 (file)
@@ -1128,6 +1128,19 @@ again:
                list_del(&page->lru);
                pcp->count--;
        } else {
+               if (unlikely(gfp_flags & __GFP_NOFAIL)) {
+                       /*
+                        * __GFP_NOFAIL is not to be used in new code.
+                        *
+                        * All __GFP_NOFAIL callers should be fixed so that they
+                        * properly detect and handle allocation failures.
+                        *
+                        * We most definitely don't want callers attempting to
+                        * allocate greater than single-page units with
+                        * __GFP_NOFAIL.
+                        */
+                       WARN_ON_ONCE(order > 0);
+               }
                spin_lock_irqsave(&zone->lock, flags);
                page = __rmqueue(zone, order, migratetype);
                __mod_zone_page_state(zone, NR_FREE_PAGES, -(1 << order));