aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Kconfig.debug15
-rw-r--r--mm/kmemleak.c10
2 files changed, 21 insertions, 4 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index b3c91b9e32f8..2b5a4256e88b 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -593,6 +593,21 @@ config DEBUG_KMEMLEAK_DEFAULT_OFF
593 Say Y here to disable kmemleak by default. It can then be enabled 593 Say Y here to disable kmemleak by default. It can then be enabled
594 on the command line via kmemleak=on. 594 on the command line via kmemleak=on.
595 595
596config DEBUG_KMEMLEAK_AUTO_SCAN
597 bool "Enable kmemleak auto scan thread on boot up"
598 default y
599 depends on DEBUG_KMEMLEAK
600 help
601 Depending on the cpu, kmemleak scan may be cpu intensive and can
602 stall user tasks at times. This option enables/disables automatic
603 kmemleak scan at boot up.
604
605 Say N here to disable kmemleak auto scan thread to stop automatic
606 scanning. Disabling this option disables automatic reporting of
607 memory leaks.
608
609 If unsure, say Y.
610
596config DEBUG_STACK_USAGE 611config DEBUG_STACK_USAGE
597 bool "Stack utilization instrumentation" 612 bool "Stack utilization instrumentation"
598 depends on DEBUG_KERNEL && !IA64 613 depends on DEBUG_KERNEL && !IA64
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 9c3d2dea0861..f9d9dc250428 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1650,7 +1650,7 @@ static void kmemleak_scan(void)
1650 */ 1650 */
1651static int kmemleak_scan_thread(void *arg) 1651static int kmemleak_scan_thread(void *arg)
1652{ 1652{
1653 static int first_run = 1; 1653 static int first_run = IS_ENABLED(CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN);
1654 1654
1655 pr_info("Automatic memory scanning thread started\n"); 1655 pr_info("Automatic memory scanning thread started\n");
1656 set_user_nice(current, 10); 1656 set_user_nice(current, 10);
@@ -2144,9 +2144,11 @@ static int __init kmemleak_late_init(void)
2144 return -ENOMEM; 2144 return -ENOMEM;
2145 } 2145 }
2146 2146
2147 mutex_lock(&scan_mutex); 2147 if (IS_ENABLED(CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN)) {
2148 start_scan_thread(); 2148 mutex_lock(&scan_mutex);
2149 mutex_unlock(&scan_mutex); 2149 start_scan_thread();
2150 mutex_unlock(&scan_mutex);
2151 }
2150 2152
2151 pr_info("Kernel memory leak detector initialized\n"); 2153 pr_info("Kernel memory leak detector initialized\n");
2152 2154