All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pekka Enberg <penberg@kernel.org>
To: torvalds@linux-founation.org
Cc: linux-kernel@vger.kernel.org, Pekka Enberg <penberg@kernel.org>,
	Christoph Lameter <cl@linux.com>,
	David Rientjes <rientjes@google.com>
Subject: [PATCH 2/2] SLUB: Mark merged slab caches in /proc/slabinfo
Date: Tue, 14 Sep 2010 20:06:04 +0300	[thread overview]
Message-ID: <1284483964-2370-2-git-send-email-penberg@kernel.org> (raw)
In-Reply-To: <1284483964-2370-1-git-send-email-penberg@kernel.org>

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@linux.com>
Cc: David Rientjes <rientjes@google.com>
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.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


  reply	other threads:[~2010-09-14 17:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-14 17:06 [PATCH 1/2] SLUB: Fix merged slab cache names Pekka Enberg
2010-09-14 17:06 ` Pekka Enberg [this message]
2010-09-14 17:10   ` [PATCH 2/2] SLUB: Mark merged slab caches in /proc/slabinfo Pekka Enberg
2010-09-14 17:28     ` Christoph Lameter
2010-09-14 17:59       ` Pekka Enberg
2010-09-14 18:05         ` Linus Torvalds
2010-09-14 18:47           ` Pekka Enberg
2010-09-14 17:26 ` [PATCH 1/2] SLUB: Fix merged slab cache names Christoph Lameter
2010-09-14 17:36   ` Pekka Enberg
2010-09-14 17:47     ` Christoph Lameter
2010-09-14 17:49       ` Pekka Enberg
2010-09-14 17:59         ` Christoph Lameter
2010-09-14 18:02 ` Linus Torvalds

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=1284483964-2370-2-git-send-email-penberg@kernel.org \
    --to=penberg@kernel.org \
    --cc=cl@linux.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rientjes@google.com \
    --cc=torvalds@linux-founation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.