Index: linux-2.6.21-rc6/include/linux/slab.h =================================================================== --- linux-2.6.21-rc6.orig/include/linux/slab.h 2007-04-20 22:20:15.000000000 -0700 +++ linux-2.6.21-rc6/include/linux/slab.h 2007-04-20 22:28:27.000000000 -0700 @@ -32,9 +32,21 @@ typedef struct kmem_cache kmem_cache_t _ #define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ #define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ -/* 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 */ +#define SLAB_HAVE_CTOR 0x00000001UL /* Cache has constructor */ +#define SLAB_HAVE_DTOR 0x00000002UL /* Cache has destructor */ +#define SLAB_CAN_FREE 0x00000004UL /* Cache can free objects */ + +/* Flags passed through the callback function */ +#define SLAB_CALLBACK_CTOR 0x00000001UL /* Constructor callback */ +#define SLAB_CALLBACK_DTOR 0x00000002UL /* Destructor callback */ +#define SLAB_CALLBACK_GETREF 0x00000004UL /* Get a reference */ +#define SLAB_CALLBACK_FREE 0x00000008UL /* Free/Move object */ + +#define SLAB_CALLBACK_ATOMIC 0x00010000UL /* The callback is atomic */ + +/* Compatibility definitions */ +#define SLAB_CTOR_CONSTRUCTOR SLAB_CALLBACK_CTOR +#define SLAB_CTOR_ATOMIC SLAB_CALLBACK_ATOMIC /* * struct kmem_cache related prototypes @@ -44,8 +56,7 @@ int slab_is_available(void); struct kmem_cache *kmem_cache_create(const char *, size_t, size_t, unsigned long, - void (*)(void *, struct kmem_cache *, unsigned long), - void (*)(void *, struct kmem_cache *, unsigned long)); + int (*)(void *, struct kmem_cache *, unsigned long)); void kmem_cache_destroy(struct kmem_cache *); int kmem_cache_shrink(struct kmem_cache *); void *kmem_cache_alloc(struct kmem_cache *, gfp_t); @@ -65,7 +76,7 @@ int kmem_ptr_validate(struct kmem_cache */ #define KMEM_CACHE(__struct, __flags) kmem_cache_create(#__struct,\ sizeof(struct __struct), __alignof__(struct __struct),\ - (__flags), NULL, NULL) + (__flags), NULL) #ifdef CONFIG_NUMA extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node); Index: linux-2.6.21-rc6/include/linux/slub_def.h =================================================================== --- linux-2.6.21-rc6.orig/include/linux/slub_def.h 2007-04-20 22:25:54.000000000 -0700 +++ linux-2.6.21-rc6/include/linux/slub_def.h 2007-04-20 22:26:10.000000000 -0700 @@ -41,8 +41,7 @@ struct kmem_cache { /* Allocation and freeing of slabs */ int objects; /* Number of objects in slab */ int refcount; /* Refcount for slab cache destroy */ - void (*ctor)(void *, struct kmem_cache *, unsigned long); - void (*dtor)(void *, struct kmem_cache *, unsigned long); + int (*callback)(void *, struct kmem_cache *, unsigned long); int inuse; /* Offset to metadata */ int align; /* Alignment */ const char *name; /* Name (only for display!) */ Index: linux-2.6.21-rc6/mm/slub.c =================================================================== --- linux-2.6.21-rc6.orig/mm/slub.c 2007-04-20 22:28:32.000000000 -0700 +++ linux-2.6.21-rc6/mm/slub.c 2007-04-20 22:30:17.000000000 -0700 @@ -784,13 +784,14 @@ static void setup_object(struct kmem_cac init_tracking(s, object); } - if (unlikely(s->ctor)) { - int mode = SLAB_CTOR_CONSTRUCTOR; + if (s->flags & SLAB_HAVE_CTOR) + callback(object, s, SLAB_CALLBACK_CTOR{ + int mode = SLAB_CALLBACK_CTOR; if (!(s->flags & __GFP_WAIT)) - mode |= SLAB_CTOR_ATOMIC; + mode |= SLAB_CALLBACK_ATOMIC; - s->ctor(object, s, mode); + s->callback(object, s, mode); } }