SLUB: fix ARCH_KMALLOC_MINALIGN cases 64 and 256

If the minalign is 64 bytes, then the 96 byte cache should not be created
because it would conflict with the 128 byte cache.

If the minalign is 256 bytes, patching the size_index table should not
result in a buffer overrun.

The calculation "(i - 1) / 8" used to access size_index[] is moved to
a separate function as suggested by Christoph Lameter.

Acked-by: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
This commit is contained in:
Aaro Koskinen
2009-08-28 14:28:54 +03:00
committed by Pekka Enberg
parent cf5d11317e
commit acdfcd04d9
2 changed files with 26 additions and 10 deletions

View File

@@ -152,12 +152,10 @@ 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)
if (KMALLOC_MIN_SIZE <= 32 && size > 64 && size <= 96)
return 1;
if (size > 128 && size <= 192)
if (KMALLOC_MIN_SIZE <= 64 && size > 128 && size <= 192)
return 2;
#endif
if (size <= 8) return 3;
if (size <= 16) return 4;
if (size <= 32) return 5;