[RESEND PATCH] locking/lockdep: Make MAX_STACK_TRACE_ENTRIES configurable

From: Waiman Long
Date: Mon Oct 23 2017 - 11:23:49 EST


A "BUG: MAX_STACK_TRACE_ENTRIES too low!" error was hit when running a
networking test on a 4.11 kernel. So even 512k of stack trace entries
wasn't enough in this case.

Instead of hardcoding a larger MAX_STACK_TRACE_ENTRIES value,
it is now made to be dependent on a new kernel configuration entry
LOCKDEP_MAX_STACK_TRACE_ENTRIES so that kernel builders can configure
a proper value depending on how the kernel is being used.

The default for this new config option is the same as the current
value - 256k if LOCKDEP_SMALL and 512k otherwise.

Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
---
kernel/locking/lockdep_internals.h | 6 ++++++
lib/Kconfig.debug | 12 ++++++++++++
2 files changed, 18 insertions(+)

diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h
index 1da4669..0873e9b 100644
--- a/kernel/locking/lockdep_internals.h
+++ b/kernel/locking/lockdep_internals.h
@@ -77,6 +77,12 @@ enum {
#define MAX_STACK_TRACE_ENTRIES 524288UL
#endif

+#ifdef CONFIG_LOCKDEP_MAX_STACK_TRACE_ENTRIES
+#undef MAX_STACK_TRACE_ENTRIES
+#define MAX_STACK_TRACE_ENTRIES \
+ ((unsigned long)CONFIG_LOCKDEP_MAX_STACK_TRACE_ENTRIES)
+#endif
+
#define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS)

#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index ee9e534..0e8fc4e 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1230,6 +1230,18 @@ config WW_MUTEX_SELFTEST
Say M if you want these self tests to build as a module.
Say N if you are unsure.

+# Allow 256k - 4M of lockdep stack trace entries
+config LOCKDEP_MAX_STACK_TRACE_ENTRIES
+ int "Maximum number of lockdep stack trace entries" if LOCKDEP
+ range 262144 4194304
+ default "262144" if LOCKDEP_SMALL
+ default "524288" if !LOCKDEP_SMALL
+ ---help---
+ This specifies the maximum number of lockdep stack trace
+ entries that can be used by the locking correctness
+ validator. If this limit is exceeded, the validator will
+ be turned off.
+
endmenu # lock debugging

config TRACE_IRQFLAGS
--
1.8.3.1