The Linux kernel has a tremendously useful feature begging to be taken advantage of by kernel developers: a runtime locking correctness or locking dependency validator; in short, lockdep. The basic idea is this: the lockdep runtime comes into play whenever any locking activity occurs within the kernel – the taking or the release of any kernel-level lock, or any locking sequence involving multiple locks.
This is tracked or mapped (see the following paragraph for more on the performance impact and how it's mitigated). By applying well-known rules for correct locking (you got a hint of this in the previous chapter in the Locking guidelines and deadlock section), lockdep then makes a conclusion regarding the validity of the correctness of what was done.
The beauty of it is that lockdep achieves 100% mathematical proof (or closure) that a lock sequence is correct or not. The...