mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] slab: respect architecture and caller mandated alignment
@ 2006-07-27 12:15 Pekka J Enberg
  2006-07-28  2:25 ` Christoph Lameter
  0 siblings, 1 reply; 4+ messages in thread
From: Pekka J Enberg @ 2006-07-27 12:15 UTC (permalink / raw)
  To: akpm; +Cc: heiko.carstens, clameter, manfred, linux-kernel

From: Pekka Enberg <penberg@cs.helsinki.fi>

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.

Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

 mm/slab.c |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

Index: 2.6/mm/slab.c
===================================================================
--- 2.6.orig/mm/slab.c
+++ 2.6/mm/slab.c
@@ -2097,6 +2097,15 @@ kmem_cache_create (const char *name, siz
 	} else {
 		ralign = BYTES_PER_WORD;
 	}
+
+	/*
+	 * Redzoning and user store require word alignment. Note this will be
+	 * overridden by architecture or caller mandated alignment if either
+	 * is greater than BYTES_PER_WORD.
+	 */
+	if (flags & SLAB_RED_ZONE || flags & SLAB_STORE_USER)
+		ralign = BYTES_PER_WORD;
+
 	/* 2) arch mandated alignment: disables debug if necessary */
 	if (ralign < ARCH_SLAB_MINALIGN) {
 		ralign = ARCH_SLAB_MINALIGN;
@@ -2110,8 +2119,7 @@ kmem_cache_create (const char *name, siz
 			flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
 	}
 	/*
-	 * 4) Store it. Note that the debug code below can reduce
-	 *    the alignment to BYTES_PER_WORD.
+	 * 4) Store it.
 	 */
 	align = ralign;
 
@@ -2123,20 +2131,19 @@ kmem_cache_create (const char *name, siz
 #if DEBUG
 	cachep->obj_size = size;
 
+	/*
+	 * Both debugging options require word-alignment which is calculated
+	 * into align above.
+	 */
 	if (flags & SLAB_RED_ZONE) {
-		/* redzoning only works with word aligned caches */
-		align = BYTES_PER_WORD;
-
 		/* add space for red zone words */
 		cachep->obj_offset += BYTES_PER_WORD;
 		size += 2 * BYTES_PER_WORD;
 	}
 	if (flags & SLAB_STORE_USER) {
-		/* user store requires word alignment and
-		 * one word storage behind the end of the real
-		 * object.
+		/* user store requires one word storage behind the end of
+		 * the real object.
 		 */
-		align = BYTES_PER_WORD;
 		size += BYTES_PER_WORD;
 	}
 #if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-07-28 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-27 12:15 [PATCH] slab: respect architecture and caller mandated alignment Pekka J Enberg
2006-07-28  2:25 ` Christoph Lameter
2006-07-28  6:20   ` Heiko Carstens
2006-07-28 15:19     ` Christoph Lameter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®