]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
slub: Do not use 192 byte sized cache if minimum alignment is 128 byte
authorChristoph Lameter <cl@linux-foundation.org>
Thu, 3 Jul 2008 14:14:26 +0000 (09:14 -0500)
committerPekka Enberg <penberg@cs.helsinki.fi>
Thu, 3 Jul 2008 16:01:55 +0000 (19:01 +0300)
The 192 byte cache is not necessary if we have a basic alignment of 128
byte. If it would be used then the 192 would be aligned to the next 128 byte
boundary which would result in another 256 byte cache. Two 256 kmalloc caches
cause sysfs to complain about a duplicate entry.

MIPS needs 128 byte aligned kmalloc caches and spits out warnings on boot without
this patch.

Signed-off-by: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
include/linux/slub_def.h
mm/slub.c

index 71e43a12ebbbc62521498155d6bace9b2b0e0585..cef6f8fddd7dae42d667297c197f43cc8fdcc142 100644 (file)
@@ -137,10 +137,12 @@ static __always_inline int kmalloc_index(size_t size)
        if (size <= KMALLOC_MIN_SIZE)
                return KMALLOC_SHIFT_LOW;
 
+#if KMALLOC_MIN_SIZE <= 64
        if (size > 64 && size <= 96)
                return 1;
        if (size > 128 && size <= 192)
                return 2;
+#endif
        if (size <=          8) return 3;
        if (size <=         16) return 4;
        if (size <=         32) return 5;
index 0987d1cd943cc88d626a7d1b1097ba1f83243591..2c9a62d1f429d96f0daf9048e3d6cd23df9cf03c 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2995,8 +2995,6 @@ void __init kmem_cache_init(void)
                create_kmalloc_cache(&kmalloc_caches[1],
                                "kmalloc-96", 96, GFP_KERNEL);
                caches++;
-       }
-       if (KMALLOC_MIN_SIZE <= 128) {
                create_kmalloc_cache(&kmalloc_caches[2],
                                "kmalloc-192", 192, GFP_KERNEL);
                caches++;
@@ -3026,6 +3024,16 @@ void __init kmem_cache_init(void)
        for (i = 8; i < KMALLOC_MIN_SIZE; i += 8)
                size_index[(i - 1) / 8] = KMALLOC_SHIFT_LOW;
 
+       if (KMALLOC_MIN_SIZE == 128) {
+               /*
+                * The 192 byte sized cache is not used if the alignment
+                * is 128 byte. Redirect kmalloc to use the 256 byte cache
+                * instead.
+                */
+               for (i = 128 + 8; i <= 192; i += 8)
+                       size_index[(i - 1) / 8] = 8;
+       }
+
        slab_state = UP;
 
        /* Provide the correct kmalloc names now that the caches are up */