Index: linux-2.6.21-rc1/mm/slub.c =================================================================== --- linux-2.6.21-rc1.orig/mm/slub.c 2007-02-28 00:50:10.000000000 -0800 +++ linux-2.6.21-rc1/mm/slub.c 2007-02-28 08:02:48.000000000 -0800 @@ -67,9 +67,11 @@ * Set of flags that will prevent slab merging */ #define SLUB_NEVER_MERGE (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \ - SLAB_DESTROY_BY_RCU | SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | \ SLAB_TRACE) +#define SLUB_MERGE_SAME (SLAB_DEBUG_FREE | SLAB_DESTROY_BY_RCU | \ + SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | SLAB_SANITY) + #ifndef ARCH_KMALLOC_MINALIGN #define ARCH_KMALLOC_MINALIGN sizeof(void *) #endif @@ -297,17 +299,21 @@ /* * Object layout: * - * object + * object address * Bytes of the object to be managed. - * object + objsize - * Filler to reach word boundary. This is also used for redzoning. - * object + inuse - * Filler to reach required alignment boundary - * object + size + * If the freepointer may overlay the object then the free + * pointer is the first word of the object. + * object + s->objsize + * Padding to reach word boundary. This is also used for Redzoning. + * Padding is extended to word size if Redzoning is enabled + * and objsize == inuse. + * object + s->inuse + * A. Free pointer (if we cannot overwrite object on free) + * B. Tracking data for SLAB_STORE_USER + * C. Padding to reach required alignment boundary + * object + s->size * - * Object layouts can only be assured if the slabcache was not merged. If any - * debug options are set then the slabcache will not be merged. If slabs were - * merged then the objsize and inuse boundaries are to be ignored. + * If slabcaches are merged then the objsize and inuse boundaries are to be ignored. */ static int check_object(struct kmem_cache *s, struct page *page, void *object, int active) @@ -1162,19 +1168,14 @@ static int slub_min_order = 0; /* - * Merge control. If this is set then no merging of slab caches into the - * general caches will occur. + * Merge control. If this is set then no merging of slab caches will occur. */ static int slub_nomerge = 0; /* * Debug settings: - * - * Run with with mininum sanity checks during slub development. */ - -// static int slub_debug = 0; -static int slub_debug = SLAB_SANITY; +static int slub_debug = 0; static char *slub_debug_slabs = NULL; @@ -1772,24 +1773,16 @@ static struct kmem_cache *kmem_cache_dup(struct kmem_cache *s, gfp_t flags, const char *name) { - char *x; - atomic_inc(&s->refcount); -#if 0 down_write(&slabstat_sem); if (!s->aliases) s->aliases = kstrdup(name, flags); else { - x = kmalloc(strlen(s->aliases) + strlen(name) + 1, - flags); - strcpy(x, s->aliases); - strcat(x, " "); - strcat(x, name); - kfree(s->aliases); - s->aliases = x; + char *x = s->aliases; + s->aliases = kasprintf(flags, "%s/%s", s->aliases, name); + kfree(x); } up_write(&slabstat_sem); -#endif return s; } @@ -1824,6 +1817,9 @@ if (s->flags & SLUB_NEVER_MERGE) continue; + if (((flags | slub_debug) & SLUB_MERGE_SAME) != + (s->flags & SLUB_MERGE_SAME)) + continue; /* * Check if alignment is compatible. * Courtesy of Adrian Drzewiecki