slub: extend slub_debug to handle multiple slabs
Subsystems (3)
PATCH 1/2 slub: extend slub_debug to handle multiple slabs
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*
--- Documentation/vm/slub.txt | 12 +++++++++--- mm/slub.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-)
Documentation/vm/slub.txt +9 -3
@@ -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
mm/slub.c +29 -3
@@ -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; }
Signature · 8 lines
1.7.3.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. 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:"[email protected]"> [email protected] </a>
Quoted 4 lines · Iliyan Malchev
Extend the
slub_debugsyntax to "slub_debug=<flags>[,<slub>]*", where <slub> may contain an asterisk at the end. For example, the following would poison all kmalloc slabs:
Quoted 8 lines
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 <[email protected]>
Christoph, David, are you OK with the patches? They look reasonable to me.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. 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:"[email protected]"> [email protected] </a>
Quoted 5 lines · Iliyan Malchev
Extend the
slub_debugsyntax 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*
The use of the star suggests that general regexps will be working. But this is only allowing a star at the end. It is explained later. So maybe that ok.
Quoted 10 lines
mm/slub.c +10
-0+ n = slub_debug_slabs; +while (*n) { +int cmplen; + + end =strchr (n,',' ); +if (!end) + end = n +strlen (n); + + glob =strnchr (n, end - n,'*' ); +if (glob)
mm/slub.c static unsigned long kmem_cache_flags(unsigned long objsize, · line 1305
Quoted 10 lines
mm/slub.c +10
-0+ cmplen = glob - n; + else + cmplen =max (len, end - n); + +if (!strncmp (name, n, cmplen)) { + flags |= slub_debug; +break ; + } + + n = *end ? end +1 : end;
Ugg.. Confusing
How about
if (!*end) break; n = end + 1;
or make the while loop into a for loop?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. 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:"[email protected]"> [email protected] </a>
Hi Iliyan,
Quoted 4 lines · Iliyan Malchev
Extend the
slub_debugsyntax to "slub_debug=<flags>[,<slub>]*", where <slub> may contain an asterisk at the end. For example, the following would poison all kmalloc slabs:
Quoted 8 lines
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 <[email protected]>
Ping? I didn't see followup patches that addressed Christoph's review comments. I think the feature makes sense so it'd be good to have it in mainline.
Pekka
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. 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:"[email protected]"> [email protected] </a>