aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2009-06-25 05:16:11 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2009-06-25 05:16:13 -0400
commita9d9058abab4ac17b79d500506e6c74bd16cecdc (patch)
tree3b12a8f093431979b3e26e04f115b4ce942ce363
parent28d0325ce6e0a52f53d8af687e6427fee59004d3 (diff)
kmemleak: Allow the early log buffer to be configurable.
(feature suggested by Sergey Senozhatsky) Kmemleak needs to track all the memory allocations but some of these happen before kmemleak is initialised. These are stored in an internal buffer which may be exceeded in some kernel configurations. This patch adds a configuration option with a default value of 400 and also removes the stack dump when the early log buffer is exceeded. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Sergey Senozhatsky <sergey.senozhatsky@mail.by>
-rw-r--r--Documentation/kmemleak.txt4
-rw-r--r--lib/Kconfig.debug12
-rw-r--r--mm/kmemleak.c5
3 files changed, 19 insertions, 2 deletions
diff --git a/Documentation/kmemleak.txt b/Documentation/kmemleak.txt
index 0112da3b9ab8..f655308064d7 100644
--- a/Documentation/kmemleak.txt
+++ b/Documentation/kmemleak.txt
@@ -41,6 +41,10 @@ Memory scanning parameters can be modified at run-time by writing to the
41Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on 41Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on
42the kernel command line. 42the kernel command line.
43 43
44Memory may be allocated or freed before kmemleak is initialised and
45these actions are stored in an early log buffer. The size of this buffer
46is configured via the CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE option.
47
44Basic Algorithm 48Basic Algorithm
45--------------- 49---------------
46 50
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 4c32b1a1a06e..12327b2bb785 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -359,6 +359,18 @@ config DEBUG_KMEMLEAK
359 In order to access the kmemleak file, debugfs needs to be 359 In order to access the kmemleak file, debugfs needs to be
360 mounted (usually at /sys/kernel/debug). 360 mounted (usually at /sys/kernel/debug).
361 361
362config DEBUG_KMEMLEAK_EARLY_LOG_SIZE
363 int "Maximum kmemleak early log entries"
364 depends on DEBUG_KMEMLEAK
365 range 200 2000
366 default 400
367 help
368 Kmemleak must track all the memory allocations to avoid
369 reporting false positives. Since memory may be allocated or
370 freed before kmemleak is initialised, an early log buffer is
371 used to store these actions. If kmemleak reports "early log
372 buffer exceeded", please increase this value.
373
362config DEBUG_KMEMLEAK_TEST 374config DEBUG_KMEMLEAK_TEST
363 tristate "Simple test for the kernel memory leak detector" 375 tristate "Simple test for the kernel memory leak detector"
364 depends on DEBUG_KMEMLEAK 376 depends on DEBUG_KMEMLEAK
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index c96f2c8700aa..17096d1b59b2 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -235,7 +235,7 @@ struct early_log {
235}; 235};
236 236
237/* early logging buffer and current position */ 237/* early logging buffer and current position */
238static struct early_log early_log[200]; 238static struct early_log early_log[CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE];
239static int crt_early_log; 239static int crt_early_log;
240 240
241static void kmemleak_disable(void); 241static void kmemleak_disable(void);
@@ -696,7 +696,8 @@ static void log_early(int op_type, const void *ptr, size_t size,
696 struct early_log *log; 696 struct early_log *log;
697 697
698 if (crt_early_log >= ARRAY_SIZE(early_log)) { 698 if (crt_early_log >= ARRAY_SIZE(early_log)) {
699 kmemleak_stop("Early log buffer exceeded\n"); 699 pr_warning("Early log buffer exceeded\n");
700 kmemleak_disable();
700 return; 701 return;
701 } 702 }
702 703