2017-06-10 20:41:53 +00:00
|
|
|
.\" Copyright (c) 2017 George V. Neville-Neil <gnn@FreeBSD.org>
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2018-03-02 18:57:00 +00:00
|
|
|
.Dd March 2, 2018
|
2017-06-10 20:41:53 +00:00
|
|
|
.Dt DTRACE_LOCKSTAT 4
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm dtrace_lockstat
|
|
|
|
.Nd a DTrace provider for tracing CPU scheduling events
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Fn lockstat:::adaptive-acquire "struct mtx *"
|
|
|
|
.Fn lockstat:::adaptive-release "struct mtx *"
|
|
|
|
.Fn lockstat:::adaptive-spin "struct mtx *" "uint64_t"
|
|
|
|
.Fn lockstat:::adaptive-block "struct mtx *" "uint64_t"
|
|
|
|
.Fn lockstat:::spin-acquire "struct mtx *"
|
|
|
|
.Fn lockstat:::spin-release "struct mtx *"
|
|
|
|
.Fn lockstat:::spin-spin "struct mtx *" "uint64_t"
|
|
|
|
.Fn lockstat:::rw-acquire "struct rwlock *" "int"
|
|
|
|
.Fn lockstat:::rw-release "struct rwlock *" "int"
|
|
|
|
.Fn lockstat:::rw-block "struct rwlock *" "uint64_t" "int" "int" "int"
|
|
|
|
.Fn lockstat:::rw-spin "struct rwlock *" "uint64_t"
|
|
|
|
.Fn lockstat:::rw-upgrade "struct rwlock *"
|
|
|
|
.Fn lockstat:::rw-downgrade "struct rwlock *"
|
|
|
|
.Fn lockstat:::sx-acquire "struct sx *" "int"
|
|
|
|
.Fn lockstat:::sx-release "struct sx *" "int"
|
|
|
|
.Fn lockstat:::sx-block "struct sx *" "uint64_t" "int" "int" "int"
|
|
|
|
.Fn lockstat:::sx-spin "struct sx *" "uint64_t"
|
|
|
|
.Fn lockstat:::sx-upgrade "struct sx *"
|
|
|
|
.Fn lockstat:::sx-downgrade "struct sx *"
|
|
|
|
.Fn lockstat:::thread-spin "struct mtx *" "uint64"
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The DTrace
|
|
|
|
.Nm lockstat
|
2017-07-03 23:54:39 +00:00
|
|
|
provider allows the tracing of events related to locking on
|
|
|
|
.Fx .
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
2018-03-02 18:57:00 +00:00
|
|
|
.Nm
|
|
|
|
provider contains DTrace probes for inspecting kernel lock
|
2017-06-10 20:41:53 +00:00
|
|
|
state transitions.
|
2017-07-03 23:54:39 +00:00
|
|
|
Probes exist for the
|
|
|
|
.Xr mutex 9 ,
|
2018-03-02 18:57:00 +00:00
|
|
|
.Xr rwlock 9 ,
|
2017-07-03 23:54:39 +00:00
|
|
|
and
|
|
|
|
.Xr sx 9
|
|
|
|
lock types.
|
|
|
|
The
|
|
|
|
.Xr lockstat 1
|
|
|
|
utility can be used to collect and display data collected from the
|
2018-03-02 18:57:00 +00:00
|
|
|
.Nm
|
2017-06-10 20:41:53 +00:00
|
|
|
provider.
|
2017-07-03 23:54:39 +00:00
|
|
|
Each type of lock has
|
2017-06-10 20:41:53 +00:00
|
|
|
.Fn acquire
|
|
|
|
and
|
|
|
|
.Fn release
|
2017-07-03 23:54:39 +00:00
|
|
|
probes which expose the lock structure being operated upon,
|
|
|
|
as well as probes which fire when a thread contends with other threads
|
|
|
|
for ownership of a lock.
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
2017-07-03 23:54:39 +00:00
|
|
|
.Fn lockstat:::adaptive-acquire
|
|
|
|
and
|
2017-06-10 20:41:53 +00:00
|
|
|
.Fn lockstat:::adaptive-release
|
2017-07-03 23:54:39 +00:00
|
|
|
probes fire when an
|
|
|
|
.Dv MTX_DEF
|
|
|
|
.Xr mutex 9
|
|
|
|
is acquired and released, respectively.
|
2017-06-10 20:41:53 +00:00
|
|
|
The only argument is a pointer to the lock structure which describes
|
2017-07-03 23:54:39 +00:00
|
|
|
the lock being acquired or released.
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn lockstat:::adaptive-spin
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread spins while waiting for a
|
|
|
|
.Dv MTX_DEF
|
|
|
|
.Xr mutex 9
|
|
|
|
to be released by another thread.
|
2017-06-10 20:41:53 +00:00
|
|
|
The first argument is a pointer to the lock structure that describes
|
|
|
|
the lock and the second argument is the amount of time,
|
2017-07-03 23:54:39 +00:00
|
|
|
in nanoseconds, that the mutex spent spinning.
|
2017-06-10 20:41:53 +00:00
|
|
|
The
|
|
|
|
.Fn lockstat:::adaptive-block
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread takes itself off the CPU while trying to acquire an
|
|
|
|
.Dv MTX_DEF
|
|
|
|
.Xr mutex 9
|
|
|
|
that is owned by another thread.
|
2017-06-10 20:41:53 +00:00
|
|
|
The first argument is a pointer to the lock structure that describes
|
|
|
|
the lock and the second argument is the length of time,
|
2017-07-03 23:54:39 +00:00
|
|
|
in nanoseconds, that the waiting thread was blocked.
|
2017-06-11 14:33:16 +00:00
|
|
|
The
|
2017-06-10 20:41:53 +00:00
|
|
|
.Fn lockstat:::adaptive-block
|
2017-07-03 23:54:39 +00:00
|
|
|
and
|
|
|
|
.Fn lockstat:::adaptive-spin
|
|
|
|
probes fire only after the lock has been successfully acquired,
|
|
|
|
and in particular, after the
|
|
|
|
.Fn lockstat:::adaptive-acquire
|
2017-06-10 20:41:53 +00:00
|
|
|
probe fires.
|
|
|
|
.Pp
|
|
|
|
The
|
2017-07-03 23:54:39 +00:00
|
|
|
.Fn lockstat:::spin-acquire
|
|
|
|
and
|
2017-06-10 20:41:53 +00:00
|
|
|
.Fn lockstat:::spin-release
|
2017-07-03 23:54:39 +00:00
|
|
|
probes fire when a
|
|
|
|
.Dv MTX_SPIN
|
|
|
|
.Xr mutex 9
|
2018-03-02 18:57:00 +00:00
|
|
|
is acquired or released, respectively.
|
2017-06-10 20:41:53 +00:00
|
|
|
The only argument is a pointer to the lock structure which describes
|
2017-07-03 23:54:39 +00:00
|
|
|
the lock being acquired or released.
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn lockstat:::spin-spin
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread spins while waiting for a
|
|
|
|
.Dv MTX_SPIN
|
|
|
|
.Xr mutex 9
|
|
|
|
to be released by another thread.
|
2017-06-10 20:41:53 +00:00
|
|
|
The first argument is a pointer to the lock structure that describes
|
|
|
|
the lock and the second argument is the length of the time
|
|
|
|
spent spinning, in nanoseconds.
|
2017-07-03 23:54:39 +00:00
|
|
|
The
|
|
|
|
.Fn lockstat:::spin-spin
|
|
|
|
probe fires only after the lock has been successfully acquired,
|
|
|
|
and in particular, after the
|
|
|
|
.Fn lockstat:::spin-acquire
|
2017-06-10 20:41:53 +00:00
|
|
|
probe fires.
|
|
|
|
.Pp
|
|
|
|
The
|
2017-07-03 23:54:39 +00:00
|
|
|
.Fn lockstat:::rw-acquire
|
|
|
|
and
|
2017-06-10 20:41:53 +00:00
|
|
|
.Fn lockstat:::rw-release
|
2017-07-03 23:54:39 +00:00
|
|
|
probes fire when a
|
|
|
|
.Xr rwlock 9
|
2018-03-02 18:57:00 +00:00
|
|
|
is acquired or released, respectively.
|
2017-07-03 23:54:39 +00:00
|
|
|
The first argument is a pointer to the structure which describes
|
|
|
|
the lock being acquired.
|
|
|
|
The second argument is
|
|
|
|
.Dv 0
|
|
|
|
if the lock is being acquired or released as a writer, and
|
|
|
|
.Dv 1
|
|
|
|
if it is being acquired or released as a reader.
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn lockstat:::rw-block
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread removes itself from the CPU while
|
|
|
|
waiting to acquire a
|
|
|
|
.Xr rwlock 9 .
|
2017-06-10 20:41:53 +00:00
|
|
|
The
|
|
|
|
.Fn lockstat:::rw-spin
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread spins while waiting to acquire a
|
|
|
|
.Xr rwlock 9 .
|
|
|
|
Both probes take the same set of arguments.
|
2017-06-10 20:41:53 +00:00
|
|
|
The first argument is a pointer to the lock structure that describes
|
2017-07-03 23:54:39 +00:00
|
|
|
the lock.
|
|
|
|
The second argument is the length of time, in nanoseconds,
|
|
|
|
that the waiting thread was off the CPU or spinning for the lock.
|
|
|
|
The third argument is
|
|
|
|
.Dv 0
|
|
|
|
if the thread is attempting to acquire the lock as a writer, and
|
|
|
|
.Dv 1
|
|
|
|
if the thread is attempting to acquire the lock as a reader.
|
|
|
|
The fourth argument is
|
|
|
|
.Dv 0
|
|
|
|
if the thread is waiting for a writer to release the lock, and
|
|
|
|
.Dv 1
|
|
|
|
if the thread is waiting for a reader to release the lock.
|
|
|
|
The fifth argument is the number of readers that held the lock when
|
|
|
|
the thread first attempted to acquire the lock.
|
|
|
|
This argument will be
|
|
|
|
.Dv 0
|
|
|
|
if the fourth argument is
|
|
|
|
.Dv 0 .
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn lockstat:::rw-upgrade
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread successfully upgrades a held
|
|
|
|
.Xr rwlock 9
|
2017-06-10 20:41:53 +00:00
|
|
|
read lock to a write lock.
|
2017-07-03 23:54:39 +00:00
|
|
|
The
|
2017-06-10 20:41:53 +00:00
|
|
|
.Fn lockstat:::rw-downgrade
|
2017-11-24 17:57:00 +00:00
|
|
|
probe fires when a thread downgrades a held
|
2017-07-03 23:54:39 +00:00
|
|
|
.Xr rwlock 9
|
|
|
|
write lock to a read lock.
|
2017-06-10 20:41:53 +00:00
|
|
|
The only argument is a pointer to the structure which describes
|
2017-07-03 23:54:39 +00:00
|
|
|
the lock being acquired.
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
2017-07-03 23:54:39 +00:00
|
|
|
.Fn lockstat:::sx-acquire
|
|
|
|
and
|
2017-06-10 20:41:53 +00:00
|
|
|
.Fn lockstat:::sx-release
|
2017-07-03 23:54:39 +00:00
|
|
|
probes fire when a
|
|
|
|
.Xr sx 9
|
2018-03-02 18:57:00 +00:00
|
|
|
is acquired or released, respectively.
|
2017-07-03 23:54:39 +00:00
|
|
|
The first argument is a pointer to the structure which describes
|
|
|
|
the lock being acquired.
|
|
|
|
The second argument is
|
|
|
|
.Dv 0
|
|
|
|
if the shared lock is being acquired or released, and
|
|
|
|
.Dv 1
|
|
|
|
if the exclusive lock is being acquired or released.
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn lockstat:::sx-block
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread takes itself off the CPU while
|
|
|
|
waiting to acquire a
|
|
|
|
.Xr sx 9 .
|
2017-06-10 20:41:53 +00:00
|
|
|
The
|
|
|
|
.Fn lockstat:::sx-spin
|
2017-11-24 17:57:00 +00:00
|
|
|
probe fires when a thread spins while waiting to acquire a
|
2017-07-03 23:54:39 +00:00
|
|
|
.Xr sx 9 .
|
|
|
|
Both probes take the same set of arguments.
|
|
|
|
The first argument is a pointer to the lock structure that describes
|
|
|
|
the lock.
|
|
|
|
The second argument is the length of time, in nanoseconds,
|
|
|
|
that the waiting thread was off the CPU or spinning for the lock.
|
|
|
|
The third argument is
|
|
|
|
.Dv 0
|
|
|
|
if the thread is attempting to acquire the lock as a writer, and
|
|
|
|
.Dv 1
|
|
|
|
if the thread is attempting to acquire the lock as a reader.
|
|
|
|
The fourth argument is
|
|
|
|
.Dv 0
|
|
|
|
if the thread is waiting for a writer to release the lock, and
|
|
|
|
.Dv 1
|
|
|
|
if the thread is waiting for a reader to release the lock.
|
|
|
|
The fifth argument is the number of readers that held the lock when
|
|
|
|
the thread first attempted to acquire the lock.
|
|
|
|
This argument will be
|
|
|
|
.Dv 0
|
|
|
|
if the fourth argument is
|
|
|
|
.Dv 0 .
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn lockstat:::sx-upgrade
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread successfully upgrades a held
|
|
|
|
.Xr sx 9
|
|
|
|
shared lock to an exclusive lock.
|
2017-06-10 20:41:53 +00:00
|
|
|
The only argument is a pointer to the structure which describes
|
2017-07-03 23:54:39 +00:00
|
|
|
the lock being acquired.
|
2017-06-10 20:41:53 +00:00
|
|
|
The
|
|
|
|
.Fn lockstat:::sx-downgrade
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread downgrades a held
|
|
|
|
.Xr sx 9
|
|
|
|
exclusive lock to a shared lock.
|
2017-06-10 20:41:53 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn lockstat:::thread-spin
|
2017-07-03 23:54:39 +00:00
|
|
|
probe fires when a thread spins on a thread lock, which is a specialized
|
|
|
|
.Dv MTX_SPIN
|
|
|
|
.Xr mutex 9 .
|
2017-06-10 20:41:53 +00:00
|
|
|
The first argument is a pointer to the structure that describes
|
|
|
|
the lock and the second argument is the length of time,
|
2017-07-03 23:54:39 +00:00
|
|
|
in nanoseconds, that the thread was spinning.
|
2017-06-10 20:41:53 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr dtrace 1 ,
|
|
|
|
.Xr lockstat 1 ,
|
|
|
|
.Xr locking 9 ,
|
2017-07-03 23:54:39 +00:00
|
|
|
.Xr mutex 9 ,
|
|
|
|
.Xr rwlock 9 ,
|
|
|
|
.Xr SDT 9 ,
|
|
|
|
.Xr sx 9
|
2017-06-10 20:41:53 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
2018-03-02 18:57:00 +00:00
|
|
|
.Nm
|
2017-07-03 23:54:39 +00:00
|
|
|
provider first appeared in Solaris.
|
|
|
|
The
|
|
|
|
.Fx
|
|
|
|
implementation of the
|
2018-03-02 18:57:00 +00:00
|
|
|
.Nm
|
2017-06-10 20:41:53 +00:00
|
|
|
provider first appeared in
|
2018-03-02 18:57:00 +00:00
|
|
|
.Fx 9 .
|
2017-06-10 20:41:53 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
This manual page was written by
|
|
|
|
.An George V. Neville-Neil Aq Mt gnn@FreeBSD.org .
|
2017-07-03 23:54:39 +00:00
|
|
|
.Sh BUGS
|
|
|
|
Probes for
|
|
|
|
.Xr lockmgr 9
|
|
|
|
and
|
|
|
|
.Xr rmlock 9
|
|
|
|
locks have not yet been added.
|