3 .\" The DragonFly Project. All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
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
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.
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
36 .Nm lwkt_serialize_init ,
37 .Nm lwkt_serialize_enter ,
38 .Nm lwkt_serialize_adaptive_enter ,
39 .Nm lwkt_serialize_try ,
40 .Nm lwkt_serialize_exit ,
41 .Nm lwkt_serialize_handler_enable ,
42 .Nm lwkt_serialize_handler_disable ,
43 .Nm lwkt_serialize_handler_call ,
44 .Nm lwkt_serialize_handler_try ,
45 .Nm LWKT_SERIALIZE_INITIALIZER ,
46 .Nm ASSERT_SERIALIZED ,
47 .Nm ASSERT_NOT_SERIALIZED
48 .Nd generic low level serializer
52 .Fn lwkt_serialize_init "lwkt_serialize_t s"
54 .Fn lwkt_serialize_enter "lwkt_serialize_t s"
56 .Fn lwkt_serialize_adaptive_enter "lwkt_serialize_t s"
58 .Fn lwkt_serialize_try "lwkt_serialize_t s"
60 .Fn lwkt_serialize_exit "lwkt_serialize_t s"
62 .Fn lwkt_serialize_handler_enable "lwkt_serialize_t s"
64 .Fn lwkt_serialize_handler_disable "lwkt_serialize_t s"
66 .Fo lwkt_serialize_handler_call
67 .Fa "lwkt_serialize_t s"
68 .Fa "void (*func)(void *, void *)"
73 .Fo lwkt_serialize_handler_try
74 .Fa "lwkt_serialize_t s"
75 .Fa "void (*func)(void *, void *)"
80 .Nm LWKT_SERIALIZE_INITIALIZER ;
81 .Fn ASSERT_SERIALIZED "s"
82 .Fn ASSERT_NOT_SERIALIZED "s"
86 API provides a fast locked-bus-cycle-based serialization facility
87 that will serialize across blocking conditions.
88 It is very similar to a lock but much faster for the common case.
90 This API was initially designed to be a replacement for SPL calls,
91 but may be used whenever a low level exclusive lock (serialization)
92 and/or interrupt/device interaction is required.
93 If it is used by interrupt,
94 callers should enter critical section to prevent the current thread
95 holding the serializer being preempted by interrupt thread
96 which may try to hold the same serializer.
97 Unlike tokens this serialization is not safe from deadlocks
99 and care must be taken when using it.
102 will not release a serializer that is being held.
104 There are two primary facilities \(em the serializer facility itself and
105 an integrated non-stackable interrupt handler disablement facility
108 .Fn lwkt_serialize_init ,
109 .Fn lwkt_serialize_enter
111 .Fn lwkt_serialize_exit
112 respectively initialize, hold and release the serializer
114 .Fn lwkt_serialize_try
115 is a non-blocking version of
116 .Fn lwkt_serialize_enter .
118 .Fn lwkt_serialize_adaptive_enter
119 is a special version of
120 .Fn lwkt_serialize_enter
121 which will try to spin a bit before the current thread is put to sleep
126 .Fn lwkt_serialize_adaptive_enter
127 favors spinning over sleeping.
129 .Fn lwkt_serialize_handler_disable ,
130 .Fn lwkt_serialize_handler_enable
132 .Fn lwkt_serialize_handler_call
133 respectively disable, enable and call an interrupt handler
141 will be passed to the handler.
142 .Fn lwkt_serialize_handler_try
143 is a non-blocking version of
144 .Fn lwkt_serialize_handler_call .
147 .Nm LWKT_SERIALIZE_INITIALIZER
148 evaluates to an initializer for the serializer.
151 .Fn ASSERT_SERIALIZED
153 .Fn ASSERT_NOT_SERIALIZED
154 macros assert that the serializer
156 is being held/not held.
159 .Fn lwkt_serialize_handler_try
160 function return 0 on success and 1 on failure.
162 .Fn lwkt_serialize_try
163 function return 1 on success and 0 on failure.
165 The serializer itself is implemented in
166 .Pa /sys/kern/lwkt_serialize.c .
168 .Pa /sys/sys/serialize.h
169 describes the public interface and the structure of a serializer.
178 API first appeared in
186 This manual page was written by