Skip to content

Commit

Permalink
kmemleak : Make kmemleak_stack_scan optional using config
Browse files Browse the repository at this point in the history
Currently we have kmemleak_stack_scan enabled by default.
This can hog the cpu with pre-emption disabled for a long
time starving other tasks.

Make this optional at compile time, since if required
we can always write to sysfs entry and enable this option.

Change-Id: Ie30447861c942337c7ff25ac269b6025a527e8eb
Signed-off-by: Vignesh Radhakrishnan <vigneshr@codeaurora.org>
Signed-off-by: Prasad Sodagudi <psodagud@codeaurora.org>
  • Loading branch information
Vignesh Radhakrishnan authored and Prasad Sodagudi committed Aug 23, 2015
1 parent 5a79eb4 commit 55048cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/Kconfig.debug
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,15 @@ config DEBUG_MODULE_SCAN_OFF
run with irq/preemption disabled for considerable amount
of time.

config DEBUG_TASK_STACK_SCAN_OFF
bool "Disable kmemleak task stack scan by default"
depends on DEBUG_KMEMLEAK
help
Say Y here to disable kmemleak task stack scan by default
at compile time. It can be enabled later if required by
writing to the debugfs entry :
echo "stack=on" > /sys/kernel/debug/kmemleak.

config DEBUG_PREEMPT
bool "Debug preemptible kernel"
depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT
Expand Down
12 changes: 11 additions & 1 deletion mm/kmemleak.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,18 @@ static unsigned long jiffies_min_age;
static unsigned long jiffies_last_scan;
/* delay between automatic memory scannings */
static signed long jiffies_scan_wait;
/* enables or disables the task stacks scanning */

/* Enables or disables the task stacks scanning.
* Set to 1 if at compile time we want it enabled.
* Else set to 0 to have it disabled by default.
* This can be enabled by writing to "stack=on" using
* kmemleak debugfs entry.*/
#ifdef CONFIG_DEBUG_TASK_STACK_SCAN_OFF
static int kmemleak_stack_scan;
#else
static int kmemleak_stack_scan = 1;
#endif

/* protects the memory scanning, parameters and debug/kmemleak file access */
static DEFINE_MUTEX(scan_mutex);
/* setting kmemleak=on, will set this var, skipping the disable */
Expand Down

0 comments on commit 55048cd

Please sign in to comment.