perf_lock_contention
Identifies lock contention in Linux by analyzing wait times and stack traces, with optional BPF tracing to pinpoint where threads block.
Instructions
Detailed lock contention analysis showing where threads wait for locks, with optional BPF-based tracking.
Key parameters:
lock_addr: show lock addresses.
lock_owner: show which task holds the lock.
callstack_filter: filter by callstack pattern.
use_bpf: use BPF for live contention tracing.
type_filter: filter by lock type.
stack_skip: skip N stack frames.
Output: contention table with wait times and optional stacks. Requires: perf lock record or lock tracepoints.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cpu | No | CPUs to filter | |
| key | No | Sort key | |
| map | No | Show lock map | |
| pid | No | Filter by PID | |
| tid | No | Filter by TID | |
| sort | No | Sort by key(s): contended,wait_total,wait_max,wait_min,avg_wait | |
| force | No | Don't complain, do it | |
| input | Yes | Path to perf.data file | |
| quiet | No | Do not show any warnings | |
| output | No | Output file path | |
| threads | No | Show per-thread stats | |
| use_bpf | No | Use BPF for contention tracing | |
| verbose | No | Verbosity level (0-2) | |
| vmlinux | No | vmlinux pathname | |
| all_cpus | No | System-wide collection | |
| kallsyms | No | kallsyms pathname | |
| lock_addr | No | Show lock addresses | |
| max_stack | No | Maximum stack depth | |
| lock_owner | No | Show lock owners | |
| stack_skip | No | Number of stack frames to skip | |
| lock_cgroup | No | Show lock contention per cgroup | |
| lock_filter | No | Filter by specific lock addr/name | |
| type_filter | No | Filter by lock type | |
| inject_delay | No | Inject delay in microseconds | |
| cgroup_filter | No | Filter by cgroup | |
| combine_locks | No | Combine locks by caller | |
| dump_raw_trace | No | Dump raw trace in ASCII | |
| map_nr_entries | No | Max entries for BPF maps | |
| callstack_filter | No | Filter by callstack pattern |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |