Skip to content

Commit

Permalink
mm/slub: remove the check for NULL kmalloc_caches
Browse files Browse the repository at this point in the history
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 <hyunminlr@gmail.com>
Co-developed-by: Jeungwoo Yoo <casionwoo@gmail.com>
Signed-off-by: Jeungwoo Yoo <casionwoo@gmail.com>
Co-developed-by: Sangyun Kim <sangyun.kim@snu.ac.kr>
Signed-off-by: Sangyun Kim <sangyun.kim@snu.ac.kr>
Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Reviewed-by: Christoph Lameter <cl@linux.com>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
  • Loading branch information
Hyunmin Lee authored and Vlastimil Babka committed May 2, 2024
1 parent 306c4ac commit 7338999
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions mm/slab_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,16 +917,14 @@ void __init create_kmalloc_caches(void)
*/
for (type = KMALLOC_NORMAL; type < NR_KMALLOC_TYPES; type++) {
/* Caches that are NOT of the two-to-the-power-of size. */
if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[type][1])
if (KMALLOC_MIN_SIZE <= 32)
new_kmalloc_cache(1, type);
if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[type][2])
if (KMALLOC_MIN_SIZE <= 64)
new_kmalloc_cache(2, type);

/* Caches that are of the two-to-the-power-of size. */
for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
if (!kmalloc_caches[type][i])
new_kmalloc_cache(i, type);
}
for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++)
new_kmalloc_cache(i, type);
}
#ifdef CONFIG_RANDOM_KMALLOC_CACHES
random_kmalloc_seed = get_random_u64();
Expand Down

0 comments on commit 7338999

Please sign in to comment.