1
0
Fork 0

slab: make size_index_elem() unsigned int

size_index_elem() always works with small sizes (kmalloc caches are
32-bit) and returns small indexes.

Link: http://lkml.kernel.org/r/20180305200730.15812-8-adobriyan@gmail.com
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
hifive-unleashed-5.1
Alexey Dobriyan 2018-04-05 16:20:44 -07:00 committed by Linus Torvalds
parent d5f866550d
commit ac914d08bb
1 changed files with 3 additions and 3 deletions

View File

@ -998,7 +998,7 @@ static u8 size_index[24] __ro_after_init = {
2 /* 192 */
};
static inline int size_index_elem(size_t bytes)
static inline unsigned int size_index_elem(unsigned int bytes)
{
return (bytes - 1) / 8;
}
@ -1067,13 +1067,13 @@ const struct kmalloc_info_struct kmalloc_info[] __initconst = {
*/
void __init setup_kmalloc_cache_index_table(void)
{
int i;
unsigned int i;
BUILD_BUG_ON(KMALLOC_MIN_SIZE > 256 ||
(KMALLOC_MIN_SIZE & (KMALLOC_MIN_SIZE - 1)));
for (i = 8; i < KMALLOC_MIN_SIZE; i += 8) {
int elem = size_index_elem(i);
unsigned int elem = size_index_elem(i);
if (elem >= ARRAY_SIZE(size_index))
break;