Re: [patch] slab: always follow arch requested alignments

From: Christoph Lameter
Date: Sat Jul 22 2006 - 15:42:08 EST


On Sat, 22 Jul 2006, Heiko Carstens wrote:

> Sorry, I should have mentioned it: on s390 (32 bit) we set
> #define ARCH_KMALLOC_MINALIGN 8.
> This is needed since our common I/O layer allocates data structures that need
> to have an eight byte alignment. Now, if I turn on DEBUG_SLAB, nothing works
> anymore, simply because the slab cache code ignores ARCH_KMALLOC_MINALIGN and
> uses an BYTES_PER_WORD alignment instead, which it shouldn't:
>
> also from mm/slab.c :
>
> #ifndef ARCH_KMALLOC_MINALIGN
> /*
> * Enforce a minimum alignment for the kmalloc caches.
> * Usually, the kmalloc caches are cache_line_size() aligned, except when
> * DEBUG and FORCED_DEBUG are enabled, then they are BYTES_PER_WORD aligned.
> * Some archs want to perform DMA into kmalloc caches and need a guaranteed
> * alignment larger than BYTES_PER_WORD. ARCH_KMALLOC_MINALIGN allows that.
> * Note that this flag disables some debug features.
> */
> #define ARCH_KMALLOC_MINALIGN 0
> #endif
>
> Since that didn't work I thought why not set ARCH_SLAB_MINALIGN to 8, since
> that would (according to the description) guarantee that _all_ caches would
> have an 8 byte alignment. But that didn't work too.

Why did that not work

See kmem_cache_create():
/* 2) arch mandated alignment: disables debug if necessary */
if (ralign < ARCH_SLAB_MINALIGN) {
ralign = ARCH_SLAB_MINALIGN;
if (ralign > BYTES_PER_WORD)
flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/