aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab_common.c
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2013-05-03 14:04:18 -0400
committerPekka Enberg <penberg@kernel.org>2013-05-06 16:22:17 -0400
commit8a965b3baa89ffedc73c0fbc750006c631012ced (patch)
tree96312febbf13b5fe1f956411be7693c07343a7f8 /mm/slab_common.c
parent6286ae97d10ea2b5cd90532163797ab217bfdbdf (diff)
mm, slab_common: Fix bootstrap creation of kmalloc caches
For SLAB the kmalloc caches must be created in ascending sizes in order for the OFF_SLAB sub-slab cache to work properly. Create the non power of two caches immediately after the prior power of two kmalloc cache. Do not create the non power of two caches before all other caches. Reported-and-tested-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Christoph Lamete <cl@linux.com> Link: http://lkml.kernel.org/r/201305040348.CIF81716.OStQOHFJMFLOVF@I-love.SAKURA.ne.jp Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slab_common.c')
-rw-r--r--mm/slab_common.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/mm/slab_common.c b/mm/slab_common.c
index c5d352e73d81..d2517b05d5bc 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -442,18 +442,24 @@ void __init create_kmalloc_caches(unsigned long flags)
442 for (i = 128 + 8; i <= 192; i += 8) 442 for (i = 128 + 8; i <= 192; i += 8)
443 size_index[size_index_elem(i)] = 8; 443 size_index[size_index_elem(i)] = 8;
444 } 444 }
445 /* Caches that are not of the two-to-the-power-of size */ 445 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
446 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1]) 446 if (!kmalloc_caches[i]) {
447 kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
448
449 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2])
450 kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
451
452 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++)
453 if (!kmalloc_caches[i])
454 kmalloc_caches[i] = create_kmalloc_cache(NULL, 447 kmalloc_caches[i] = create_kmalloc_cache(NULL,
455 1 << i, flags); 448 1 << i, flags);
456 449
450 /*
451 * Caches that are not of the two-to-the-power-of size.
452 * These have to be created immediately after the
453 * earlier power of two caches
454 */
455 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
456 kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
457
458 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
459 kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
460 }
461 }
462
457 /* Kmalloc array is now usable */ 463 /* Kmalloc array is now usable */
458 slab_state = UP; 464 slab_state = UP;
459 465