In case of spinlock recursion bugs, knowing which entity acquired the
lock initially is key to debugging. Therefore, save the stack frames
when the lock is acquired and print them when spinlock recursion is
detected.
Signed-off-by: Guru Das Srinagesh <gurus@xxxxxxxxxxxxxx>
---
include/linux/spinlock_types.h | 3 +++
kernel/locking/spinlock_debug.c | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h
index b981caa..8a68d55 100644
--- a/include/linux/spinlock_types.h
+++ b/include/linux/spinlock_types.h
@@ -22,6 +22,9 @@ typedef struct raw_spinlock {
#ifdef CONFIG_DEBUG_SPINLOCK
unsigned int magic, owner_cpu;
void *owner;
+#define MAX_STACK_LEN 16
+ int stack_len;
+ unsigned long stack_trace[MAX_STACK_LEN];
#endif