From: Gavin Guo <gavin.guo@canonical.com>
To: cl@linux.com, penberg@kernel.org, rientjes@google.com,
iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] mm/slab_common: Support the slub_debug boot option on specific object size
Date: Wed, 22 Apr 2015 16:33:38 +0800 [thread overview]
Message-ID: <1429691618-13884-1-git-send-email-gavin.guo@canonical.com> (raw)
The slub_debug=PU,kmalloc-xx cannot work because in the
create_kmalloc_caches() the s->name is created after the
create_kmalloc_cache() is called. The name is NULL in the
create_kmalloc_cache() so the kmem_cache_flags() would not set the
slub_debug flags to the s->flags. The fix here set up a kmalloc_names
string array for the initialization purpose and delete the dynamic
name creation of kmalloc_caches.
v1->v2
- Adopted suggestion from Christoph to delete the dynamic name creation
for kmalloc_caches.
Signed-off-by: Gavin Guo <gavin.guo@canonical.com>
---
mm/slab_common.c | 41 ++++++++++++++++++++++++++---------------
1 file changed, 26 insertions(+), 15 deletions(-)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 999bb34..61fbc4e 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -793,6 +793,26 @@ void __init create_kmalloc_caches(unsigned long flags)
int i;
/*
+ * The kmalloc_names is for temporary usage to make
+ * slub_debug=,kmalloc-xx option work in the boot time. The
+ * kmalloc_index() support to 2^26=64MB. So, the final entry of the
+ * table is kmalloc-67108864.
+ */
+ static const char *kmalloc_names[] = {
+ "0", "kmalloc-96", "kmalloc-192",
+ "kmalloc-8", "kmalloc-16", "kmalloc-32",
+ "kmalloc-64", "kmalloc-128", "kmalloc-256",
+ "kmalloc-512", "kmalloc-1024", "kmalloc-2048",
+ "kmalloc-4196", "kmalloc-8192", "kmalloc-16384",
+ "kmalloc-32768", "kmalloc-65536",
+ "kmalloc-131072", "kmalloc-262144",
+ "kmalloc-524288", "kmalloc-1048576",
+ "kmalloc-2097152", "kmalloc-4194304",
+ "kmalloc-8388608", "kmalloc-16777216",
+ "kmalloc-33554432", "kmalloc-67108864"
+ };
+
+ /*
* Patch up the size_index table if we have strange large alignment
* requirements for the kmalloc array. This is only the case for
* MIPS it seems. The standard arches will not generate any code here.
@@ -835,7 +855,8 @@ void __init create_kmalloc_caches(unsigned long flags)
}
for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
if (!kmalloc_caches[i]) {
- kmalloc_caches[i] = create_kmalloc_cache(NULL,
+ kmalloc_caches[i] = create_kmalloc_cache(
+ kmalloc_names[i],
1 << i, flags);
}
@@ -845,27 +866,17 @@ void __init create_kmalloc_caches(unsigned long flags)
* earlier power of two caches
*/
if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
- kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
+ kmalloc_caches[1] = create_kmalloc_cache(
+ kmalloc_names[1], 96, flags);
if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
- kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
+ kmalloc_caches[2] = create_kmalloc_cache(
+ kmalloc_names[2], 192, flags);
}
/* Kmalloc array is now usable */
slab_state = UP;
- for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
- struct kmem_cache *s = kmalloc_caches[i];
- char *n;
-
- if (s) {
- n = kasprintf(GFP_NOWAIT, "kmalloc-%d", kmalloc_size(i));
-
- BUG_ON(!n);
- s->name = n;
- }
- }
-
#ifdef CONFIG_ZONE_DMA
for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
struct kmem_cache *s = kmalloc_caches[i];
--
2.0.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2015-04-22 8:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-22 8:33 Gavin Guo [this message]
2015-04-22 14:27 ` Christoph Lameter
2015-04-22 21:00 ` Andrew Morton
2015-04-22 21:02 ` Andrew Morton
2015-04-23 3:10 ` Gavin Guo
2015-04-23 3:28 ` Andrew Morton
2015-04-23 9:55 ` Rasmus Villemoes
2015-04-23 11:15 ` Gavin Guo
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=1429691618-13884-1-git-send-email-gavin.guo@canonical.com \
--to=gavin.guo@canonical.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
/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