-h Print usage message.
-i SEC print summary at this interval (seconds)
-c CALLER print locks taken by given caller filter (e.g., pipe_)
-S FIELDS sort data on specific columns defined by FIELDS string (by default the data is sorted by Max columns) FIELDS string contains 1 or 2 fields describing columns to sort on for both acquiring and holding data. Following fields are available: acq_max for 'Max spin' column acq_total for 'Total spin' column acq_count for 'Count' column hld_max for 'Max hold' column hld_total for 'Total hold' column hld_count for 'Count' column See EXAMPLES.
-n COUNT print COUNT number of locks
-s COUNT print COUNT number of stack entries
-p PID Trace this process ID only (filtered in-kernel).
-t TID Trace this thread ID only (filtered in-kernel).
-d DURATION Total duration of trace in seconds.
--stack-storage-size STACK_STORAGE_SIZE Change the number of unique stack traces that can be stored and displayed.
Sort lock acquired results on acquired count: # klockstat -S acq_count
Sort lock held results on total held time: # klockstat -S hld_total
Combination of above: # klockstat -S acq_count,hld_total
Trace system wide: # klockstat
Trace for 5 seconds only: # klockstat -d 5
Display stats every 5 seconds # klockstat -i 5
Trace locks for PID 123: # klockstat -p 123
Trace locks for TID 321: # klockstat -t 321
Display stats only for lock callers with 'pipe_' substring # klockstat -c pipe_
Display 3 locks: # klockstat -n 3
Display 10 levels of stack for the most expensive lock: # klockstat -n 1 -s 10 Tracing lock events... Hit Ctrl-C to end. ^C Caller Avg Spin Count Max spin Total spin pipe_wait+0xa9 670 397691 17273 266775437 pipe_wait+0xa9 pipe_read+0x206 new_sync_read+0x12a vfs_read+0x9d ksys_read+0x5f do_syscall_64+0x5b entry_SYSCALL_64_after_hwframe+0x44 Caller Avg Hold Count Max hold Total hold flush_to_ldisc+0x22 28381 3 65484 85144 flush_to_ldisc+0x22 process_one_work+0x1b0 worker_thread+0x50 kthread+0xfb ret_from_fork+0x35
Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool.