slab allocators: Remove SLAB_CTOR_ATOMIC
authorChristoph Lameter <clameter@sgi.com>
Sun, 6 May 2007 21:50:17 +0000 (14:50 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Mon, 7 May 2007 19:12:57 +0000 (12:12 -0700)
SLAB_CTOR atomic is never used which is no surprise since I cannot imagine
that one would want to do something serious in a constructor or destructor.
 In particular given that the slab allocators run with interrupts disabled.
 Actions in constructors and destructors are by their nature very limited
and usually do not go beyond initializing variables and list operations.

(The i386 pgd ctor and dtors do take a spinlock in constructor and
destructor.....  I think that is the furthest we go at this point.)

There is no flag passed to the destructor so removing SLAB_CTOR_ATOMIC also
establishes a certain symmetry.

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/slab.h
mm/slab.c
mm/slub.c

index 1ffe0a959cd4d3971e4633b3f18c0a44dd7dfc62..71829efc40ba22595419c6d2c46f9d3177e4b590 100644 (file)
@@ -34,7 +34,6 @@ typedef struct kmem_cache kmem_cache_t __deprecated;
 
 /* Flags passed to a constructor functions */
 #define SLAB_CTOR_CONSTRUCTOR  0x001UL         /* If not set, then deconstructor */
-#define SLAB_CTOR_ATOMIC       0x002UL         /* Tell constructor it can't sleep */
 
 /*
  * struct kmem_cache related prototypes
index a877d6f3d68730d9bce92f6f3c24a545755e1596..52ecf7599a7b7a8d22e12cb8ad1eef98122cb935 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2752,13 +2752,6 @@ static int cache_grow(struct kmem_cache *cachep,
 
        ctor_flags = SLAB_CTOR_CONSTRUCTOR;
        local_flags = (flags & GFP_LEVEL_MASK);
-       if (!(local_flags & __GFP_WAIT))
-               /*
-                * Not allowed to sleep.  Need to tell a constructor about
-                * this - it might need to know...
-                */
-               ctor_flags |= SLAB_CTOR_ATOMIC;
-
        /* Take the l3 list lock to change the colour_next on this node */
        check_irq_off();
        l3 = cachep->nodelists[nodeid];
@@ -3092,14 +3085,8 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
        }
 #endif
        objp += obj_offset(cachep);
-       if (cachep->ctor && cachep->flags & SLAB_POISON) {
-               unsigned long ctor_flags = SLAB_CTOR_CONSTRUCTOR;
-
-               if (!(flags & __GFP_WAIT))
-                       ctor_flags |= SLAB_CTOR_ATOMIC;
-
-               cachep->ctor(objp, cachep, ctor_flags);
-       }
+       if (cachep->ctor && cachep->flags & SLAB_POISON)
+               cachep->ctor(objp, cachep, SLAB_CTOR_CONSTRUCTOR);
 #if ARCH_SLAB_MINALIGN
        if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
                printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
index bd86182e595e62d589b00cfa6e42874dc6b6da1b..347e44821bcb8b7e5b10a77a1c79c7debed1caa9 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -802,14 +802,8 @@ static void setup_object(struct kmem_cache *s, struct page *page,
                init_tracking(s, object);
        }
 
-       if (unlikely(s->ctor)) {
-               int mode = SLAB_CTOR_CONSTRUCTOR;
-
-               if (!(s->flags & __GFP_WAIT))
-                       mode |= SLAB_CTOR_ATOMIC;
-
-               s->ctor(object, s, mode);
-       }
+       if (unlikely(s->ctor))
+               s->ctor(object, s, SLAB_CTOR_CONSTRUCTOR);
 }
 
 static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
This page took 0.030747 seconds and 5 git commands to generate.