Generally it is hard to debug any synchronization (or concurrency) related issue's are because they are usually difficult to reproduce. But it always recommend to enable SMP (CONFIG_SMP) & preemption (CONFIG_PREEMPT) options while building and testing our kernel code, even though our kernel productions code is going to run on a UP machine without preemption enabled.
- There are general ways to catch some common spinlock and mutex related errors by enabling kernel configuration option under Kernel hacking,By enabling "Spinlock and rw-lock debugging" (CONFIG_DEBUG_SPINLOCK) that helps find some common spinlock errors.
- By turning on CONFIG_DEBUG_MUTEXES to checks for mutex-related errors code.
There are some tools also available to debug such as lockmeter.