All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Christoph Lameter <clameter@sgi.com>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	linux-mm@kvack.org, Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 2/2] slab: always consider arch mandated alignment
Date: Wed, 26 Jul 2006 10:51:13 +0200	[thread overview]
Message-ID: <20060726085113.GD9592@osiris.boeblingen.de.ibm.com> (raw)
In-Reply-To: <20060723162427.GA10553@osiris.ibm.com>

From: Heiko Carstens <heiko.carstens@de.ibm.com>

Since ARCH_KMALLOC_MINALIGN didn't work on s390 I tried ARCH_SLAB_MINALIGN
instead, just to find out that it didn't work too.
In case of CONFIG_DEBUG_SLAB kmem_cache_create() creates caches with an
alignment lesser than ARCH_SLAB_MINALIGN, which it shouldn't according to
this comment in mm/slab.c :

 * Enforce a minimum alignment for all caches.
 * Intended for archs that get misalignment faults even for BYTES_PER_WORD
 * aligned buffers. Includes ARCH_KMALLOC_MINALIGN.
 * If possible: Do not enable this flag for CONFIG_DEBUG_SLAB, it disables
 * some debug features.

For example the following might happen if kmem_cache_create() gets called
with -- size: 64; align: 0; flags with SLAB_HWCACHE_ALIGN, SLAB_RED_ZONE and
SLAB_STORE_USER set. ARCH_SLAB_MINALIGN is 8.
These are the steps as numbered in kmem_cache_create() where 5) is after the
"if (flags & SLAB_RED_ZONE)" statement.

1) align: 0 ralign 64
2) align: 0 ralign 64
3) align: 0 ralign 64
4) align: 64 ralign 64
5) align: 4 ralign 64

Note that in this case in step 2) the flags SLAB_RED_ZONE and SLAB_STORE_USER
don't get masked out and that this causes an BYTES_PER_WORD alignment in
step 5) which is lesser than ARCH_SLAB_MINALIGN.

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

 mm/slab.c |    3 +++
 1 files changed, 3 insertions(+)

Index: linux-2.6/mm/slab.c
===================================================================
--- linux-2.6.orig/mm/slab.c	2006-07-26 09:55:54.000000000 +0200
+++ linux-2.6/mm/slab.c	2006-07-26 09:57:07.000000000 +0200
@@ -2103,6 +2103,9 @@
 		if (ralign > BYTES_PER_WORD)
 			flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
 	}
+	if (BYTES_PER_WORD < ARCH_SLAB_MINALIGN)
+		flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
+
 	/* 3) caller mandated alignment: disables debug if necessary */
 	if (ralign < align) {
 		ralign = align;

WARNING: multiple messages have this Message-ID (diff)
From: Heiko Carstens <heiko.carstens@de.ibm.com>
From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Christoph Lameter <clameter@sgi.com>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	linux-mm@kvack.org, Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 2/2] slab: always consider arch mandated alignment
Date: Wed, 26 Jul 2006 10:51:13 +0200	[thread overview]
Message-ID: <20060726085113.GD9592@osiris.boeblingen.de.ibm.com> (raw)
In-Reply-To: <20060723162427.GA10553@osiris.ibm.com>

Since ARCH_KMALLOC_MINALIGN didn't work on s390 I tried ARCH_SLAB_MINALIGN
instead, just to find out that it didn't work too.
In case of CONFIG_DEBUG_SLAB kmem_cache_create() creates caches with an
alignment lesser than ARCH_SLAB_MINALIGN, which it shouldn't according to
this comment in mm/slab.c :

 * Enforce a minimum alignment for all caches.
 * Intended for archs that get misalignment faults even for BYTES_PER_WORD
 * aligned buffers. Includes ARCH_KMALLOC_MINALIGN.
 * If possible: Do not enable this flag for CONFIG_DEBUG_SLAB, it disables
 * some debug features.

For example the following might happen if kmem_cache_create() gets called
with -- size: 64; align: 0; flags with SLAB_HWCACHE_ALIGN, SLAB_RED_ZONE and
SLAB_STORE_USER set. ARCH_SLAB_MINALIGN is 8.
These are the steps as numbered in kmem_cache_create() where 5) is after the
"if (flags & SLAB_RED_ZONE)" statement.

1) align: 0 ralign 64
2) align: 0 ralign 64
3) align: 0 ralign 64
4) align: 64 ralign 64
5) align: 4 ralign 64

Note that in this case in step 2) the flags SLAB_RED_ZONE and SLAB_STORE_USER
don't get masked out and that this causes an BYTES_PER_WORD alignment in
step 5) which is lesser than ARCH_SLAB_MINALIGN.

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

 mm/slab.c |    3 +++
 1 files changed, 3 insertions(+)

