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>
This commit is contained in:
Родитель
6286ae97d1
Коммит
8a965b3baa
|
@ -442,18 +442,24 @@ void __init create_kmalloc_caches(unsigned long flags)
|
||||||
for (i = 128 + 8; i <= 192; i += 8)
|
for (i = 128 + 8; i <= 192; i += 8)
|
||||||
size_index[size_index_elem(i)] = 8;
|
size_index[size_index_elem(i)] = 8;
|
||||||
}
|
}
|
||||||
/* Caches that are not of the two-to-the-power-of size */
|
for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
|
||||||
if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1])
|
if (!kmalloc_caches[i]) {
|
||||||
kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
|
|
||||||
|
|
||||||
if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2])
|
|
||||||
kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
|
|
||||||
|
|
||||||
for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++)
|
|
||||||
if (!kmalloc_caches[i])
|
|
||||||
kmalloc_caches[i] = create_kmalloc_cache(NULL,
|
kmalloc_caches[i] = create_kmalloc_cache(NULL,
|
||||||
1 << i, flags);
|
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);
|
||||||
|
|
||||||
|
if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
|
||||||
|
kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Kmalloc array is now usable */
|
/* Kmalloc array is now usable */
|
||||||
slab_state = UP;
|
slab_state = UP;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче