Re: [patch] slab: always follow arch requested alignments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 26 Jul 2006, Pekka Enberg wrote:

> On 7/26/06, Christoph Lameter <[email protected]> wrote:
> > Your patch only deals with ARCH_SLAB_MINALIGN. kmem_cache_create() never
> > uses ARCH_KMALLOC_MINALIGN only kmem_cache_init() does by passing it to
> > kmem_cache_create.  ARCH_KMALLOC_MINALIGN will still be ignored.
> 
> Yes, in which case the caller mandated align will be, well,
> ARCH_KMALLOC_MINALIGN. The patch changes kmem_cache_create to respect
> caller mandated alignment too.

As far as I understood Heiko s390 does not set ARCH_SLAB_MINALIGN
because they do not want alignent for all caches.

The following patch adds an option SLAB_DEBUG_OVERRIDE to switch off
debugging if its on by default. S390 would have to set ARCH_KMALLOC_FLAGS
to SLAB_DEBUG_OVERRIDE. The flag will then be passed in 
kmem_cache_init to kmem_cache_create(). This approach also preserves the 
existing slab behavior for all other archs.

Index: linux-2.6/include/linux/slab.h
===================================================================
--- linux-2.6.orig/include/linux/slab.h	2006-07-26 05:14:33.000000000 -0700
+++ linux-2.6/include/linux/slab.h	2006-07-26 05:15:08.000000000 -0700
@@ -46,6 +46,7 @@ typedef struct kmem_cache kmem_cache_t;
 #define SLAB_PANIC		0x00040000UL	/* panic if kmem_cache_create() fails */
 #define SLAB_DESTROY_BY_RCU	0x00080000UL	/* defer freeing pages to RCU */
 #define SLAB_MEM_SPREAD		0x00100000UL	/* Spread some memory over cpuset */
+#define SLAB_DEBUG_OVERRIDE	0x00200000UL	/* Do not debug this slab */
 
 /* flags passed to a constructor func */
 #define	SLAB_CTOR_CONSTRUCTOR	0x001UL		/* if not set, then deconstructor */
Index: linux-2.6/mm/slab.c
===================================================================
--- linux-2.6.orig/mm/slab.c	2006-07-26 05:13:59.000000000 -0700
+++ linux-2.6/mm/slab.c	2006-07-26 05:17:59.000000000 -0700
@@ -2055,8 +2055,11 @@ kmem_cache_create (const char *name, siz
 	 * above the next power of two: caches with object sizes just above a
 	 * power of two have a significant amount of internal fragmentation.
 	 */
-	if (size < 4096 || fls(size - 1) == fls(size-1 + 3 * BYTES_PER_WORD))
-		flags |= SLAB_RED_ZONE | SLAB_STORE_USER;
+
+	if (!(flags & DEBUG_OVERRIDE) &&
+		size < 4096 ||
+		(fls(size - 1) == fls(size-1 + 3 * BYTES_PER_WORD)))
+			flags |= SLAB_RED_ZONE | SLAB_STORE_USER;
 	if (!(flags & SLAB_DESTROY_BY_RCU))
 		flags |= SLAB_POISON;
 #endif

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux