Skip to content

Commit 71f9c2a

Browse files
committed
rename tool lockstat.py to klockstat.py
The current lockstat.py is tracing three kernel functions mutex_lock_enter(), mutex_unlock_enter(), mutex_lock_return() for kernel locking statistics. There are some other efforts trying to get user lock stats by tracing e.g. pthread locking primitives. For example, Sasha Goldshtein's linux-tracing-workshop https://github.com/goldshtn/linux-tracing-workshop is referenced in bcc/docs/tutorial_bcc_python_developer.md. It has a tool called lockstat.py which traces pthread_mutex_init to collect some lock statistics for userspace locks. In bcc, in the past, we also had an effort to gather userspace lock statistics with the same name lockstat.py. #1268 In the future, bcc could have a lockstat tool tracing userspace locks. So let us rename the current lockstat.py to klockstat.py to clearly express its scope.
1 parent b040635 commit 71f9c2a

File tree

6 files changed

+42
-42
lines changed

6 files changed

+42
-42
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pair of .c and .py files, and some are directories of files.
118118
- tools/[hardirqs](tools/hardirqs.py): Measure hard IRQ (hard interrupt) event time. [Examples](tools/hardirqs_example.txt).
119119
- tools/[inject](tools/inject.py): Targeted error injection with call chain and predicates [Examples](tools/inject_example.txt).
120120
- tools/[killsnoop](tools/killsnoop.py): Trace signals issued by the kill() syscall. [Examples](tools/killsnoop_example.txt).
121-
- tools/[lockstat](tools/lockstat.py): Traces kernel mutex lock events and display locks statistics. [Examples](tools/lockstat_example.txt).
121+
- tools/[klockstat](tools/klockstat.py): Traces kernel mutex lock events and display locks statistics. [Examples](tools/klockstat_example.txt).
122122
- tools/[llcstat](tools/llcstat.py): Summarize CPU cache references and misses by process. [Examples](tools/llcstat_example.txt).
123123
- tools/[mdflush](tools/mdflush.py): Trace md flush events. [Examples](tools/mdflush_example.txt).
124124
- tools/[memleak](tools/memleak.py): Display outstanding memory allocations to find memory leaks. [Examples](tools/memleak_example.txt).

man/man8/lockstat.8 man/man8/klockstat.8

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
.TH lockstat 8 "2019-10-22" "USER COMMANDS"
1+
.TH klockstat 8 "2019-10-22" "USER COMMANDS"
22
.SH NAME
3-
lockstat \- Traces kernel mutex lock events and display locks statistics. Uses Linux eBPF/bcc.
3+
klockstat \- Traces kernel mutex lock events and display locks statistics. Uses Linux eBPF/bcc.
44
.SH SYNOPSIS
5-
.B lockstat [\-h] [\-i] [\-n] [\-s] [\-c] [\-S FIELDS] [\-p] [\-t] [\-d DURATION]
5+
.B klockstat [\-h] [\-i] [\-n] [\-s] [\-c] [\-S FIELDS] [\-p] [\-t] [\-d DURATION]
66
.SH DESCRIPTION
7-
lockstats traces kernel mutex lock events and display locks statistics
7+
klockstat traces kernel mutex lock events and display locks statistics
88
and displays following data:
99

1010
Caller Avg Spin Count Max spin Total spin
@@ -101,57 +101,57 @@ Change the number of unique stack traces that can be stored and displayed.
101101
.TP
102102
Sort lock acquired results on acquired count:
103103
#
104-
.B lockstats -S acq_count
104+
.B klockstat -S acq_count
105105

106106
.TP
107107
Sort lock held results on total held time:
108108
#
109-
.B lockstats -S hld_total
109+
.B klockstat -S hld_total
110110

111111
.TP
112112
Combination of above:
113113
#
114-
.B lockstats -S acq_count,hld_total
114+
.B klockstat -S acq_count,hld_total
115115

116116
.TP
117117
Trace system wide:
118118
#
119-
.B lockstats
119+
.B klockstat
120120

121121
.TP
122122
Trace for 5 seconds only:
123123
#
124-
.B lockstats -d 5
124+
.B klockstat -d 5
125125

126126
.TP
127127
Display stats every 5 seconds
128128
#
129-
.B lockstats -i 5
129+
.B klockstat -i 5
130130

131131
.TP
132132
Trace locks for PID 123:
133133
#
134-
.B lockstats -p 123
134+
.B klockstat -p 123
135135

136136
.TP
137137
Trace locks for PID 321:
138138
#
139-
.B lockstats -t 321
139+
.B klockstat -t 321
140140

141141
.TP
142142
Display stats only for lock callers with 'pipe_' substring
143143
#
144-
.B lockstats -c pipe_
144+
.B klockstat -c pipe_
145145

146146
.TP
147147
Display 3 locks:
148148
#
149-
.B lockstats -n 3
149+
.B klockstat -n 3
150150

151151
.TP
152152
Display 10 levels of stack for the most expensive lock:
153153
#
154-
.B lockstats -n 1 -s 10
154+
.B klockstat -n 1 -s 10
155155

156156
Tracing lock events... Hit Ctrl-C to end.
157157
^C

snapcraft/snapcraft.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ apps:
151151
command: bcc-wrapper javathreads
152152
killsnoop:
153153
command: bcc-wrapper killsnoop
154-
lockstat:
155-
command: bcc-wrapper lockstat
154+
klockstat:
155+
command: bcc-wrapper klockstat
156156
llcstat:
157157
command: bcc-wrapper llcstat
158158
mdflush:

