In user space, you will be familiar with using the very useful assert() macro. There, you assert a Boolean expression, a condition (for example, assert(p == 5);). If the assertion is true at runtime, nothing happens and execution continues; when the assertion is false, the process is aborted and a noisy printf() to stderr indicates which assertion and where it failed. This allows developers to check for runtime conditions that they expect. Thus, assertions can be very valuable – they help catch bugs!
In a similar manner, lockdep allows the kernel developer to assert that a lock is held at a particular point, via the lockdep_assert_held() macro. This is called a lockdep annotation. The macro definition is displayed here:
// include/linux/lockdep.h
#define lockdep_assert_held(l) do { \
WARN_ON(debug_locks && !lockdep_is_held(l)); \
} while (0)
The assertion failing results in a warning (via WARN_ON...