lkml.org 
[lkml]   [2006]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] slab: respect architecture and caller mandated alignment
On Thu, 27 Jul 2006, Pekka J Enberg wrote:

> As explained by Heiko, on s390 (32-bit) ARCH_KMALLOC_MINALIGN is set to eight
> because their common I/O layer allocates data structures that need to have an
> eight byte alignment. This does not work when CONFIG_SLAB_DEBUG is enabled
> because kmem_cache_create will override alignment to BYTES_PER_WORD which is
> four.
>
> So change kmem_cache_create to ensure cache alignment is always at minimum
> what the architecture or caller mandates even if slab debugging is enabled.

Note that this will disable SLAB_RED_ZONE and SLAB_STORE_USER
for the following SLAB_DEBUG cases:

1. For all slabs if an arch sets ARCH_SLAB_MINALIGN > BYTES_PER_WORD

by:

/* 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);
}

ralign = BYTES_PER_WORD per your change for slab debug.
ARCH_SLAB_MINALIGN > BYTES_PER_WORD -> SLAB_RED_ZONE and SLAB_STORE_USER
off.

2. For all general (kmalloc) slabs if an arch sets
ARCH_KMALLOC_MINALIGN > BYTES_PER_WORD

by:

/* 3) caller mandated alignment: disables debug if necessary */
if (ralign < align) {
ralign = align;
if (ralign > BYTES_PER_WORD)
flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
}

ralign = BYTES_PER_WORD by your change.
align = ARCH_KMALLOC_MINALIGN (passed by kmem_cache_init)
Therefore SLAB_RED_ZONE and SLAB_STORE_USER are always off.

F.e. S/390 will not be able to use slab debug for the general slabs.

You may want to document that change somewhere.


Note that it is not possible to do Redzoning and aligning at the same
time. Redzoning adds a word before and after the object. If you would
align it then you would align the whole thing which would result in an
alignment visible to the slab user of alignment + sizeof(word).
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-07-28 04:29    [W:0.061 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site