deadlock_detector(8) | System Manager's Manual | deadlock_detector(8) |
deadlock_detector - Find potential deadlocks (lock order inversions) in a running program.
deadlock_detector [-h] [--binary BINARY] [--dump-graph DUMP_GRAPH] [--verbose] [--lock-symbols LOCK_SYMBOLS] [--unlock-symbols UNLOCK_SYMBOLS] pid
deadlock_detector finds potential deadlocks in a running process. The program attaches uprobes on `pthread_mutex_lock` and `pthread_mutex_unlock` by default to build a mutex wait directed graph, and then looks for a cycle in this graph. This graph has the following properties:
- Nodes in the graph represent mutexes.
- Edge (A, B) exists if there exists some thread T where lock(A) was called and lock(B) was called before unlock(A) was called.
If there is a cycle in this graph, this indicates that there is a lock order inversion (potential deadlock). If the program finds a lock order inversion, the program will dump the cycle of mutexes, dump the stack traces where each mutex was acquired, and then exit.
This program can only find potential deadlocks that occur while the program is tracing the process. It cannot find deadlocks that may have occurred before the program was attached to the process.
This tool does not work for shared mutexes or recursive mutexes.
Since this uses BPF, only the root user can use this tool.
CONFIG_BPF and bcc
This program does not output any fields. Rather, it will keep running until it finds a potential deadlock, or the user hits Ctrl-C. If the program finds a potential deadlock, it will output the stack traces and lock order inversion in the following format and exit:
This traces all mutex lock and unlock events and all thread creation events on the traced process. The overhead of this can be high if the process has many threads and mutexes. You should only run this on a process where the slowdown is acceptable.
This is from bcc.
Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool.
Linux
Unstable - in development.
Kenny Yu
2017-02-01 | USER COMMANDS |