Index: linux-2.6.21-rc1/mm/slub.c =================================================================== --- linux-2.6.21-rc1.orig/mm/slub.c 2007-02-21 20:39:14.000000000 -0800 +++ linux-2.6.21-rc1/mm/slub.c 2007-02-21 20:46:12.000000000 -0800 @@ -840,6 +840,18 @@ static int calculate_order(int size) return order; } +static unsigned long calculate_alignment(struct kmem_cache *s, + unsigned long align) +{ + if (s->flags & (SLAB_MUST_HWCACHE_ALIGN|SLAB_HWCACHE_ALIGN)) + return L1_CACHE_BYTES; + + if (align < ARCH_SLAB_MINALIGN) + return ARCH_SLAB_MINALIGN; + + return ALIGN(align, sizeof(void *)); +} + int kmem_cache_open(struct kmem_cache *s, const char *name, size_t size, size_t align, unsigned long flags, @@ -890,9 +902,7 @@ int kmem_cache_open(struct kmem_cache *s 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; + align = calculate_alignment(s, align); size = ALIGN(size, align); s->size = size; @@ -1343,7 +1353,7 @@ struct kmem_cache *kmem_cache_create(con #ifdef SLAB_MERGE if (!ctor && !dtor && !(flags & SLUB_NO_MERGE) && align <= ARCH_SLAB_MINALIGN) { - int sz = ALIGN(size, ARCH_SLAB_MINALIGN); + int sz = ALIGN(size, calculate_alignment(s, align)); /* Find the kmalloc slab that would be used for this size */ s = __kmalloc_slab(sz);