clean-up for create_kmalloc_caches()
Subsystems (2)
v3 cover clean-up for create_kmalloc_caches()
Hi pals,
I am cleanning up unnecessary code in create_kmalloc_caches(). I added one more commit to remove the check for NULL kmalloc_cachee according to the review comments like below.
- David Rientjes suggested moving the check for NULL kmalloc_caches to new_kmalloc_cache().
- Christoph Lameter suggested skipping the check for the kmalloc caches already being present.
Thanks,
Hyunmin
Hyunmin Lee (2):
mm/slub: create kmalloc 96 and 192 caches regardless cache size order mm/slub: remove the check for NULL kmalloc_caches
mm/slab_common.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/2 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.
--- mm/slab_common.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
mm/slab_common.c +7 -12
@@ -916,21 +916,16 @@ void __init create_kmalloc_caches(void)* Including KMALLOC_CGROUP if CONFIG_MEMCG_KMEM defined */ 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 ]) +new_kmalloc_cache (1 , type); +if (KMALLOC_MIN_SIZE <=64 && !kmalloc_caches[type][2 ]) +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); - -/* -* Caches that are not of the two-to-the-power-of size. -* These have to be created immediately after the -* earlier power of two caches -*/ -if (KMALLOC_MIN_SIZE <=32 && i ==6 && - !kmalloc_caches[type][1 ]) -new_kmalloc_cache (1 , type); -if (KMALLOC_MIN_SIZE <=64 && i ==7 && - !kmalloc_caches[type][2 ]) -new_kmalloc_cache (2 , type); } }#ifdef CONFIG_RANDOM_KMALLOC_CACHES
Signature · 1 line
2.34.1
Re: [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order
Quoted 7 lines · Hyunmin Lee
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.
Re: [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order
In reply to Hyunmin LeeQuoted 8 lines · Hyunmin Lee
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.
Quoted 7 lines
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]>
PATCH v3 2/2 mm/slub: remove the check for NULL kmalloc_caches
In reply to Hyunmin LeeIf 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.
--- mm/slab_common.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
mm/slab_common.c +4 -6
@@ -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 ();
Signature · 1 line
2.34.1
Re: [PATCH v3 2/2] mm/slub: remove the check for NULL kmalloc_caches
Quoted 5 lines · Hyunmin Lee
If the same size kmalloc cache already exists, it should not be created again. So there is the check for NULL
kmalloc_cachesbefore calling the kmalloc creation function. However,new_kmalloc_cache()itself checks NULLkmalloc_cahcesbefore cache creation. Therefore, the NULL check is not necessary in this function.
Re: [PATCH v3 2/2] mm/slub: remove the check for NULL kmalloc_caches
In reply to Hyunmin LeeQuoted 6 lines · Hyunmin Lee
If the same size kmalloc cache already exists, it should not be created again. So there is the check for NULL
kmalloc_cachesbefore calling the kmalloc creation function. However,new_kmalloc_cache()itself checks NULLkmalloc_cahcesbefore cache creation. Therefore, the NULL check is not necessary in this function.
Quoted 7 lines
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]>
Vlastimil Babka
AppliedQuoted 6 lines · Hyunmin Lee
Hi pals,
I am cleanning up unnecessary code in
create_kmalloc_caches(). I added one more commit to remove the check for NULLkmalloc_cacheeaccording to the review comments like below.
Quoted 7 lines
- David Rientjes suggested moving the check for NULL
kmalloc_cachestonew_kmalloc_cache().
- Christoph Lameter suggested skipping the check for the kmalloc caches already being present.Thanks,
Hyunmin
Thanks, applied to slab/for-6.10
Quoted 7 lines
Hyunmin Lee (2):
mm/slub: create kmalloc 96 and 192 caches regardless cache size order mm/slub: remove the check for NULLkmalloc_cachesmm/slab_common.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)