linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pekka J Enberg <penberg@cs.Helsinki.FI>
To: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Christoph Lameter <clameter@sgi.com>,
	Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	manfred@colorfullife.com
Subject: Re: [patch 2/2] slab: always consider arch mandated alignment
Date: Wed, 26 Jul 2006 14:16:06 +0300 (EEST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0607261411420.17986@sbz-30.cs.Helsinki.FI> (raw)
In-Reply-To: <20060726105204.GF9592@osiris.boeblingen.de.ibm.com>

On Wed, 26 Jul 2006, Heiko Carstens wrote:
> We only specify ARCH_KMALLOC_MINALIGN, since that aligns only the kmalloc
> caches, but it doesn't disable debugging on other caches that are created
> via kmem_cache_create() where an alignment of e.g. 0 is specified.
> 
> The point of the first patch is: why should the slab cache be allowed to chose
> an aligment that is less than what the caller specified? This does very likely
> break things.

Ah, yes, you are absolutely right. We need to respect caller mandated 
alignment too. How about this?

			Pekka

[PATCH] slab: respect architecture and caller mandated alignment

Ensure cache alignment is always at minimum what the architecture or 
caller mandates even if slab debugging is enabled.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---

diff --git a/mm/slab.c b/mm/slab.c
index 0f20843..3767460 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2097,6 +2097,15 @@ #endif
 	} 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;
@@ -2123,20 +2132,19 @@ #endif
 #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)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2006-07-26 11:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060722110601.GA9572@osiris.boeblingen.de.ibm.com>
     [not found] ` <Pine.LNX.4.64.0607220748160.13737@schroedinger.engr.sgi.com>
     [not found]   ` <20060722162607.GA10550@osiris.ibm.com>
     [not found]     ` <Pine.LNX.4.64.0607221241130.14513@schroedinger.engr.sgi.com>
     [not found]       ` <20060723073500.GA10556@osiris.ibm.com>
     [not found]         ` <Pine.LNX.4.64.0607230558560.15651@schroedinger.engr.sgi.com>
     [not found]           ` <20060723162427.GA10553@osiris.ibm.com>
2006-07-26  8:50             ` [patch 1/2] slab: always consider caller " Heiko Carstens, Heiko Carstens
2006-07-26  8:51             ` [patch 2/2] slab: always consider arch " Heiko Carstens, Heiko Carstens
2006-07-26 10:05               ` Pekka J Enberg
2006-07-26 10:13                 ` Heiko Carstens
2006-07-26 10:37                   ` Pekka J Enberg
2006-07-26 10:52                     ` Heiko Carstens
2006-07-26 11:16                       ` Pekka J Enberg [this message]
2006-07-26 11:26                         ` Heiko Carstens
2006-07-26 18:06                         ` Manfred Spraul
2006-07-26 18:19                           ` Christoph Lameter
2006-07-26 18:45                             ` Manfred Spraul
2006-07-26 18:59                               ` Christoph Lameter
2006-07-26 19:28                                 ` Manfred Spraul
2006-07-26 19:31                                   ` Christoph Lameter
2006-07-26 19:37                                     ` Manfred Spraul
2006-07-26 19:47                                       ` Christoph Lameter
2006-07-27  5:33                                         ` Pekka J Enberg
2006-07-27  5:47                                           ` Pekka J Enberg
2006-07-27  4:24                                     ` Pekka J Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.58.0607261411420.17986@sbz-30.cs.Helsinki.FI \
    --to=penberg@cs.helsinki.fi \
    --cc=akpm@osdl.org \
    --cc=clameter@sgi.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=manfred@colorfullife.com \
    --cc=schwidefsky@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox