$linuxjunkies
>

lockdep

also: lock dependency validator

A Linux kernel debugging tool that detects potential deadlocks by tracking lock dependencies and validating locking rules at runtime.

lockdep is a kernel subsystem that instruments all lock operations (mutexes, spinlocks, semaphores, etc.) to build a graph of lock dependencies. It validates that locks are always acquired in a consistent order to prevent circular wait conditions that cause deadlocks.

When enabled (via CONFIG_LOCKDEP), lockdep monitors every lock acquisition and release, checking for violations like attempting to acquire locks in different orders across code paths. If a problematic pattern is detected, the kernel logs a warning with details about which locks are involved and where.

Example: If Thread A locks X then Y, but Thread B locks Y then X, lockdep will warn about a potential deadlock scenario even before one actually occurs. This makes it invaluable for kernel developers to catch concurrency bugs during testing.

lockdep has minimal performance impact when disabled but adds significant overhead when active, so it's typically only used during development and debugging rather than in production kernels.

Related terms