slab: make size_index_elem() unsigned int
authorAlexey Dobriyan <[email protected]>
Thu, 5 Apr 2018 23:20:44 +0000 (16:20 -0700)
committerLinus Torvalds <[email protected]>
Fri, 6 Apr 2018 04:36:23 +0000 (21:36 -0700)
size_index_elem() always works with small sizes (kmalloc caches are
32-bit) and returns small indexes.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Alexey Dobriyan <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/slab_common.c

index dda966e6bc58945d5263d406e8c1823bbb363beb..8abb2a46ae85847cdd169b304b27b3d517e2cd2b 100644 (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;