Skip to content

Commit 7338999

Browse files
Hyunmin Leetehcaster
authored andcommitted
mm/slub: remove the check for NULL kmalloc_caches
If the same size kmalloc cache already exists, it should not be created again. So there is the check for NULL kmalloc_caches before calling the kmalloc creation function. However, new_kmalloc_cache() itself checks NULL kmalloc_cahces before cache creation. Therefore, the NULL check is not necessary in this function. Signed-off-by: Hyunmin Lee <[email protected]> Co-developed-by: Jeungwoo Yoo <[email protected]> Signed-off-by: Jeungwoo Yoo <[email protected]> Co-developed-by: Sangyun Kim <[email protected]> Signed-off-by: Sangyun Kim <[email protected]> Cc: Hyeonggon Yoo <[email protected]> Cc: Gwan-gyeong Mun <[email protected]> Reviewed-by: Christoph Lameter <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]>
1 parent 306c4ac commit 7338999

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

mm/slab_common.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -917,16 +917,14 @@ void __init create_kmalloc_caches(void)
917917
*/
918918
for (type = KMALLOC_NORMAL; type < NR_KMALLOC_TYPES; type++) {
919919
/* Caches that are NOT of the two-to-the-power-of size. */
920-
if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[type][1])
920+
if (KMALLOC_MIN_SIZE <= 32)
921921
new_kmalloc_cache(1, type);
922-
if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[type][2])
922+
if (KMALLOC_MIN_SIZE <= 64)
923923
new_kmalloc_cache(2, type);
924924

925925
/* Caches that are of the two-to-the-power-of size. */
926-
for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
927-
if (!kmalloc_caches[type][i])
928-
new_kmalloc_cache(i, type);
929-
}
926+
for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++)
927+
new_kmalloc_cache(i, type);
930928
}
931929
#ifdef CONFIG_RANDOM_KMALLOC_CACHES
932930
random_kmalloc_seed = get_random_u64();

0 commit comments

Comments
 (0)