Due to its relevance and importance to lock debugging, we will take a quick look at a key point from the Linux Kernel patch submission checklist document (https://www.kernel.org/doc/html/v5.4/process/submit-checklist.html) that's most relevant to our discussions here, on enabling a debug kernel (especially for lock debugging):
// https://www.kernel.org/doc/html/v5.4/process/submit-checklist.html
[...]
12. Has been tested with CONFIG_PREEMPT, CONFIG_DEBUG_PREEMPT, CONFIG_DEBUG_SLAB, CONFIG_DEBUG_PAGEALLOC, CONFIG_DEBUG_MUTEXES, CONFIG_DEBUG_SPINLOCK, CONFIG_DEBUG_ATOMIC_SLEEP, CONFIG_PROVE_RCU and CONFIG_DEBUG_OBJECTS_RCU_HEAD all simultaneously enabled.
13. Has been build- and runtime tested with and without CONFIG_SMP and CONFIG_PREEMPT.
16. All codepaths have been exercised with all lockdep features enabled.
[ ... ]
Though not covered in this book, I cannot fail to mention a very powerful dynamic memory error detector...