linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] clean-up for create_kmalloc_caches()
@ 2024-04-24 14:04 Hyunmin Lee
  2024-04-24 14:04 ` [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order Hyunmin Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Hyunmin Lee @ 2024-04-24 14:04 UTC (permalink / raw)
  To: linux-mm
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	Jeungwoo Yoo, Sangyun Kim, Gwan-gyeong Mun

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(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order
  2024-04-24 14:04 [PATCH v3 0/2] clean-up for create_kmalloc_caches() Hyunmin Lee
@ 2024-04-24 14:04 ` Hyunmin Lee
  2024-04-24 17:04   ` Christoph Lameter (Ampere)
  2024-04-27  4:51   ` David Rientjes
       [not found] ` <20240424140422.12780-3-hyunminlr@gmail.com>
  2024-05-02 14:12 ` [PATCH v3 0/2] clean-up for create_kmalloc_caches() Vlastimil Babka
  2 siblings, 2 replies; 7+ messages in thread
From: Hyunmin Lee @ 2024-04-24 14:04 UTC (permalink / raw)
  To: linux-mm
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	Jeungwoo Yoo, Sangyun Kim, Gwan-gyeong Mun

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 <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>
---
 mm/slab_common.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/mm/slab_common.c b/mm/slab_common.c
index 3179a6aeffc5..ed7b8592b62c 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -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
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order
  2024-04-24 14:04 ` [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order Hyunmin Lee
@ 2024-04-24 17:04   ` Christoph Lameter (Ampere)
  2024-04-27  4:51   ` David Rientjes
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Lameter (Ampere) @ 2024-04-24 17:04 UTC (permalink / raw)
  To: Hyunmin Lee
  Cc: linux-mm, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	Jeungwoo Yoo, Sangyun Kim, Gwan-gyeong Mun

On Wed, 24 Apr 2024, Hyunmin Lee wrote:

> 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.

Reviewed-by: Christoph Lameter <cl@linux.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/2] mm/slub: remove the check for NULL kmalloc_caches
       [not found] ` <20240424140422.12780-3-hyunminlr@gmail.com>
@ 2024-04-24 17:05   ` Christoph Lameter (Ampere)
  2024-04-27  4:51   ` David Rientjes
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Lameter (Ampere) @ 2024-04-24 17:05 UTC (permalink / raw)
  To: Hyunmin Lee
  Cc: linux-mm, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	Jeungwoo Yoo, Sangyun Kim, Gwan-gyeong Mun

On Wed, 24 Apr 2024, Hyunmin Lee wrote:

> 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.

Reviewed-by: Christoph Lameter <cl@linux.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order
  2024-04-24 14:04 ` [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order Hyunmin Lee
  2024-04-24 17:04   ` Christoph Lameter (Ampere)
@ 2024-04-27  4:51   ` David Rientjes
  1 sibling, 0 replies; 7+ messages in thread
From: David Rientjes @ 2024-04-27  4:51 UTC (permalink / raw)
  To: Hyunmin Lee
  Cc: linux-mm, Christoph Lameter, Pekka Enberg, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	Jeungwoo Yoo, Sangyun Kim, Gwan-gyeong Mun

On Wed, 24 Apr 2024, Hyunmin Lee wrote:

> 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 <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>

Acked-by: David Rientjes <rientjes@google.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 2/2] mm/slub: remove the check for NULL kmalloc_caches
       [not found] ` <20240424140422.12780-3-hyunminlr@gmail.com>
  2024-04-24 17:05   ` [PATCH v3 2/2] mm/slub: remove the check for NULL kmalloc_caches Christoph Lameter (Ampere)
@ 2024-04-27  4:51   ` David Rientjes
  1 sibling, 0 replies; 7+ messages in thread
From: David Rientjes @ 2024-04-27  4:51 UTC (permalink / raw)
  To: Hyunmin Lee
  Cc: linux-mm, Christoph Lameter, Pekka Enberg, Joonsoo Kim,
	Andrew Morton, Vlastimil Babka, Roman Gushchin, Hyeonggon Yoo,
	Jeungwoo Yoo, Sangyun Kim, Gwan-gyeong Mun

On Wed, 24 Apr 2024, Hyunmin Lee wrote:

> 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>

Acked-by: David Rientjes <rientjes@google.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v3 0/2] clean-up for create_kmalloc_caches()
  2024-04-24 14:04 [PATCH v3 0/2] clean-up for create_kmalloc_caches() Hyunmin Lee
  2024-04-24 14:04 ` [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order Hyunmin Lee
       [not found] ` <20240424140422.12780-3-hyunminlr@gmail.com>
@ 2024-05-02 14:12 ` Vlastimil Babka
  2 siblings, 0 replies; 7+ messages in thread
From: Vlastimil Babka @ 2024-05-02 14:12 UTC (permalink / raw)
  To: Hyunmin Lee, linux-mm
  Cc: Christoph Lameter, Pekka Enberg, David Rientjes, Joonsoo Kim,
	Andrew Morton, Roman Gushchin, Hyeonggon Yoo, Jeungwoo Yoo,
	Sangyun Kim, Gwan-gyeong Mun

On 4/24/24 16:04, Hyunmin Lee wrote:
> 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

Thanks, applied to slab/for-6.10

> 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(-)
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-02 14:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-24 14:04 [PATCH v3 0/2] clean-up for create_kmalloc_caches() Hyunmin Lee
2024-04-24 14:04 ` [PATCH v3 1/2] mm/slub: create kmalloc 96 and 192 caches regardless cache size order Hyunmin Lee
2024-04-24 17:04   ` Christoph Lameter (Ampere)
2024-04-27  4:51   ` David Rientjes
     [not found] ` <20240424140422.12780-3-hyunminlr@gmail.com>
2024-04-24 17:05   ` [PATCH v3 2/2] mm/slub: remove the check for NULL kmalloc_caches Christoph Lameter (Ampere)
2024-04-27  4:51   ` David Rientjes
2024-05-02 14:12 ` [PATCH v3 0/2] clean-up for create_kmalloc_caches() Vlastimil Babka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).