summaryrefslogtreecommitdiffstats
path: root/share/man/man9/vm_page_busy.9
blob: bc4b796d1fce47d3b31fe4c23c474d750bffbff4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
.\"
.\" Copyright (c) 2013 EMC Corp.
.\" 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$
.Dd August 07, 2013
.Dt VM_PAGE_BUSY 9
.Os
.Sh NAME
.Nm vm_page_busied ,
.Nm vm_page_busy_downgrade ,
.Nm vm_page_busy_sleep ,
.Nm vm_page_sbusied ,
.Nm vm_page_sbusy ,
.Nm vm_page_sleep_if_busy ,
.Nm vm_page_sunbusy ,
.Nm vm_page_trysbusy ,
.Nm vm_page_tryxbusy ,
.Nm vm_page_xbusied ,
.Nm vm_page_xbusy ,
.Nm vm_page_xunbusy ,
.Nm vm_page_assert_sbusied ,
.Nm vm_page_assert_unbusied ,
.Nm vm_page_assert_xbusied
.Nd protect page identity changes and page content references
.Sh SYNOPSIS
.In sys/param.h
.In vm/vm.h
.In vm/vm_page.h
.Ft int
.Fn vm_page_busied "vm_page_t m"
.Ft void
.Fn vm_page_busy_downgrade "vm_page_t m"
.Ft void
.Fn vm_page_busy_sleep "vm_page_t m" "const char *msg"
.Ft int
.Fn vm_page_sbusied "vm_page_t m"
.Ft void
.Fn vm_page_sbusy "vm_page_t m"
.Ft int
.Fn vm_page_sleep_if_busy "vm_page_t m" "const char *msg"
.Ft void
.Fn vm_page_sunbusy "vm_page_t m"
.Ft int
.Fn vm_page_trysbusy "vm_page_t m"
.Ft int
.Fn vm_page_tryxbusy "vm_page_t m"
.Ft int
.Fn vm_page_xbusied "vm_page_t m"
.Ft void
.Fn vm_page_xbusy "vm_page_t m"
.Ft void
.Fn vm_page_xunbusy "vm_page_t m"
.Pp
.Cd "options INVARIANTS"
.Cd "options INVARIANT_SUPPORT"
.Ft void
.Fn vm_page_assert_sbusied "vm_page_t m"
.Ft void
.Fn vm_page_assert_unbusied "vm_page_t m"
.Ft void
.Fn vm_page_assert_xbusied "vm_page_t m"
.Sh DESCRIPTION
Page identity is usually protected by higher level locks like vm_object
locks and vm page locks.
However, sometimes it is not possible to hold such locks for the time
necessary to complete the identity change.
In such case the page can be exclusively busied by a thread which needs
to own the identity for a certain amount of time.
.Pp
In other situations, threads do not need to change the identity of the
page but they want to prevent other threads from changing the identity
themselves.
For example, when a thread wants to access or update page contents
without a lock held the page is shared busied.
.Pp
Before busing a page the vm_object lock must be held.
The same rule applies when a page is unbusied.
This makes the vm_object lock a real busy interlock.
.Pp
The
.Fn vm_page_busied
function returns non-zero if the current thread busied
.Fa m
in either exclusive or shared mode.
Returns zero otherwise.
.Pp
The
.Fn vm_page_busy_downgrade
function must be used to downgrade
.Fa m
from an exclusive busy state to a shared busy state.
.Pp
The
.Fn vm_page_busy_sleep
function puts the invoking thread to sleep using the appropriate
waitchannels for the busy mechanism.
The parameter
.Fa msg
is a string describing the sleep condition for userland tools.
.Pp
The
.Fn vm_page_busied
function returns non-zero if the current thread busied
.Fa m
in shared mode.
Returns zero otherwise.
.Pp
The
.Fn vm_page_sbusy
function shared busies
.Fa m .
.Pp
The
.Fn vm_page_sleep_if_busy
function puts the invoking thread to sleep, using the appropriate
waitchannels for the busy mechanism, if
.Fa m .
is busied in either exclusive or shared mode.
If the invoking thread slept a non-zero value is returned, otherwise
0 is returned.
The parameter
.Fa msg
is a string describing the sleep condition for userland tools.
.Pp
The
.Fn vm_page_sunbusy
function shared unbusies
.Fa m .
.Pp
The
.Fn vm_page_trysbusy
attempts to shared busy
.Fa m .
If the operation cannot immediately succeed
.Fn vm_page_trysbusy
returns 0, otherwise a non-zero value is returned.
.Pp
The
.Fn vm_page_tryxbusy
attempts to exclusive busy
.Fa m .
If the operation cannot immediately succeed
.Fn vm_page_tryxbusy
returns 0, otherwise a non-zero value is returned.
.Pp
The
.Fn vm_page_xbusied
function returns non-zero if the current thread busied
.Fa m
in exclusive mode.
Returns zero otherwise.
.Pp
The
.Fn vm_page_xbusy
function exclusive busies
.Fa m .
.Pp
The
.Fn vm_page_xunbusy
function exclusive unbusies
.Fa m .
Assertions on the busy state allow kernels compiled with
.Cd "options INVARIANTS"
and
.Cd "options INVARIANT_SUPPORT"
to panic if they are not respected.
.Pp
The
.Fn vm_page_assert_sbusied
function panics if
.Fa m
is not shared busied.
.Pp
The
.Fn vm_page_assert_unbusied
function panics if
.Fa m
is not unbusied.
.Pp
The
.Fn vm_page_assert_xbusied
function panics if
.Fa m
is not exclusive busied.
.Sh SEE ALSO
.Xr VOP_GETPAGES 9 ,
.Xr vm_page_aflag 9 ,
.Xr vm_page_alloc 9 ,
.Xr vm_page_deactivate 9 ,
.Xr vm_page_free 9 ,
.Xr vm_page_grab 9 ,
.Xr vm_page_insert 9 ,
.Xr vm_page_lookup 9 ,
.Xr vm_page_rename 9
OpenPOWER on IntegriCloud