Markup fixes in several manual pages.
[dragonfly.git] / share / man / man9 / serializer.9
1 .\"
2 .\" Copyright (c) 2007
3 .\"     The DragonFly Project.  All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\"
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in
13 .\"    the documentation and/or other materials provided with the
14 .\"    distribution.
15 .\" 3. Neither the name of The DragonFly Project nor the names of its
16 .\"    contributors may be used to endorse or promote products derived
17 .\"    from this software without specific, prior written permission.
18 .\"
19 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
23 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\" $DragonFly: src/share/man/man9/serializer.9,v 1.5 2008/05/15 09:21:40 swildner Exp $
33 .\"
34 .Dd May 15, 2008
35 .Os
36 .Dt SERIALIZER 9
37 .Sh NAME
38 .Nm lwkt_serialize_init ,
39 .Nm lwkt_serialize_enter ,
40 .Nm lwkt_serialize_adaptive_enter ,
41 .Nm lwkt_serialize_try ,
42 .Nm lwkt_serialize_exit ,
43 .Nm lwkt_serialize_handler_enable ,
44 .Nm lwkt_serialize_handler_disable ,
45 .Nm lwkt_serialize_handler_call ,
46 .Nm lwkt_serialize_handler_try ,
47 .Nm IS_SERIALIZED
48 .Nm ASSERT_SERIALIZED
49 .Nm ASSERT_NOT_SERIALIZED
50 .Nd generic low level serializer
51 .Sh SYNOPSIS
52 .In sys/serialize.h
53 .Ft void
54 .Fn lwkt_serialize_init "lwkt_serialize_t s"
55 .Ft void
56 .Fn lwkt_serialize_enter "lwkt_serialize_t s"
57 .Ft void
58 .Fn lwkt_serialize_adaptive_enter "lwkt_serialize_t s"
59 .Ft int
60 .Fn lwkt_serialize_try "lwkt_serialize_t s"
61 .Ft void
62 .Fn lwkt_serialize_exit "lwkt_serialize_t s"
63 .Ft void
64 .Fn lwkt_serialize_handler_enable "lwkt_serialize_t s"
65 .Ft void
66 .Fn lwkt_serialize_handler_disable "lwkt_serialize_t s"
67 .Ft void
68 .Fo lwkt_serialize_handler_call
69 .Fa "lwkt_serialize_t s"
70 .Fa "void (*func)(void *, void *)"
71 .Fa "void *arg"
72 .Fa "void *frame"
73 .Fc
74 .Ft int
75 .Fo lwkt_serialize_handler_try
76 .Fa "lwkt_serialize_t s"
77 .Fa "void (*func)(void *, void *)"
78 .Fa "void *arg"
79 .Fa "void *frame"
80 .Fc
81 .Fn IS_SERIALIZED "s"
82 .Fn ASSERT_SERIALIZED "s"
83 .Fn ASSERT_NOT_SERIALIZED "s"
84 .Sh DESCRIPTION
85 The
86 .Nm serializer
87 API provides a fast locked-bus-cycle-based serialization facility
88 that will serialize across blocking conditions.
89 It is very similar to a lock but much faster for the common case.
90 .Pp
91 This API was initially designed to be a replacement for SPL calls, but
92 may be used whenever a low level exclusive lock (serialization) and/or
93 interrupt/device interaction is required.
94 Unlike tokens this serialization is not safe from deadlocks nor is it
95 recursive, and care must be taken when using it.
96 Note that
97 .Xr tsleep 9
98 will not release a serializer that is being held.
99 .Pp
100 There are two primary facilities \(em the serializer facility itself and
101 an integrated non-stackable interrupt handler disablement facility
102 used by drivers.
103 .Pp
104 .Fn lwkt_serialize_init ,
105 .Fn lwkt_serialize_enter
106 and
107 .Fn lwkt_serialize_exit
108 respectively initialize, hold and release the serializer
109 .Fa s .
110 .Fn lwkt_serialize_try
111 is a non-blocking version of
112 .Fn lwkt_serialize_enter .
113 .Pp
114 .Fn lwkt_serialize_adaptive_enter
115 is a special version of
116 .Fn lwkt_serialize_enter
117 which will try to spin a bit before the current thread is put to sleep
118 if the serializer
119 .Fa s
120 is contended.
121 By default,
122 .Fn lwkt_serialize_adaptive_enter
123 favors spinning over sleeping.
124 This behavior can be changed by tuning the
125 .Va debug.serialize_bolimit
126 and
127 .Va debug.serialize_boround
128 .Xr sysctl 8
129 variables.
130 Note that
131 .Fn lwkt_serialize_adaptive_enter
132 is only available in SMP kernels.
133 .Pp
134 .Fn lwkt_serialize_handler_disable ,
135 .Fn lwkt_serialize_handler_enable
136 and
137 .Fn lwkt_serialize_handler_call
138 respectively disable, enable and call an interrupt handler
139 .Fa func
140 for the serializer
141 .Fa s .
142 The arguments
143 .Fa arg
144 and
145 .Fa frame
146 will be passed to the handler.
147 .Fn lwkt_serialize_handler_try
148 is a non-blocking version of
149 .Fn lwkt_serialize_handler_call .
150 .Pp
151 The
152 .Fn IS_SERIALIZED
153 macro tests if the serializer
154 .Fa s
155 is being held.
156 Similarly, the
157 .Fn ASSERT_SERIALIZED
158 and
159 .Fn ASSERT_NOT_SERIALIZED
160 macros assert that the serializer
161 .Fa s
162 is being held/not held.
163 .Sh RETURN VALUES
164 The
165 .Fn lwkt_serialize_try
166 and
167 .Fn lwkt_serialize_handler_try
168 functions return 0 on success and 1 on failure.
169 .Sh FILES
170 .Pa sys/kern/lwkt_serialize.c
171 .Sh SEE ALSO
172 .Xr crit_enter 9 ,
173 .Xr serialize_sleep 9 ,
174 .Xr spinlock 9
175 .Sh HISTORY
176 The
177 .Nm serializer
178 API first appeared in
179 .Dx 1.3 .
180 .Sh AUTHORS
181 .An -nosplit
182 The
183 .Nm serializer
184 API was written by
185 .An Matt Dillon .
186 This manual page was written by
187 .An Hasso Tepper .