[PATCH] mm, slab: rename kmalloc-node cache to kmalloc-<size>-fix2
From: Vlastimil Babka
Date: Wed Feb 08 2017 - 05:00:11 EST
Export the whole kmalloc_info structure instead of just a name accessor,
per Christoph Lameter.
Signed-off-by: Vlastimil Babka <vbabka@xxxxxxx>
---
mm/slab.c | 2 +-
mm/slab.h | 7 ++++++-
mm/slab_common.c | 10 +---------
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index ede31b59bb9f..9d66b3d6791e 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1294,7 +1294,7 @@ void __init kmem_cache_init(void)
* structures first. Without this, further allocations will bug.
*/
kmalloc_caches[INDEX_NODE] = create_kmalloc_cache(
- get_kmalloc_cache_name(INDEX_NODE),
+ kmalloc_info[INDEX_NODE].name,
kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
slab_state = PARTIAL_NODE;
setup_kmalloc_cache_index_table();
diff --git a/mm/slab.h b/mm/slab.h
index 5708c548c6f7..2fa824335a50 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -71,6 +71,12 @@ extern struct list_head slab_caches;
/* The slab cache that manages slab cache information */
extern struct kmem_cache *kmem_cache;
+/* A table of kmalloc cache names and sizes */
+extern const struct kmalloc_info_struct {
+ const char *name;
+ unsigned long size;
+} kmalloc_info[];
+
unsigned long calculate_alignment(unsigned long flags,
unsigned long align, unsigned long size);
@@ -78,7 +84,6 @@ unsigned long calculate_alignment(unsigned long flags,
/* Kmalloc array related functions */
void setup_kmalloc_cache_index_table(void);
void create_kmalloc_caches(unsigned long);
-const char *get_kmalloc_cache_name(int index);
/* Find the kmalloc slab corresponding for a certain size */
struct kmem_cache *kmalloc_slab(size_t, gfp_t);
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 36a8547de699..be5dce23037d 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -917,10 +917,7 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
* kmalloc_index() supports up to 2^26=64MB, so the final entry of the table is
* kmalloc-67108864.
*/
-static struct {
- const char *name;
- unsigned long size;
-} const kmalloc_info[] __initconst = {
+const struct kmalloc_info_struct kmalloc_info[] __initconst = {
{NULL, 0}, {"kmalloc-96", 96},
{"kmalloc-192", 192}, {"kmalloc-8", 8},
{"kmalloc-16", 16}, {"kmalloc-32", 32},
@@ -937,11 +934,6 @@ static struct {
{"kmalloc-67108864", 67108864}
};
-const char *get_kmalloc_cache_name(int index)
-{
- return kmalloc_info[index].name;
-}
-
/*
* Patch up the size_index table if we have strange large alignment
* requirements for the kmalloc array. This is only the case for
--
2.11.0