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: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
fc9a07e7bf
commit
f0630fff54
81
mm/slub.c
81
mm/slub.c
@@ -323,7 +323,11 @@ static inline int slab_index(void *p, struct kmem_cache *s, void *addr)
|
||||
/*
|
||||
* Debug settings:
|
||||
*/
|
||||
#ifdef CONFIG_SLUB_DEBUG_ON
|
||||
static int slub_debug = DEBUG_DEFAULT_FLAGS;
|
||||
#else
|
||||
static int slub_debug;
|
||||
#endif
|
||||
|
||||
static char *slub_debug_slabs;
|
||||
|
||||
@@ -888,38 +892,57 @@ fail:
|
||||
|
||||
static int __init setup_slub_debug(char *str)
|
||||
{
|
||||
if (!str || *str != '=')
|
||||
slub_debug = DEBUG_DEFAULT_FLAGS;
|
||||
else {
|
||||
str++;
|
||||
if (*str == 0 || *str == ',')
|
||||
slub_debug = DEBUG_DEFAULT_FLAGS;
|
||||
else
|
||||
for( ;*str && *str != ','; str++)
|
||||
switch (*str) {
|
||||
case 'f' : case 'F' :
|
||||
slub_debug |= SLAB_DEBUG_FREE;
|
||||
break;
|
||||
case 'z' : case 'Z' :
|
||||
slub_debug |= SLAB_RED_ZONE;
|
||||
break;
|
||||
case 'p' : case 'P' :
|
||||
slub_debug |= SLAB_POISON;
|
||||
break;
|
||||
case 'u' : case 'U' :
|
||||
slub_debug |= SLAB_STORE_USER;
|
||||
break;
|
||||
case 't' : case 'T' :
|
||||
slub_debug |= SLAB_TRACE;
|
||||
break;
|
||||
default:
|
||||
printk(KERN_ERR "slub_debug option '%c' "
|
||||
"unknown. skipped\n",*str);
|
||||
}
|
||||
}
|
||||
slub_debug = DEBUG_DEFAULT_FLAGS;
|
||||
if (*str++ != '=' || !*str)
|
||||
/*
|
||||
* No options specified. Switch on full debugging.
|
||||
*/
|
||||
goto out;
|
||||
|
||||
if (*str == ',')
|
||||
/*
|
||||
* No options but restriction on slabs. This means full
|
||||
* debugging for slabs matching a pattern.
|
||||
*/
|
||||
goto check_slabs;
|
||||
|
||||
slub_debug = 0;
|
||||
if (*str == '-')
|
||||
/*
|
||||
* Switch off all debugging measures.
|
||||
*/
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* Determine which debug features should be switched on
|
||||
*/
|
||||
for ( ;*str && *str != ','; str++) {
|
||||
switch (tolower(*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 == ',')
|
||||
slub_debug_slabs = str + 1;
|
||||
out:
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user