Skip to contentSkip to conversation

locking/lockdep: Make MAX_STACK_TRACE_ENTRIES configurable

PATCH RESEND New Waiman Long 1 participant 1 message Oct 23, 2017

Subsystems (2)
lore
Share & tools
lore

Waiman Long

author reviewer
#0 lore raw

PATCH RESEND 1/1 locking/lockdep: Make MAX_STACK_TRACE_ENTRIES configurable

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.

---
 kernel/locking/lockdep_internals.h |  6 ++++++
 lib/Kconfig.debug                  | 12 ++++++++++++
 2 files changed, 18 insertions(+)
kernel/locking/lockdep_internals.h +6 -0
index 1da4669..0873e9b 100644
@@ -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)
lib/Kconfig.debug +12 -0
index ee9e534..0e8fc4e 100644
@@ -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
Signature · 1 line
1.8.3.1