From: Iliyan Malchev <malchev@google.com>
To: Christoph Lameter <cl@linux-foundation.org>,
Pekka Enberg <penberg@kernel.org>, Matt Mackall <mpm@selenic.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Iliyan Malchev <malchev@google.com>
Subject: [PATCH 1/2] slub: extend slub_debug to handle multiple slabs
Date: Mon, 8 Aug 2011 14:30:19 -0700 [thread overview]
Message-ID: <1312839019-17987-1-git-send-email-malchev@google.com> (raw)
Extend the slub_debug syntax to "slub_debug=<flags>[,<slub>]*", where <slub>
may contain an asterisk at the end. For example, the following would poison
all kmalloc slabs:
slub_debug=P,kmalloc*
and the following would apply the default flags to all kmalloc and all block IO
slabs:
slub_debug=,bio*,kmalloc*
Signed-off-by: Iliyan Malchev <malchev@google.com>
---
Documentation/vm/slub.txt | 12 +++++++++---
mm/slub.c | 32 +++++++++++++++++++++++++++++---
2 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/Documentation/vm/slub.txt b/Documentation/vm/slub.txt
index 07375e7..caa5b4a 100644
--- a/Documentation/vm/slub.txt
+++ b/Documentation/vm/slub.txt
@@ -31,8 +31,9 @@ Parameters may be given to slub_debug. If none is specified then full
debugging is enabled. Format:
slub_debug=<Debug-Options> Enable options for all slabs
-slub_debug=<Debug-Options>,<slab name>
- Enable options only for select slabs
+slub_debug=<Debug-Options>,<slab name1>,<slab name2>,...
+ Enable options only for select slabs (no spaces
+ after a comma)
Possible debug options are
F Sanity checks on (enables SLAB_DEBUG_FREE. Sorry
@@ -55,7 +56,12 @@ Trying to find an issue in the dentry cache? Try
slub_debug=,dentry
-to only enable debugging on the dentry cache.
+to only enable debugging on the dentry cache. You may use an asterisk at the
+end of the slab name, in order to cover all slabs with the same prefix. For
+example, here's how you can poison the dentry cache as well as all kmalloc
+slabs:
+
+ slub_debug=P,kmalloc-*,dentry
Red zoning and tracking may realign the slab. We can just apply sanity checks
to the dentry cache with
diff --git a/mm/slub.c b/mm/slub.c
index eb5a8f9..8e7a282 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1275,9 +1275,35 @@ static unsigned long kmem_cache_flags(unsigned long objsize,
/*
* Enable debugging if selected on the kernel commandline.
*/
- if (slub_debug && (!slub_debug_slabs ||
- !strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs))))
- flags |= slub_debug;
+
+ char *end, *n, *glob;
+ int len = strlen(name);
+
+ /* If slub_debug = 0, it folds into the if conditional. */
+ if (!slub_debug_slabs)
+ return flags | slub_debug;
+
+ n = slub_debug_slabs;
+ while (*n) {
+ int cmplen;
+
+ end = strchr(n, ',');
+ if (!end)
+ end = n + strlen(n);
+
+ glob = strnchr(n, end - n, '*');
+ if (glob)
+ cmplen = glob - n;
+ else
+ cmplen = max(len, end - n);
+
+ if (!strncmp(name, n, cmplen)) {
+ flags |= slub_debug;
+ break;
+ }
+
+ n = *end ? end + 1 : end;
+ }
return flags;
}
--
1.7.3.1
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2011-08-08 21:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-08 21:30 Iliyan Malchev [this message]
2011-08-13 6:58 ` [PATCH 1/2] slub: extend slub_debug to handle multiple slabs Pekka Enberg
2011-08-15 13:55 ` Christoph Lameter
2012-01-23 13:16 ` Pekka Enberg
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=1312839019-17987-1-git-send-email-malchev@google.com \
--to=malchev@google.com \
--cc=cl@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mpm@selenic.com \
--cc=penberg@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).