Skip to content

Commit 306c4ac

Browse files
Hyunmin Leetehcaster
authored andcommitted
mm/slub: create kmalloc 96 and 192 caches regardless cache size order
For SLAB the kmalloc caches needed to be created in ascending sizes in order. However, the constraint is not necessary anymore because SLAB has been removed and SLUB doesn't need to comply with the constraint. Thus, kmalloc 96 and 192 caches can be created after the other size kmalloc caches are created instead of checking every time to find their order to be created. Also, this change could prevent engineers from being confused by the removed constraint. 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 844776c commit 306c4ac

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

mm/slab_common.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -916,21 +916,16 @@ void __init create_kmalloc_caches(void)
916916
* Including KMALLOC_CGROUP if CONFIG_MEMCG_KMEM defined
917917
*/
918918
for (type = KMALLOC_NORMAL; type < NR_KMALLOC_TYPES; type++) {
919+
/* Caches that are NOT of the two-to-the-power-of size. */
920+
if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[type][1])
921+
new_kmalloc_cache(1, type);
922+
if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[type][2])
923+
new_kmalloc_cache(2, type);
924+
925+
/* Caches that are of the two-to-the-power-of size. */
919926
for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
920927
if (!kmalloc_caches[type][i])
921928
new_kmalloc_cache(i, type);
922-
923-
/*
924-
* Caches that are not of the two-to-the-power-of size.
925-
* These have to be created immediately after the
926-
* earlier power of two caches
927-
*/
928-
if (KMALLOC_MIN_SIZE <= 32 && i == 6 &&
929-
!kmalloc_caches[type][1])
930-
new_kmalloc_cache(1, type);
931-
if (KMALLOC_MIN_SIZE <= 64 && i == 7 &&
932-
!kmalloc_caches[type][2])
933-
new_kmalloc_cache(2, type);
934929
}
935930
}
936931
#ifdef CONFIG_RANDOM_KMALLOC_CACHES

0 commit comments

Comments
 (0)