Archive-only list for patches
 help / color / mirror / Atom feed
From: Hyunmin Lee <hyunminlr@gmail.com>
To: linux-mm@kvack.org
Cc: Christoph Lameter <cl@linux.com>,
	Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Jeungwoo Yoo <casionwoo@gmail.com>,
	Sangyun Kim <sangyun.kim@snu.ac.kr>,
	Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Subject: [PATCH v3 2/2] mm/slub: remove the check for NULL kmalloc_caches
Date: Wed, 24 Apr 2024 23:04:22 +0900	[thread overview]
Message-ID: <20240424140422.12780-3-hyunminlr@gmail.com> (raw)
In-Reply-To: <20240424140422.12780-1-hyunminlr@gmail.com>

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

diff --git a/mm/slab_common.c b/mm/slab_common.c
index ed7b8592b62c..0f2675f421e9 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -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();
-- 
2.34.1


           reply	other threads:[~2024-05-02 12:54 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20240424140422.12780-1-hyunminlr@gmail.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240424140422.12780-3-hyunminlr@gmail.com \
    --to=hyunminlr@gmail.com \
    --cc=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=casionwoo@gmail.com \
    --cc=cl@linux.com \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=sangyun.kim@snu.ac.kr \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox