libbpf-tools: add klockstat
This is a port of BCC's klockstat. Differences from BCC:
- can specify a lock by ksym name, using -L
- tracks whichever task had the max time for acquire and hold, outputted
when -s > 1 (otherwise it's cluttered).
- does not reset stats each interval by default. Can request with -R.
-------------
Usage: klockstat [-hRT] [-p PID] [-t TID] [-c FUNC] [-L LOCK] [-n NR_LOCKS]
[-s NR_STACKS] [-S SORT] [-d DURATION] [-i INTERVAL]
-p, --pid=PID Filter by process ID
-t, --tid=TID Filter by thread ID
-c, --caller=FUNC Filter by caller string prefix
-L, --lock=LOCK Filter by specific ksym lock name
-n, --locks=NR_LOCKS Number of locks to print
-s, --stacks=NR_STACKS Number of stack entries to print per lock
-S, --sort=SORT Sort by field:
acq_[max|total|count]
hld_[max|total|count]
-d, --duration=SECONDS Duration to trace
-i, --interval=SECONDS Print interval
-R, --reset Reset stats each interval
-T, --timestamp Print timestamp
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
Examples:
klockstat # trace system wide until ctrl-c
klockstat -d 5 # trace for 5 seconds
klockstat -i 5 # print stats every 5 seconds
klockstat -p 181 # trace process 181 only
klockstat -t 181 # trace thread 181 only
klockstat -c pipe_ # print only for lock callers with 'pipe_'
# prefix
klockstat -L cgroup_mutex # trace the cgroup_mutex lock only
klockstat -S acq_count # sort lock acquired results by acquire count
klockstat -S hld_total # sort lock held results by total held time
klockstat -S acq_count,hld_total # combination of above
klockstat -n 3 # display top 3 locks
klockstat -s 6 # display 6 stack entries per lock
-------------
Signed-off-by: Barret Rhoden <brho@google.com>