tests/python/test_tools_smoke.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ def test_killsnoop(self):
200200
self.run_with_int("killsnoop.py", kill=True)
201201

202202
@skipUnless(kernel_version_ge(4,18), "requires kernel >= 4.18")
203-
def test_lockstat(self):
204-
self.run_with_int("lockstat.py")
203+
def test_klockstat(self):
204+
self.run_with_int("klockstat.py")
205205

206206
@skipUnless(kernel_version_ge(4,9), "requires kernel >= 4.9")
207207
def test_llcstat(self):

tools/lockstat.py tools/klockstat.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/python
22
#
3-
# lockstats traces lock events and display locks statistics.
3+
# klockstat traces lock events and display locks statistics.
44
#
5-
# USAGE: lockstats
5+
# USAGE: klockstat
66
#
77

88
from __future__ import print_function
@@ -16,17 +16,17 @@
1616
from sys import stderr
1717

1818
examples = """
19-
lockstats # trace system wide
20-
lockstats -d 5 # trace for 5 seconds only
21-
lockstats -i 5 # display stats every 5 seconds
22-
lockstats -p 123 # trace locks for PID 123
23-
lockstats -t 321 # trace locks for PID 321
24-
lockstats -c pipe_ # display stats only for lock callers with 'pipe_' substring
25-
lockstats -S acq_count # sort lock acquired results on acquired count
26-
lockstats -S hld_total # sort lock held results on total held time
27-
lockstats -S acq_count,hld_total # combination of above
28-
lockstats -n 3 # display 3 locks
29-
lockstats -s 3 # display 3 levels of stack
19+
klockstat # trace system wide
20+
klockstat -d 5 # trace for 5 seconds only
21+
klockstat -i 5 # display stats every 5 seconds
22+
klockstat -p 123 # trace locks for PID 123
23+
klockstat -t 321 # trace locks for PID 321
24+
klockstat -c pipe_ # display stats only for lock callers with 'pipe_' substring
25+
klockstat -S acq_count # sort lock acquired results on acquired count
26+
klockstat -S hld_total # sort lock held results on total held time
27+
klockstat -S acq_count,hld_total # combination of above
28+
klockstat -n 3 # display 3 locks
29+
klockstat -s 3 # display 3 levels of stack
3030
"""
3131

3232
# arg validation

tools/lockstat_example.txt tools/klockstat_example.txt

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Demonstrations of lockstat, the Linux eBPF/bcc version.
1+
Demonstrations of klockstat, the Linux eBPF/bcc version.
22

3-
lockstats traces kernel mutex lock events and display locks statistics
3+
klockstat traces kernel mutex lock events and display locks statistics
44

5-
# lockstat.py
5+
# klockstat.py
66
Tracing lock events... Hit Ctrl-C to end.
77
^C
88
Caller Avg Spin Count Max spin Total spin
@@ -50,7 +50,7 @@ lock stats in maps and processing them in the python part.
5050

5151
An -i option can be used to display stats in interval (5 seconds in example below):
5252

53-
# lockstat.py -i 5
53+
# klockstat.py -i 5
5454
Tracing lock events... Hit Ctrl-C to end.
5555

5656
Caller Avg Spin Count Max spin Total spin
@@ -73,7 +73,7 @@ Tracing lock events... Hit Ctrl-C to end.
7373

7474
A -p option can be used to trace only selected process:
7575

76-
# lockstat.py -p 883
76+
# klockstat.py -p 883
7777
Tracing lock events... Hit Ctrl-C to end.
7878
^C
7979
Caller Avg Spin Count Max spin Total spin
@@ -89,7 +89,7 @@ Tracing lock events... Hit Ctrl-C to end.
8989

9090
A -c option can be used to display only callers with specific substring:
9191

92-
# lockstat.py -c pipe_
92+
# klockstat.py -c pipe_
9393
Tracing lock events... Hit Ctrl-C to end.
9494
^C
9595
Caller Avg Spin Count Max spin Total spin
@@ -105,7 +105,7 @@ Tracing lock events... Hit Ctrl-C to end.
105105

106106
An -n option can be used to display only specific number of callers:
107107

108-
# lockstat.py -n 3
108+
# klockstat.py -n 3
109109
Tracing lock events... Hit Ctrl-C to end.
110110
^C
111111
Caller Avg Spin Count Max spin Total spin
@@ -121,7 +121,7 @@ Tracing lock events... Hit Ctrl-C to end.
121121

122122
An -s option can be used to display number of callers backtrace entries:
123123

124-
# lockstat.py -n 1 -s 3
124+
# klockstat.py -n 1 -s 3
125125
Tracing lock events... Hit Ctrl-C to end.
126126
^C
127127
Caller Avg Spin Count Max spin Total spin
@@ -139,7 +139,7 @@ Output can be sorted by using -S <fields> option on various
139139
fields, the acq_total will force the acquired table to be
140140
sorted on 'Total spin' column:
141141

142-
# lockstat.py -S acq_total
142+
# klockstat.py -S acq_total
143143
Tracing lock events... Hit Ctrl-C to end.
144144
^C
145145
Caller Avg Spin Count Max spin Total spin

0 commit comments

Comments
 (0)