diff options
| author | Jason Baron <jbaron@redhat.com> | 2010-07-19 06:54:17 -0400 |
|---|---|---|
| committer | Catalin Marinas <catalin.marinas@arm.com> | 2010-07-19 06:54:17 -0400 |
| commit | ab0155a22ad5bda3a6dbfbbecc416cbe92619755 (patch) | |
| tree | 0a8b2caea650cc31f61bc8723b0da275382701af | |
| parent | a7686a45c07462b78df5ac15fc696a86e57ccf91 (diff) | |
kmemleak: Introduce a default off mode for kmemleak
Introduce a new DEBUG_KMEMLEAK_DEFAULT_OFF config parameter that allows
kmemleak to be disabled by default, but enabled on the command line
via: kmemleak=on. Although a reboot is required to turn it on, its still
useful to not require a re-compile.
Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
| -rw-r--r-- | lib/Kconfig.debug | 7 | ||||
| -rw-r--r-- | mm/kmemleak.c | 14 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index e722e9d62221..95ab402db9c0 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -400,6 +400,13 @@ config DEBUG_KMEMLEAK_TEST | |||
| 400 | 400 | ||
| 401 | If unsure, say N. | 401 | If unsure, say N. |
| 402 | 402 | ||
| 403 | config DEBUG_KMEMLEAK_DEFAULT_OFF | ||
| 404 | bool "Default kmemleak to off" | ||
| 405 | depends on DEBUG_KMEMLEAK | ||
| 406 | help | ||
| 407 | Say Y here to disable kmemleak by default. It can then be enabled | ||
| 408 | on the command line via kmemleak=on. | ||
| 409 | |||
| 403 | config DEBUG_PREEMPT | 410 | config DEBUG_PREEMPT |
| 404 | bool "Debug preemptible kernel" | 411 | bool "Debug preemptible kernel" |
| 405 | depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT | 412 | depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT |
diff --git a/mm/kmemleak.c b/mm/kmemleak.c index c2c9feb3097f..d33e990e0668 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c | |||
| @@ -211,6 +211,9 @@ static signed long jiffies_scan_wait; | |||
| 211 | static int kmemleak_stack_scan = 1; | 211 | static int kmemleak_stack_scan = 1; |
| 212 | /* protects the memory scanning, parameters and debug/kmemleak file access */ | 212 | /* protects the memory scanning, parameters and debug/kmemleak file access */ |
| 213 | static DEFINE_MUTEX(scan_mutex); | 213 | static DEFINE_MUTEX(scan_mutex); |
| 214 | /* setting kmemleak=on, will set this var, skipping the disable */ | ||
| 215 | static int kmemleak_skip_disable; | ||
| 216 | |||
| 214 | 217 | ||
| 215 | /* | 218 | /* |
| 216 | * Early object allocation/freeing logging. Kmemleak is initialized after the | 219 | * Early object allocation/freeing logging. Kmemleak is initialized after the |
| @@ -1604,7 +1607,9 @@ static int kmemleak_boot_config(char *str) | |||
| 1604 | return -EINVAL; | 1607 | return -EINVAL; |
| 1605 | if (strcmp(str, "off") == 0) | 1608 | if (strcmp(str, "off") == 0) |
| 1606 | kmemleak_disable(); | 1609 | kmemleak_disable(); |
| 1607 | else if (strcmp(str, "on") != 0) | 1610 | else if (strcmp(str, "on") == 0) |
| 1611 | kmemleak_skip_disable = 1; | ||
| 1612 | else | ||
| 1608 | return -EINVAL; | 1613 | return -EINVAL; |
| 1609 | return 0; | 1614 | return 0; |
| 1610 | } | 1615 | } |
| @@ -1618,6 +1623,13 @@ void __init kmemleak_init(void) | |||
| 1618 | int i; | 1623 | int i; |
| 1619 | unsigned long flags; | 1624 | unsigned long flags; |
| 1620 | 1625 | ||
| 1626 | #ifdef CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF | ||
| 1627 | if (!kmemleak_skip_disable) { | ||
| 1628 | kmemleak_disable(); | ||
| 1629 | return; | ||
| 1630 | } | ||
| 1631 | #endif | ||
| 1632 | |||
| 1621 | jiffies_min_age = msecs_to_jiffies(MSECS_MIN_AGE); | 1633 | jiffies_min_age = msecs_to_jiffies(MSECS_MIN_AGE); |
| 1622 | jiffies_scan_wait = msecs_to_jiffies(SECS_SCAN_WAIT * 1000); | 1634 | jiffies_scan_wait = msecs_to_jiffies(SECS_SCAN_WAIT * 1000); |
| 1623 | 1635 | ||
