From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750715AbWGVLI0 (ORCPT ); Sat, 22 Jul 2006 07:08:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750720AbWGVLI0 (ORCPT ); Sat, 22 Jul 2006 07:08:26 -0400 Received: from mtagate2.uk.ibm.com ([195.212.29.135]:58202 "EHLO mtagate2.uk.ibm.com") by vger.kernel.org with ESMTP id S1750715AbWGVLIZ (ORCPT ); Sat, 22 Jul 2006 07:08:25 -0400 Date: Sat, 22 Jul 2006 13:06:01 +0200 From: Heiko Carstens To: Andrew Morton Cc: Christoph Lameter , linux-kernel@vger.kernel.org Subject: [patch] slab: always follow arch requested alignments Message-ID: <20060722110601.GA9572@osiris.boeblingen.de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: mutt-ng/devel-r804 (Linux) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org From: Heiko Carstens In kmem_cache_create(): always check if BYTES_PER_WORD is less than ARCH_SLAB_MINALIGN and disable debug options that would set the alignment to BYTES_PER_WORD. This will make sure that all slab caches will have at least an ARCH_SLAB_MINALIGN alignment. In addition make sure that a caller mandated align which is greater than BYTES_PER_WORD also disables the same debug options. This makes sure that ARCH_KMALLOC_MINALIGN also has an effect if CONFIG_DEBUG_SLAB is set. Cc: Christoph Lameter Signed-off-by: Heiko Carstens --- mm/slab.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/slab.c b/mm/slab.c index 0f20843..1f6fc04 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2103,12 +2103,18 @@ #endif 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; if (ralign > BYTES_PER_WORD) flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER); } + if (align > BYTES_PER_WORD) + flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER); + /* * 4) Store it. Note that the debug code below can reduce * the alignment to BYTES_PER_WORD.