Index: linux-2.6.20-mm2/mm/slub.c =================================================================== --- linux-2.6.20-mm2.orig/mm/slub.c 2007-02-21 21:17:21.000000000 -0800 +++ linux-2.6.20-mm2/mm/slub.c 2007-02-21 21:40:57.000000000 -0800 @@ -843,6 +843,18 @@ return order; } +static unsigned long calculate_alignment(unsigned long flags, + unsigned long align) +{ + if (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, @@ -893,9 +905,7 @@ 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(flags, align); size = ALIGN(size, align); s->size = size; @@ -1346,7 +1356,7 @@ #ifdef SLUB_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(flags, align)); /* Find the kmalloc slab that would be used for this size */ s = __kmalloc_slab(sz);