xref: /freebsd/share/man/man4/dtrace_lockstat.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1566569c4SGeorge V. Neville-Neil.\" Copyright (c) 2017 George V. Neville-Neil <gnn@FreeBSD.org>
2566569c4SGeorge V. Neville-Neil.\" All rights reserved.
3566569c4SGeorge V. Neville-Neil.\"
4566569c4SGeorge V. Neville-Neil.\" Redistribution and use in source and binary forms, with or without
5566569c4SGeorge V. Neville-Neil.\" modification, are permitted provided that the following conditions
6566569c4SGeorge V. Neville-Neil.\" are met:
7566569c4SGeorge V. Neville-Neil.\" 1. Redistributions of source code must retain the above copyright
8566569c4SGeorge V. Neville-Neil.\"    notice, this list of conditions and the following disclaimer.
9566569c4SGeorge V. Neville-Neil.\" 2. Redistributions in binary form must reproduce the above copyright
10566569c4SGeorge V. Neville-Neil.\"    notice, this list of conditions and the following disclaimer in the
11566569c4SGeorge V. Neville-Neil.\"    documentation and/or other materials provided with the distribution.
12566569c4SGeorge V. Neville-Neil.\"
13566569c4SGeorge V. Neville-Neil.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14566569c4SGeorge V. Neville-Neil.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15566569c4SGeorge V. Neville-Neil.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16566569c4SGeorge V. Neville-Neil.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17566569c4SGeorge V. Neville-Neil.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18566569c4SGeorge V. Neville-Neil.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19566569c4SGeorge V. Neville-Neil.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20566569c4SGeorge V. Neville-Neil.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21566569c4SGeorge V. Neville-Neil.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22566569c4SGeorge V. Neville-Neil.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23566569c4SGeorge V. Neville-Neil.\" SUCH DAMAGE.
24566569c4SGeorge V. Neville-Neil.\"
25*5b699f16SMark Johnston.Dd August 20, 2019
26566569c4SGeorge V. Neville-Neil.Dt DTRACE_LOCKSTAT 4
27566569c4SGeorge V. Neville-Neil.Os
28566569c4SGeorge V. Neville-Neil.Sh NAME
29566569c4SGeorge V. Neville-Neil.Nm dtrace_lockstat
30566569c4SGeorge V. Neville-Neil.Nd a DTrace provider for tracing CPU scheduling events
31566569c4SGeorge V. Neville-Neil.Sh SYNOPSIS
32566569c4SGeorge V. Neville-Neil.Fn lockstat:::adaptive-acquire "struct mtx *"
33566569c4SGeorge V. Neville-Neil.Fn lockstat:::adaptive-release "struct mtx *"
34566569c4SGeorge V. Neville-Neil.Fn lockstat:::adaptive-spin "struct mtx *" "uint64_t"
35566569c4SGeorge V. Neville-Neil.Fn lockstat:::adaptive-block "struct mtx *" "uint64_t"
36566569c4SGeorge V. Neville-Neil.Fn lockstat:::spin-acquire "struct mtx *"
37566569c4SGeorge V. Neville-Neil.Fn lockstat:::spin-release "struct mtx *"
38566569c4SGeorge V. Neville-Neil.Fn lockstat:::spin-spin "struct mtx *" "uint64_t"
39566569c4SGeorge V. Neville-Neil.Fn lockstat:::rw-acquire "struct rwlock *" "int"
40566569c4SGeorge V. Neville-Neil.Fn lockstat:::rw-release "struct rwlock *" "int"
41566569c4SGeorge V. Neville-Neil.Fn lockstat:::rw-block "struct rwlock *" "uint64_t" "int" "int" "int"
42566569c4SGeorge V. Neville-Neil.Fn lockstat:::rw-spin "struct rwlock *" "uint64_t"
43566569c4SGeorge V. Neville-Neil.Fn lockstat:::rw-upgrade "struct rwlock *"
44566569c4SGeorge V. Neville-Neil.Fn lockstat:::rw-downgrade "struct rwlock *"
45566569c4SGeorge V. Neville-Neil.Fn lockstat:::sx-acquire "struct sx *" "int"
46566569c4SGeorge V. Neville-Neil.Fn lockstat:::sx-release "struct sx *" "int"
47566569c4SGeorge V. Neville-Neil.Fn lockstat:::sx-block "struct sx *" "uint64_t" "int" "int" "int"
48566569c4SGeorge V. Neville-Neil.Fn lockstat:::sx-spin "struct sx *" "uint64_t"
49566569c4SGeorge V. Neville-Neil.Fn lockstat:::sx-upgrade "struct sx *"
50566569c4SGeorge V. Neville-Neil.Fn lockstat:::sx-downgrade "struct sx *"
51*5b699f16SMark Johnston.Fn lockstat:::lockmgr-acquire "struct lock *" "int"
52*5b699f16SMark Johnston.Fn lockstat:::lockmgr-release "struct lock *" "int"
53*5b699f16SMark Johnston.Fn lockstat:::lockmgr-disown "struct lock *" "int"
54*5b699f16SMark Johnston.Fn lockstat:::lockmgr-block "struct lock *" "uint64_t" "int" "int" "int"
55*5b699f16SMark Johnston.Fn lockstat:::lockmgr-upgrade "struct lock *"
56*5b699f16SMark Johnston.Fn lockstat:::lockmgr-downgrade "struct lock *"
57566569c4SGeorge V. Neville-Neil.Fn lockstat:::thread-spin "struct mtx *" "uint64"
58566569c4SGeorge V. Neville-Neil.Sh DESCRIPTION
59566569c4SGeorge V. Neville-NeilThe DTrace
60566569c4SGeorge V. Neville-Neil.Nm lockstat
6161b0ecf4SMark Johnstonprovider allows the tracing of events related to locking on
6261b0ecf4SMark Johnston.Fx .
63566569c4SGeorge V. Neville-Neil.Pp
64566569c4SGeorge V. Neville-NeilThe
65d3e9ec30SWarren Block.Nm
66d3e9ec30SWarren Blockprovider contains DTrace probes for inspecting kernel lock
67566569c4SGeorge V. Neville-Neilstate transitions.
6861b0ecf4SMark JohnstonProbes exist for the
69*5b699f16SMark Johnston.Xr lockmgr 9 ,
7061b0ecf4SMark Johnston.Xr mutex 9 ,
71d3e9ec30SWarren Block.Xr rwlock 9 ,
7261b0ecf4SMark Johnstonand
7361b0ecf4SMark Johnston.Xr sx 9
7461b0ecf4SMark Johnstonlock types.
7561b0ecf4SMark JohnstonThe
7661b0ecf4SMark Johnston.Xr lockstat 1
7761b0ecf4SMark Johnstonutility can be used to collect and display data collected from the
78d3e9ec30SWarren Block.Nm
79566569c4SGeorge V. Neville-Neilprovider.
8061b0ecf4SMark JohnstonEach type of lock has
81566569c4SGeorge V. Neville-Neil.Fn acquire
82566569c4SGeorge V. Neville-Neiland
83566569c4SGeorge V. Neville-Neil.Fn release
8461b0ecf4SMark Johnstonprobes which expose the lock structure being operated upon,
8561b0ecf4SMark Johnstonas well as probes which fire when a thread contends with other threads
8661b0ecf4SMark Johnstonfor ownership of a lock.
87566569c4SGeorge V. Neville-Neil.Pp
88566569c4SGeorge V. Neville-NeilThe
8961b0ecf4SMark Johnston.Fn lockstat:::adaptive-acquire
9061b0ecf4SMark Johnstonand
91566569c4SGeorge V. Neville-Neil.Fn lockstat:::adaptive-release
9261b0ecf4SMark Johnstonprobes fire when an
9361b0ecf4SMark Johnston.Dv MTX_DEF
9461b0ecf4SMark Johnston.Xr mutex 9
9561b0ecf4SMark Johnstonis acquired and released, respectively.
96566569c4SGeorge V. Neville-NeilThe only argument is a pointer to the lock structure which describes
9761b0ecf4SMark Johnstonthe lock being acquired or released.
98566569c4SGeorge V. Neville-Neil.Pp
99566569c4SGeorge V. Neville-NeilThe
100566569c4SGeorge V. Neville-Neil.Fn lockstat:::adaptive-spin
10161b0ecf4SMark Johnstonprobe fires when a thread spins while waiting for a
10261b0ecf4SMark Johnston.Dv MTX_DEF
10361b0ecf4SMark Johnston.Xr mutex 9
10461b0ecf4SMark Johnstonto be released by another thread.
105566569c4SGeorge V. Neville-NeilThe first argument is a pointer to the lock structure that describes
106566569c4SGeorge V. Neville-Neilthe lock and the second argument is the amount of time,
10761b0ecf4SMark Johnstonin nanoseconds, that the mutex spent spinning.
108566569c4SGeorge V. Neville-NeilThe
109566569c4SGeorge V. Neville-Neil.Fn lockstat:::adaptive-block
11061b0ecf4SMark Johnstonprobe fires when a thread takes itself off the CPU while trying to acquire an
11161b0ecf4SMark Johnston.Dv MTX_DEF
11261b0ecf4SMark Johnston.Xr mutex 9
11361b0ecf4SMark Johnstonthat is owned by another thread.
114566569c4SGeorge V. Neville-NeilThe first argument is a pointer to the lock structure that describes
115566569c4SGeorge V. Neville-Neilthe lock and the second argument is the length of time,
11661b0ecf4SMark Johnstonin nanoseconds, that the waiting thread was blocked.
117566569c4SGeorge V. Neville-NeilThe
118566569c4SGeorge V. Neville-Neil.Fn lockstat:::adaptive-block
11961b0ecf4SMark Johnstonand
12061b0ecf4SMark Johnston.Fn lockstat:::adaptive-spin
12161b0ecf4SMark Johnstonprobes fire only after the lock has been successfully acquired,
12261b0ecf4SMark Johnstonand in particular, after the
12361b0ecf4SMark Johnston.Fn lockstat:::adaptive-acquire
124566569c4SGeorge V. Neville-Neilprobe fires.
125566569c4SGeorge V. Neville-Neil.Pp
126566569c4SGeorge V. Neville-NeilThe
12761b0ecf4SMark Johnston.Fn lockstat:::spin-acquire
12861b0ecf4SMark Johnstonand
129566569c4SGeorge V. Neville-Neil.Fn lockstat:::spin-release
13061b0ecf4SMark Johnstonprobes fire when a
13161b0ecf4SMark Johnston.Dv MTX_SPIN
13261b0ecf4SMark Johnston.Xr mutex 9
133d3e9ec30SWarren Blockis acquired or released, respectively.
134566569c4SGeorge V. Neville-NeilThe only argument is a pointer to the lock structure which describes
13561b0ecf4SMark Johnstonthe lock being acquired or released.
136566569c4SGeorge V. Neville-Neil.Pp
137566569c4SGeorge V. Neville-NeilThe
138566569c4SGeorge V. Neville-Neil.Fn lockstat:::spin-spin
13961b0ecf4SMark Johnstonprobe fires when a thread spins while waiting for a
14061b0ecf4SMark Johnston.Dv MTX_SPIN
14161b0ecf4SMark Johnston.Xr mutex 9
14261b0ecf4SMark Johnstonto be released by another thread.
143566569c4SGeorge V. Neville-NeilThe first argument is a pointer to the lock structure that describes
144566569c4SGeorge V. Neville-Neilthe lock and the second argument is the length of the time
145566569c4SGeorge V. Neville-Neilspent spinning, in nanoseconds.
14661b0ecf4SMark JohnstonThe
14761b0ecf4SMark Johnston.Fn lockstat:::spin-spin
14861b0ecf4SMark Johnstonprobe fires only after the lock has been successfully acquired,
14961b0ecf4SMark Johnstonand in particular, after the
15061b0ecf4SMark Johnston.Fn lockstat:::spin-acquire
151566569c4SGeorge V. Neville-Neilprobe fires.
152566569c4SGeorge V. Neville-Neil.Pp
153566569c4SGeorge V. Neville-NeilThe
15461b0ecf4SMark Johnston.Fn lockstat:::rw-acquire
15561b0ecf4SMark Johnstonand
156566569c4SGeorge V. Neville-Neil.Fn lockstat:::rw-release
15761b0ecf4SMark Johnstonprobes fire when a
15861b0ecf4SMark Johnston.Xr rwlock 9
159d3e9ec30SWarren Blockis acquired or released, respectively.
16061b0ecf4SMark JohnstonThe first argument is a pointer to the structure which describes
16161b0ecf4SMark Johnstonthe lock being acquired.
16261b0ecf4SMark JohnstonThe second argument is
16361b0ecf4SMark Johnston.Dv 0
16461b0ecf4SMark Johnstonif the lock is being acquired or released as a writer, and
16561b0ecf4SMark Johnston.Dv 1
16661b0ecf4SMark Johnstonif it is being acquired or released as a reader.
167566569c4SGeorge V. Neville-NeilThe
16861b0ecf4SMark Johnston.Fn lockstat:::sx-acquire
16961b0ecf4SMark Johnstonand
170*5b699f16SMark Johnston.Fn lockstat:::sx-release ,
171*5b699f16SMark Johnstonand
172*5b699f16SMark Johnston.Fn lockstat:::lockmgr-acquire
173*5b699f16SMark Johnstonand
174*5b699f16SMark Johnston.Fn lockstat:::lockmgr-release
175*5b699f16SMark Johnstonprobes fire upon the corresponding events for
17661b0ecf4SMark Johnston.Xr sx 9
177*5b699f16SMark Johnstonand
178*5b699f16SMark Johnston.Xr lockmgr 9
179*5b699f16SMark Johnstonlocks, respectively.
180*5b699f16SMark JohnstonThe
181*5b699f16SMark Johnston.Fn lockstat:::lockmgr-disown
182*5b699f16SMark Johnstonprobe fires when a
183*5b699f16SMark Johnston.Xr lockmgr 9
184*5b699f16SMark Johnstonexclusive lock is disowned.
185*5b699f16SMark JohnstonIn this state, the lock remains exclusively held, but may be
186*5b699f16SMark Johnstonreleased by a different thread.
187*5b699f16SMark JohnstonThe
188*5b699f16SMark Johnston.Fn lockstat:::lockmgr-release
189*5b699f16SMark Johnstonprobe does not fire when releasing a disowned lock.
19061b0ecf4SMark JohnstonThe first argument is a pointer to the structure which describes
191*5b699f16SMark Johnstonthe lock being disowned.
19261b0ecf4SMark JohnstonThe second argument is
193*5b699f16SMark Johnston.Dv 0 ,
194*5b699f16SMark Johnstonfor compatibility with
195*5b699f16SMark Johnston.Fn lockstat:::lockmgr-release .
196566569c4SGeorge V. Neville-Neil.Pp
197566569c4SGeorge V. Neville-NeilThe
198*5b699f16SMark Johnston.Fn lockstat:::rw-block ,
199*5b699f16SMark Johnston.Fn lockstat:::sx-block ,
200*5b699f16SMark Johnstonand
201*5b699f16SMark Johnston.Fn lockstat:::lockmgr-block
202*5b699f16SMark Johnstonprobes fire when a thread removes itself from the CPU while
203*5b699f16SMark Johnstonwaiting to acquire a lock of the corresponding type.
204566569c4SGeorge V. Neville-NeilThe
205*5b699f16SMark Johnston.Fn lockstat:::rw-spin
206*5b699f16SMark Johnstonand
207566569c4SGeorge V. Neville-Neil.Fn lockstat:::sx-spin
208*5b699f16SMark Johnstonprobes fire when a thread spins while waiting to acquire a lock
209*5b699f16SMark Johnstonof the corresponding type.
210*5b699f16SMark JohnstonAll probes take the same set of arguments.
21161b0ecf4SMark JohnstonThe first argument is a pointer to the lock structure that describes
21261b0ecf4SMark Johnstonthe lock.
21361b0ecf4SMark JohnstonThe second argument is the length of time, in nanoseconds,
21461b0ecf4SMark Johnstonthat the waiting thread was off the CPU or spinning for the lock.
21561b0ecf4SMark JohnstonThe third argument is
21661b0ecf4SMark Johnston.Dv 0
21761b0ecf4SMark Johnstonif the thread is attempting to acquire the lock as a writer, and
21861b0ecf4SMark Johnston.Dv 1
21961b0ecf4SMark Johnstonif the thread is attempting to acquire the lock as a reader.
22061b0ecf4SMark JohnstonThe fourth argument is
22161b0ecf4SMark Johnston.Dv 0
222*5b699f16SMark Johnstonif the thread is waiting for a reader to release the lock, and
22361b0ecf4SMark Johnston.Dv 1
224*5b699f16SMark Johnstonif the thread is waiting for a writer to release the lock.
22561b0ecf4SMark JohnstonThe fifth argument is the number of readers that held the lock when
22661b0ecf4SMark Johnstonthe thread first attempted to acquire the lock.
22761b0ecf4SMark JohnstonThis argument will be
22861b0ecf4SMark Johnston.Dv 0
22961b0ecf4SMark Johnstonif the fourth argument is
230*5b699f16SMark Johnston.Dv 1 .
231566569c4SGeorge V. Neville-Neil.Pp
232566569c4SGeorge V. Neville-NeilThe
233*5b699f16SMark Johnston.Fn lockstat:::lockmgr-upgrade ,
234*5b699f16SMark Johnston.Fn lockstat:::rw-upgrade ,
235*5b699f16SMark Johnstonand
236566569c4SGeorge V. Neville-Neil.Fn lockstat:::sx-upgrade
237*5b699f16SMark Johnstonprobes fire when a thread successfully upgrades a held
238*5b699f16SMark Johnston.Xr lockmgr 9 ,
239*5b699f16SMark Johnston.Xr rwlock 9 ,
240*5b699f16SMark Johnstonor
24161b0ecf4SMark Johnston.Xr sx 9
242*5b699f16SMark Johnstonshared/reader lock to an exclusive/writer lock.
243566569c4SGeorge V. Neville-NeilThe only argument is a pointer to the structure which describes
24461b0ecf4SMark Johnstonthe lock being acquired.
245566569c4SGeorge V. Neville-NeilThe
246*5b699f16SMark Johnston.Fn lockstat:::lockmgr-downgrade ,
247*5b699f16SMark Johnston.Fn lockstat:::rw-downgrade ,
248*5b699f16SMark Johnstonand
249566569c4SGeorge V. Neville-Neil.Fn lockstat:::sx-downgrade
250*5b699f16SMark Johnstonprobes fire when a thread downgrades a held
251*5b699f16SMark Johnston.Xr lockmgr 9 ,
252*5b699f16SMark Johnston.Xr rwlock 9 ,
253*5b699f16SMark Johnstonor
25461b0ecf4SMark Johnston.Xr sx 9
255*5b699f16SMark Johnstonexclusive/writer lock to a shared/reader lock.
256566569c4SGeorge V. Neville-Neil.Pp
257566569c4SGeorge V. Neville-NeilThe
258566569c4SGeorge V. Neville-Neil.Fn lockstat:::thread-spin
25961b0ecf4SMark Johnstonprobe fires when a thread spins on a thread lock, which is a specialized
26061b0ecf4SMark Johnston.Dv MTX_SPIN
26161b0ecf4SMark Johnston.Xr mutex 9 .
262566569c4SGeorge V. Neville-NeilThe first argument is a pointer to the structure that describes
263566569c4SGeorge V. Neville-Neilthe lock and the second argument is the length of time,
26461b0ecf4SMark Johnstonin nanoseconds, that the thread was spinning.
265566569c4SGeorge V. Neville-Neil.Sh SEE ALSO
266566569c4SGeorge V. Neville-Neil.Xr dtrace 1 ,
267566569c4SGeorge V. Neville-Neil.Xr lockstat 1 ,
268566569c4SGeorge V. Neville-Neil.Xr locking 9 ,
26961b0ecf4SMark Johnston.Xr mutex 9 ,
27061b0ecf4SMark Johnston.Xr rwlock 9 ,
27161b0ecf4SMark Johnston.Xr SDT 9 ,
27261b0ecf4SMark Johnston.Xr sx 9
273566569c4SGeorge V. Neville-Neil.Sh HISTORY
274566569c4SGeorge V. Neville-NeilThe
275d3e9ec30SWarren Block.Nm
27661b0ecf4SMark Johnstonprovider first appeared in Solaris.
27761b0ecf4SMark JohnstonThe
27861b0ecf4SMark Johnston.Fx
27961b0ecf4SMark Johnstonimplementation of the
280d3e9ec30SWarren Block.Nm
281566569c4SGeorge V. Neville-Neilprovider first appeared in
282566569c4SGeorge V. Neville-Neil.Fx 9 .
283566569c4SGeorge V. Neville-Neil.Sh AUTHORS
284566569c4SGeorge V. Neville-NeilThis manual page was written by
285*5b699f16SMark Johnston.An George V. Neville-Neil Aq Mt gnn@FreeBSD.org
286*5b699f16SMark Johnstonand
287*5b699f16SMark Johnston.An -nosplit
288*5b699f16SMark Johnston.An Mark Johnston Aq Mt markj@FreeBSD.org .
28961b0ecf4SMark Johnston.Sh BUGS
29061b0ecf4SMark JohnstonProbes for
29161b0ecf4SMark Johnston.Xr rmlock 9
29261b0ecf4SMark Johnstonlocks have not yet been added.
293