From bf98d686befa50fe244c283da20588425f58559a Mon Sep 17 00:00:00 2001 From: Rohit Vaswani Date: Thu, 2 Oct 2014 21:02:56 -0700 Subject: [PATCH] lib: spinlock: Cause a watchdog bite on spin_dump Currently we cause a BUG_ON once a spin_bug is detected, but that causes a whole lot of processing and the other CPUs would have proceeded to perform other actions and the state of the system is moved by the time we can analyze it. Provide an option to trigger a watchdog bite instead so that we can get the traces as close to the issue as possible. Change-Id:Ic8d692ebd02c6940a3b4e5798463744db20b0026 Signed-off-by: Rohit Vaswani Signed-off-by: Rishabh Bhatnagar [rananta@codeaurora.org: Resolved trivial merge conflicts] Signed-off-by: Raghavendra Rao Ananta --- kernel/locking/spinlock_debug.c | 8 ++++++++ lib/Kconfig.debug | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/kernel/locking/spinlock_debug.c b/kernel/locking/spinlock_debug.c index 472dd462a40c..1cb23cae1b91 100644 --- a/kernel/locking/spinlock_debug.c +++ b/kernel/locking/spinlock_debug.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name, struct lock_class_key *key) @@ -64,6 +66,12 @@ static void spin_dump(raw_spinlock_t *lock, const char *msg) owner ? owner->comm : "", owner ? task_pid_nr(owner) : -1, READ_ONCE(lock->owner_cpu)); + +#ifdef CONFIG_DEBUG_SPINLOCK_BITE_ON_BUG + msm_trigger_wdog_bite(); +#elif defined(CONFIG_DEBUG_SPINLOCK_PANIC_ON_BUG) + BUG(); +#endif dump_stack(); } diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index d0d614246564..8e9a7880dd59 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1085,6 +1085,29 @@ config LOCK_DEBUGGING_SUPPORT depends on TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT default y +choice + prompt "Perform Action on spinlock bug" + depends on DEBUG_SPINLOCK + + default DEBUG_SPINLOCK_BITE_ON_BUG + + config DEBUG_SPINLOCK_BITE_ON_BUG + bool "Cause a Watchdog Bite on Spinlock bug" + depends on QCOM_WATCHDOG_V2 + help + On a spinlock bug, cause a watchdog bite so that we can get + the precise state of the system captured at the time of spin + dump. This is mutually exclusive with the below + DEBUG_SPINLOCK_PANIC_ON_BUG config. + + config DEBUG_SPINLOCK_PANIC_ON_BUG + bool "Cause a Kernel Panic on Spinlock bug" + help + On a spinlock bug, cause a kernel panic so that we can get the complete + information about the system at the time of spin dump in the dmesg. + This is mutually exclusive with the above DEBUG_SPINLOCK_BITE_ON_BUG. +endchoice + config PROVE_LOCKING bool "Lock debugging: prove locking correctness" depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT