Commit f0630fff authored by Christoph Lameter's avatar Christoph Lameter Committed by Linus Torvalds

SLUB: support slub_debug on by default

Add a new configuration variable

CONFIG_SLUB_DEBUG_ON

If set then the kernel will be booted by default with slab debugging
switched on. Similar to CONFIG_SLAB_DEBUG. By default slab debugging
is available but must be enabled by specifying "slub_debug" as a
kernel parameter.

Also add support to switch off slab debugging for a kernel that was
built with CONFIG_SLUB_DEBUG_ON. This works by specifying

slub_debug=-

as a kernel parameter.

Dave Jones wanted this feature.
http://marc.info/?l=linux-kernel&m=118072189913045&w=2

[akpm@linux-foundation.org: clean up switch statement]
Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fc9a07e7
...@@ -1580,35 +1580,39 @@ and is between 256 and 4096 characters. It is defined in the file ...@@ -1580,35 +1580,39 @@ and is between 256 and 4096 characters. It is defined in the file
slram= [HW,MTD] slram= [HW,MTD]
slub_debug [MM, SLUB] slub_debug[=options[,slabs]] [MM, SLUB]
Enabling slub_debug allows one to determine the culprit Enabling slub_debug allows one to determine the
if slab objects become corrupted. Enabling slub_debug culprit if slab objects become corrupted. Enabling
creates guard zones around objects and poisons objects slub_debug can create guard zones around objects and
when not in use. Also tracks the last alloc / free. may poison objects when not in use. Also tracks the
For more information see Documentation/vm/slub.txt. last alloc / free. For more information see
Documentation/vm/slub.txt.
slub_max_order= [MM, SLUB] slub_max_order= [MM, SLUB]
Determines the maximum allowed order for slabs. Setting Determines the maximum allowed order for slabs.
this too high may cause fragmentation. A high setting may cause OOMs due to memory
For more information see Documentation/vm/slub.txt. fragmentation. For more information see
Documentation/vm/slub.txt.
slub_min_objects= [MM, SLUB] slub_min_objects= [MM, SLUB]
The minimum objects per slab. SLUB will increase the The minimum number of objects per slab. SLUB will
slab order up to slub_max_order to generate a increase the slab order up to slub_max_order to
sufficiently big slab to satisfy the number of objects. generate a sufficiently large slab able to contain
The higher the number of objects the smaller the overhead the number of objects indicated. The higher the number
of tracking slabs. of objects the smaller the overhead of tracking slabs
and the less frequently locks need to be acquired.
For more information see Documentation/vm/slub.txt. For more information see Documentation/vm/slub.txt.
slub_min_order= [MM, SLUB] slub_min_order= [MM, SLUB]
Determines the mininum page order for slabs. Must be Determines the mininum page order for slabs. Must be
lower than slub_max_order lower than slub_max_order.
For more information see Documentation/vm/slub.txt. For more information see Documentation/vm/slub.txt.
slub_nomerge [MM, SLUB] slub_nomerge [MM, SLUB]
Disable merging of slabs of similar size. May be Disable merging of slabs with similar size. May be
necessary if there is some reason to distinguish necessary if there is some reason to distinguish
allocs to different slabs. allocs to different slabs. Debug options disable
merging on their own.
For more information see Documentation/vm/slub.txt. For more information see Documentation/vm/slub.txt.
smart2= [HW] smart2= [HW]
......
...@@ -41,6 +41,8 @@ Possible debug options are ...@@ -41,6 +41,8 @@ Possible debug options are
P Poisoning (object and padding) P Poisoning (object and padding)
U User tracking (free and alloc) U User tracking (free and alloc)
T Trace (please only use on single slabs) T Trace (please only use on single slabs)
- Switch all debugging off (useful if the kernel is
configured with CONFIG_SLUB_DEBUG_ON)
F.e. in order to boot just with sanity checks and red zoning one would specify: F.e. in order to boot just with sanity checks and red zoning one would specify:
......
...@@ -152,6 +152,19 @@ config DEBUG_SLAB_LEAK ...@@ -152,6 +152,19 @@ config DEBUG_SLAB_LEAK
bool "Memory leak debugging" bool "Memory leak debugging"
depends on DEBUG_SLAB depends on DEBUG_SLAB
config SLUB_DEBUG_ON
bool "SLUB debugging on by default"
depends on SLUB && SLUB_DEBUG
default n
help
Boot with debugging on by default. SLUB boots by default with
the runtime debug capabilities switched off. Enabling this is
equivalent to specifying the "slub_debug" parameter on boot.
There is no support for more fine grained debug control like
possible with slub_debug=xxx. SLUB debugging may be switched
off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying
"slub_debug=-".
config DEBUG_PREEMPT config DEBUG_PREEMPT
bool "Debug preemptible kernel" bool "Debug preemptible kernel"
depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT
......
...@@ -323,7 +323,11 @@ static inline int slab_index(void *p, struct kmem_cache *s, void *addr) ...@@ -323,7 +323,11 @@ static inline int slab_index(void *p, struct kmem_cache *s, void *addr)
/* /*
* Debug settings: * Debug settings:
*/ */
#ifdef CONFIG_SLUB_DEBUG_ON
static int slub_debug = DEBUG_DEFAULT_FLAGS;
#else
static int slub_debug; static int slub_debug;
#endif
static char *slub_debug_slabs; static char *slub_debug_slabs;
...@@ -888,38 +892,57 @@ static int free_debug_processing(struct kmem_cache *s, struct page *page, ...@@ -888,38 +892,57 @@ static int free_debug_processing(struct kmem_cache *s, struct page *page,
static int __init setup_slub_debug(char *str) static int __init setup_slub_debug(char *str)
{ {
if (!str || *str != '=') slub_debug = DEBUG_DEFAULT_FLAGS;
slub_debug = DEBUG_DEFAULT_FLAGS; if (*str++ != '=' || !*str)
else { /*
str++; * No options specified. Switch on full debugging.
if (*str == 0 || *str == ',') */
slub_debug = DEBUG_DEFAULT_FLAGS; goto out;
else
for( ;*str && *str != ','; str++) if (*str == ',')
switch (*str) { /*
case 'f' : case 'F' : * No options but restriction on slabs. This means full
slub_debug |= SLAB_DEBUG_FREE; * debugging for slabs matching a pattern.
break; */
case 'z' : case 'Z' : goto check_slabs;
slub_debug |= SLAB_RED_ZONE;
break; slub_debug = 0;
case 'p' : case 'P' : if (*str == '-')
slub_debug |= SLAB_POISON; /*
break; * Switch off all debugging measures.
case 'u' : case 'U' : */
slub_debug |= SLAB_STORE_USER; goto out;
break;
case 't' : case 'T' : /*
slub_debug |= SLAB_TRACE; * Determine which debug features should be switched on
break; */
default: for ( ;*str && *str != ','; str++) {
printk(KERN_ERR "slub_debug option '%c' " switch (tolower(*str)) {
"unknown. skipped\n",*str); case 'f':
} slub_debug |= SLAB_DEBUG_FREE;
break;
case 'z':
slub_debug |= SLAB_RED_ZONE;
break;
case 'p':
slub_debug |= SLAB_POISON;
break;
case 'u':
slub_debug |= SLAB_STORE_USER;
break;
case 't':
slub_debug |= SLAB_TRACE;
break;
default:
printk(KERN_ERR "slub_debug option '%c' "
"unknown. skipped\n",*str);
}
} }
check_slabs:
if (*str == ',') if (*str == ',')
slub_debug_slabs = str + 1; slub_debug_slabs = str + 1;
out:
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment