Skip to contentSkip to conversation

mm, slab: make kmalloc_info[] contain all types of names

PATCH In review [email protected] 1 participant 1 message Dec 1, 2019

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 5/158 mm, slab: make kmalloc_info[] contain all types of names

From: Pengfei Li <[email protected]>
Subject: mm, slab: make kmalloc_info[] contain all types of names

Patch series "mm, slab: Make kmalloc_info[] contain all types of names", v6.

There are three types of kmalloc, KMALLOC_NORMAL, KMALLOC_RECLAIM and KMALLOC_DMA.

The name of KMALLOC_NORMAL is contained in kmalloc_info[].name, but the names of KMALLOC_RECLAIM and KMALLOC_DMA are dynamically generated by kmalloc_cache_name().

Patch1 predefines the names of all types of kmalloc to save the time spent dynamically generating names.

These changes make sense, and the time spent by new_kmalloc_cache() has been reduced by approximately 36.3%.

Time spent by new_kmalloc_cache()
(CPU cycles)
5.3-rc7 66264
5.3-rc7+patch 42188

This patch (of 3):

There are three types of kmalloc, KMALLOC_NORMAL, KMALLOC_RECLAIM and KMALLOC_DMA.

The name of KMALLOC_NORMAL is contained in kmalloc_info[].name, but the names of KMALLOC_RECLAIM and KMALLOC_DMA are dynamically generated by kmalloc_cache_name().

This patch predefines the names of all types of kmalloc to save the time spent dynamically generating names.

Besides, remove the kmalloc_cache_name() that is no longer used.

---

 mm/slab.c        |    2 
 mm/slab.h        |    2 
 mm/slab_common.c |   91 ++++++++++++++++++++++++---------------------
 3 files changed, 51 insertions(+), 44 deletions(-)
mm/slab.c renamed from mm/slab.c~mm-slab-make-kmalloc_info-contain-all-types-of-names +1 -1
@@ -1247,7 +1247,7 @@ void __init kmem_cache_init(void)
 	 * structures first.  Without this, further allocations will bug.
 	 */
 	kmalloc_caches[KMALLOC_NORMAL][INDEX_NODE] = create_kmalloc_cache(
-				kmalloc_info[INDEX_NODE].name,
+				kmalloc_info[INDEX_NODE].name[KMALLOC_NORMAL],
 				kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS,
 				0, kmalloc_size(INDEX_NODE));
 	slab_state = PARTIAL_NODE;
mm/slab_common.c renamed from mm/slab_common.c~mm-slab-make-kmalloc_info-contain-all-types-of-names +49 -42

122 lines not on this page · raw message

mm/slab.h renamed from mm/slab.h~mm-slab-make-kmalloc_info-contain-all-types-of-names +1 -1
@@ -139,7 +139,7 @@ extern struct kmem_cache *kmem_cache;
 
 /* A table of kmalloc cache names and sizes */
 extern const struct kmalloc_info_struct {
-	const char *name;
+	const char *name[NR_KMALLOC_TYPES];
 	unsigned int size;
 } kmalloc_info[];
 

_