Index: linux-2.6/mm/slab.c
===================================================================
--- linux-2.6.orig/mm/slab.c	2006-07-26 09:55:54.000000000 +0200
+++ linux-2.6/mm/slab.c	2006-07-26 09:57:07.000000000 +0200
@@ -2103,6 +2103,9 @@
 		if (ralign > BYTES_PER_WORD)
 			flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
 	}
+	if (BYTES_PER_WORD < ARCH_SLAB_MINALIGN)
+		flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
+
 	/* 3) caller mandated alignment: disables debug if necessary */
 	if (ralign < align) {
 		ralign = align;

--
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>

  parent reply	other threads:[~2006-07-26  8:53 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-22 11:06 [patch] slab: always follow arch requested alignments Heiko Carstens
2006-07-22 12:06 ` Pekka Enberg
2006-07-22 14:50 ` Christoph Lameter
2006-07-22 16:26   ` Heiko Carstens
2006-07-22 19:42     ` Christoph Lameter
2006-07-23  7:35       ` Heiko Carstens
2006-07-23 13:03         ` Christoph Lameter
2006-07-23 16:24           ` Heiko Carstens
2006-07-26  8:49             ` Heiko Carstens
2006-07-26  9:55               ` Pekka J Enberg
2006-07-26  8:50             ` [patch 1/2] slab: always consider caller mandated alignment Heiko Carstens
2006-07-26  8:50               ` Heiko Carstens, Heiko Carstens
2006-07-26  8:51             ` Heiko Carstens [this message]
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:05                 ` Pekka J Enberg
2006-07-26 10:13                 ` Heiko Carstens
2006-07-26 10:13                   ` Heiko Carstens
2006-07-26 10:37                   ` Pekka J Enberg
2006-07-26 10:37                     ` Pekka J Enberg
2006-07-26 10:52                     ` Heiko Carstens
2006-07-26 10:52                       ` Heiko Carstens
2006-07-26 11:16                       ` Pekka J Enberg
2006-07-26 11:16                         ` Pekka J Enberg
2006-07-26 11:26                         ` Heiko Carstens
2006-07-26 11:26                           ` Heiko Carstens
2006-07-26 18:06                         ` Manfred Spraul
2006-07-26 18:06                           ` Manfred Spraul
2006-07-26 18:19                           ` Christoph Lameter
2006-07-26 18:19                             ` Christoph Lameter
2006-07-26 18:45                             ` Manfred Spraul
2006-07-26 18:45                               ` Manfred Spraul
2006-07-26 18:59                               ` Christoph Lameter
2006-07-26 18:59                                 ` Christoph Lameter
2006-07-26 19:28                                 ` Manfred Spraul
2006-07-26 19:28                                   ` Manfred Spraul
2006-07-26 19:31                                   ` Christoph Lameter
2006-07-26 19:31                                     ` Christoph Lameter
2006-07-26 19:37                                     ` Manfred Spraul
2006-07-26 19:37                                       ` Manfred Spraul
2006-07-26 19:47                                       ` Christoph Lameter
2006-07-26 19:47                                         ` Christoph Lameter
2006-07-27  5:33                                         ` Pekka J Enberg
2006-07-27  5:33                                           ` Pekka J Enberg
2006-07-27  5:47                                           ` Pekka J Enberg
2006-07-27  5:47                                             ` Pekka J Enberg
2006-07-27  4:24                                     ` Pekka J Enberg
2006-07-27  4:24                                       ` Pekka J Enberg
2006-07-26 11:22     ` [patch] slab: always follow arch requested alignments Pekka Enberg
2006-07-26 11:29       ` Christoph Lameter
2006-07-26 11:32         ` Pekka J Enberg
2006-07-26 11:41           ` Christoph Lameter
2006-07-26 11:48             ` Pekka J Enberg
2006-07-26 11:49               ` Pekka J Enberg
2006-07-26 11:55                 ` Christoph Lameter
2006-07-26 12:05                   ` Pekka Enberg
2006-07-26 12:20                     ` Christoph Lameter
2006-07-26 12:31                       ` Pekka J Enberg
2006-07-26 15:24                         ` Christoph Lameter
2006-07-26 15:43                           ` Pekka Enberg
2006-07-26 16:25                             ` Christoph Lameter
2006-07-26 18:24                             ` Manfred Spraul
2006-07-26 18:28                               ` Christoph Lameter
2006-07-26 12:35                       ` Pekka J Enberg
2006-07-26 12:36                         ` 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=20060726085113.GD9592@osiris.boeblingen.de.ibm.com \
    --to=heiko.carstens@de.ibm.com \
    --cc=akpm@osdl.org \
    --cc=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@cs.helsinki.fi \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.