From: Chris Mason Date: Wed, 8 May 2013 19:56:28 +0000 (-0400) Subject: mm/slab: Fix crash during slab init X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=956e46efb2478ebff7a871138458fa8124fd18dd;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git mm/slab: Fix crash during slab init Commit 8a965b3baa89 ("mm, slab_common: Fix bootstrap creation of kmalloc caches") introduced a regression that caused us to crash early during boot. The commit was introducing ordering of slab creation, making sure two odd-sized slabs were created after specific powers of two sizes. But, if any of the power of two slabs were created earlier during boot, slabs at index 1 or 2 might not get created at all. This patch makes sure none of the slabs get skipped. Tony Lindgren bisected this down to the offending commit, which really helped because bisect kept bringing me to almost but not quite this one. Signed-off-by: Chris Mason Acked-by: Christoph Lameter Acked-by: Tony Lindgren Acked-by: Soren Brinkmann Tested-by: Tetsuo Handa Tested-by: Konrad Rzeszutek Wilk Signed-off-by: Linus Torvalds --- diff --git a/mm/slab_common.c b/mm/slab_common.c index d2517b05d5bc..ff3218a0f5e1 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -446,18 +446,18 @@ void __init create_kmalloc_caches(unsigned long flags) if (!kmalloc_caches[i]) { kmalloc_caches[i] = create_kmalloc_cache(NULL, 1 << i, flags); + } - /* - * Caches that are not of the two-to-the-power-of size. - * These have to be created immediately after the - * earlier power of two caches - */ - if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6) - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags); + /* + * Caches that are not of the two-to-the-power-of size. + * These have to be created immediately after the + * earlier power of two caches + */ + if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6) + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags); - if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7) - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags); - } + if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7) + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags); } /* Kmalloc array is now usable */