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 /mm/kmemleak.c | |
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>
Diffstat (limited to 'mm/kmemleak.c')
-rw-r--r-- | mm/kmemleak.c | 14 |
1 files changed, 13 insertions, 1 deletions
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 | ||