[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1284483964-2370-2-git-send-email-penberg@kernel.org>
Date: Tue, 14 Sep 2010 20:06:04 +0300
From: Pekka Enberg <penberg@...nel.org>
To: torvalds@...ux-founation.org
Cc: linux-kernel@...r.kernel.org, Pekka Enberg <penberg@...nel.org>,
Christoph Lameter <cl@...ux.com>,
David Rientjes <rientjes@...gle.com>
Subject: [PATCH 2/2] SLUB: Mark merged slab caches in /proc/slabinfo
SLUB uses the name of the first slab cache for all merged slab caches. To make
the output of /proc/slabinfo more obvious, append the name of each merged slab
cache to s->name.
An example output looks like this:
bip-16,ip_dst_cache,kioctx 42 42 [snip]
Cc: Christoph Lameter <cl@...ux.com>
Cc: David Rientjes <rientjes@...gle.com>
Reported-by: Linus Torvalds <torvalds@...ux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@...nel.org>
---
mm/slub.c | 41 ++++++++++++++++++++++++++++++-----------
1 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 0704288..6b08256 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3149,6 +3149,34 @@ void __init kmem_cache_init_late(void)
{
}
+static int kmem_merge_names(struct kmem_cache *s, const char *name)
+{
+ size_t new_size;
+ char *new_name;
+
+ /* Don't append name to merged name more than once */
+ if (strstr(s->name, name))
+ return 0;
+
+ /* Comma separated and NULL terminated. */
+ new_size = strlen(s->name) + strlen(name) + 2;
+
+ new_name = kmalloc(new_size, GFP_KERNEL);
+ if (!new_name)
+ return -ENOMEM;
+
+ snprintf(new_name, new_size, "%s,%s", s->name, name);
+
+ if (s->flags & SLAB_DYNAMIC_NAME)
+ kfree(s->name);
+
+ s->name = new_name;
+
+ s->flags |= SLAB_DYNAMIC_NAME;
+
+ return 0;
+}
+
/*
* Find a mergeable slab cache
*/
@@ -3221,17 +3249,8 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
down_write(&slub_lock);
s = find_mergeable(size, align, flags, name, ctor);
if (s) {
- if (!(s->flags & SLAB_DYNAMIC_NAME)) {
- const char *new_name;
-
- new_name = kstrdup(s->name, GFP_KERNEL);
- if (!new_name)
- goto err;
-
- s->name = new_name;
-
- s->flags |= SLAB_DYNAMIC_NAME;
- }
+ if (kmem_merge_names(s, name))
+ goto err;
s->refcount++;
/*
--
1.6.3.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists