]> git.baikalelectronics.ru Git - kernel.git/commitdiff
slab: improve checking for invalid gfp_flags
authorAndrew Morton <akpm@linux-foundation.org>
Wed, 10 Dec 2014 23:42:25 +0000 (15:42 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Dec 2014 01:41:04 +0000 (17:41 -0800)
The code goes BUG, but doesn't tell us which bits were unexpectedly set.
Print that out.

Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/slab.c
mm/slub.c

index a2152a2573dd28b07daf557f09614a75e5104b49..79e15f0a2a6e59a8d65fdefbf2695f1353364f19 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2590,7 +2590,10 @@ static int cache_grow(struct kmem_cache *cachep,
         * Be lazy and only check for valid flags here,  keeping it out of the
         * critical path in kmem_cache_alloc().
         */
-       BUG_ON(flags & GFP_SLAB_BUG_MASK);
+       if (unlikely(flags & GFP_SLAB_BUG_MASK)) {
+               pr_emerg("gfp: %u\n", flags & GFP_SLAB_BUG_MASK);
+               BUG();
+       }
        local_flags = flags & (GFP_CONSTRAINT_MASK|GFP_RECLAIM_MASK);
 
        /* Take the node list lock to change the colour_next on this node */
index cf4f3c480b983c56be8a8e9f24ad7922e92c296e..386bbed76e945c32d758f4e9b0f396ef0a4714af 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1377,7 +1377,10 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
        int order;
        int idx;
 
-       BUG_ON(flags & GFP_SLAB_BUG_MASK);
+       if (unlikely(flags & GFP_SLAB_BUG_MASK)) {
+               pr_emerg("gfp: %u\n", flags & GFP_SLAB_BUG_MASK);
+               BUG();
+       }
 
        page = allocate_slab(s,
                flags & (GFP_RECLAIM_MASK | GFP_CONSTRAINT_MASK), node);