--- mm/slub.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2007-08-21 06:42:43.000000000 -0700 +++ linux-2.6/mm/slub.c 2007-08-21 06:48:29.000000000 -0700 @@ -986,7 +986,9 @@ out: __setup("slub_debug", setup_slub_debug); -static void kmem_cache_open_debug_check(struct kmem_cache *s) +static unsigned long calculate_debug_flags(unsigned long flags, + const char *name, unsigned long size, + void (*ctor)(void *, struct kmem_cache *, unsigned long)) { /* * The page->offset field is only 16 bit wide. This is an offset @@ -1000,19 +1002,20 @@ static void kmem_cache_open_debug_check( * Debugging or ctor may create a need to move the free * pointer. Fail if this happens. */ - if (s->objsize >= 65535 * sizeof(void *)) { - BUG_ON(s->flags & (SLAB_RED_ZONE | SLAB_POISON | + if (size >= 65535 * sizeof(void *)) { + BUG_ON(flags & (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | SLAB_DESTROY_BY_RCU)); - BUG_ON(s->ctor); + BUG_ON(ctor); } else /* * Enable debugging if selected on the kernel commandline. */ if (slub_debug && (!slub_debug_slabs || - strncmp(slub_debug_slabs, s->name, + strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs)) == 0)) - s->flags |= slub_debug; + flags |= slub_debug; + return flags; } #else static inline void setup_object_debug(struct kmem_cache *s, @@ -1029,7 +1032,12 @@ static inline int slab_pad_check(struct static inline int check_object(struct kmem_cache *s, struct page *page, void *object, int active) { return 1; } static inline void add_full(struct kmem_cache_node *n, struct page *page) {} -static inline void kmem_cache_open_debug_check(struct kmem_cache *s) {} +static inline void calculate_debug_flags(unsigned long flags, + const char *name, unsigned long size, + void (*)(void *, struct kmem_cache *s, unsigned long)) +{ + return flags; +} #define slub_debug 0 #endif /* @@ -2083,7 +2091,6 @@ static int kmem_cache_open(struct kmem_c s->objsize = size; s->flags = flags; s->align = align; - kmem_cache_open_debug_check(s); if (!calculate_sizes(s)) goto error; @@ -2699,6 +2706,7 @@ struct kmem_cache *kmem_cache_create(con { struct kmem_cache *s; + flags = calculate_debug_flags(flags, name, size, ctor); down_write(&slub_lock); s = find_mergeable(size, align, flags, ctor); if (s) {