]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/witness.4
Add LLVM openmp trunk r351319 (just before the release_80 branch point)
[FreeBSD/FreeBSD.git] / share / man / man4 / witness.4
1 .\" Copyright (c) 2001 John H. Baldwin <jhb@FreeBSD.org>
2 .\"
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions
5 .\" are met:
6 .\" 1. Redistributions of source code must retain the above copyright
7 .\"    notice, this list of conditions and the following disclaimer.
8 .\" 2. Redistributions in binary form must reproduce the above copyright
9 .\"    notice, this list of conditions and the following disclaimer in the
10 .\"    documentation and/or other materials provided with the distribution.
11 .\"
12 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22 .\" SUCH DAMAGE.
23 .\"
24 .\" $FreeBSD$
25 .\"
26 .Dd November 18, 2015
27 .Dt WITNESS 4
28 .Os
29 .Sh NAME
30 .Nm witness
31 .Nd lock validation facility
32 .Sh SYNOPSIS
33 .Cd options WITNESS
34 .Cd options WITNESS_COUNT
35 .Cd options WITNESS_KDB
36 .Cd options WITNESS_NO_VNODE
37 .Cd options WITNESS_SKIPSPIN
38 .Sh DESCRIPTION
39 The
40 .Nm
41 module keeps track of the locks acquired and released by each thread.
42 It also keeps track of the order in which locks are acquired with respect
43 to each other.
44 Each time a lock is acquired,
45 .Nm
46 uses these two lists to verify that a lock is not being acquired in the
47 wrong order.
48 If a lock order violation is detected, then a message is output to the
49 kernel console or log detailing the locks involved and the locations in
50 question.
51 Witness can also be configured to drop into the kernel debugger when an order
52 violation occurs.
53 .Pp
54 The
55 .Nm
56 code also checks various other conditions such as verifying that one
57 does not recurse on a non-recursive lock,
58 or attempt an upgrade on a shared lock held by another thread.
59 If any of these checks fail, then the kernel will panic.
60 .Pp
61 The
62 .Dv WITNESS_COUNT
63 kernel option controls the maximum number of
64 .Nm
65 entries that are tracked in the kernel.
66 The maximum number of entries can be queried via the
67 .Va debug.witness.count
68 sysctl.
69 It can also be set from the
70 .Xr loader 8
71 via the
72 .Va debug.witness.count
73 environment variable.
74 .Pp
75 The
76 .Dv WITNESS_NO_VNODE
77 kernel option tells
78 .Nm
79 to ignore locking issues between
80 .Xr vnode 9
81 objects.
82 .Pp
83 The flag that controls whether or not the kernel debugger is entered when a
84 lock order violation is detected can be set in a variety of ways.
85 By default, the flag is off, but if the
86 .Dv WITNESS_KDB
87 kernel option is
88 specified, then the flag will default to on.
89 It can also be set from the
90 .Xr loader 8
91 via the
92 .Va debug.witness.kdb
93 environment variable or after the kernel has booted via the
94 .Va debug.witness.kdb
95 sysctl.
96 If the flag is set to zero, then the debugger will not be entered.
97 If the flag is non-zero, then the debugger will be entered.
98 .Pp
99 The
100 .Nm
101 code can also be configured to skip all checks on spin mutexes.
102 By default, this flag defaults to off, but it can be turned on by
103 specifying the
104 .Dv WITNESS_SKIPSPIN
105 kernel option.
106 The flag can also be set via the
107 .Xr loader 8
108 environment variable
109 .Va debug.witness.skipspin .
110 If the variable is set to a non-zero value, then spin mutexes are skipped.
111 Once the kernel has booted, the status of this flag can be examined but not
112 set via the read-only sysctl
113 .Va debug.witness.skipspin .
114 .Pp
115 The sysctl
116 .Va debug.witness.watch
117 specifies the level of witness involvement in the system.
118 A value of 1 specifies that witness is enabled.
119 A value of 0 specifies that witness is disabled, but that can be enabled
120 again.
121 This will maintain a small amount of overhead in the system.
122 A value of -1 specifies that witness is disabled permanently and
123 cannot be enabled again.
124 The sysctl
125 .Va debug.witness.watch
126 can be set via
127 .Xr loader 8 .
128 .Pp
129 The sysctl
130 .Va debug.witness.output_channel
131 specifies the output channel used to display warnings emitted by
132 .Nm .
133 The possible values are
134 .Ql console ,
135 indicating that warnings are to be printed to the system console,
136 .Ql log ,
137 indicating that warnings are to be logged via
138 .Xr log 9 ,
139 and
140 .Ql none .
141 This sysctl can be set via
142 .Xr loader 8 .
143 .Pp
144 The
145 .Nm
146 code also provides three extra
147 .Xr ddb 4
148 commands if both
149 .Nm
150 and
151 .Xr ddb 4
152 are compiled into the kernel:
153 .Bl -ohang
154 .It Ic show locks Op thread
155 Outputs the list of locks held by a thread to the kernel console
156 along with the filename and line number at which each lock was last acquired
157 by the thread.
158 The optional
159 .Ar thread
160 argument may be either a TID,
161 PID,
162 or pointer to a thread structure.
163 If
164 .Ar thread
165 is not specified,
166 then the locks held by the current thread are displayed.
167 .It Ic show all locks
168 Outputs the list of locks held by all threads in the system to the
169 kernel console.
170 .It Ic show witness
171 Dump the current order list to the kernel console.
172 The code first displays the lock order tree for all of the sleep locks.
173 Then it displays the lock order tree for all of the spin locks.
174 Finally, it displays a list of locks that have not yet been acquired.
175 .El
176 .Sh SEE ALSO
177 .Xr ddb 4 ,
178 .Xr loader 8 ,
179 .Xr sysctl 8 ,
180 .Xr mutex 9
181 .Sh HISTORY
182 The
183 .Nm
184 code first appeared in
185 .Bsx 5.0
186 and was imported from there into
187 .Fx 5.0 .