Index: linux-2.6.20-mm2/mm/slub.c =================================================================== --- linux-2.6.20-mm2.orig/mm/slub.c 2007-02-21 20:04:05.000000000 -0800 +++ linux-2.6.20-mm2/mm/slub.c 2007-02-21 20:28:31.000000000 -0800 @@ -843,6 +843,15 @@ return order; } +static unsigned long get_align(unsigned long size, unsigned long alignment, + unsigned long flags) +{ + if (flags & (SLAB_MUST_HWCACHE_ALIGN|SLAB_HWCACHE_ALIGN)) + return L1_CACHE_BYTES; + + return max(ARCH_SLAB_MINALIGN, ALIGN(alignment, sizeof(void *))); +} + int kmem_cache_open(struct kmem_cache *s, const char *name, size_t size, size_t align, unsigned long flags, @@ -893,12 +902,8 @@ size += sizeof(void *); } - align = max(ARCH_SLAB_MINALIGN, ALIGN(align, sizeof(void *))); - if (flags & (SLAB_MUST_HWCACHE_ALIGN|SLAB_HWCACHE_ALIGN)) - align = L1_CACHE_BYTES; - - size = ALIGN(size, align); - s->size = size; + s->align = get_align(size, align, flags); + size = ALIGN(size, s->align); s->order = calculate_order(size); if (s->order < 0) @@ -1344,9 +1349,8 @@ struct kmem_cache *s; #ifdef SLUB_MERGE - if (!ctor && !dtor && !(flags & SLUB_NO_MERGE) && - align <= ARCH_SLAB_MINALIGN) { - int sz = ALIGN(size, ARCH_SLAB_MINALIGN); + if (!ctor && !dtor && !(flags & SLUB_NO_MERGE)) { + int sz = ALIGN(size, get_align(size, align, flags)); /* Find the kmalloc slab that would be used for this size */ s = __kmalloc_slab(sz);