@@ -52,19 +52,21 @@ extern int bit_wait_timeout(struct wait_bit_key *key, int mode);
5252
5353/**
5454 * wait_on_bit - wait for a bit to be cleared
55- * @word: the word being waited on, a kernel virtual address
56- * @bit: the bit of the word being waited on
55+ * @word: the address containing the bit being waited on
56+ * @bit: the bit at that address being waited on
5757 * @mode: the task state to sleep in
5858 *
59- * There is a standard hashed waitqueue table for generic use. This
60- * is the part of the hashtable's accessor API that waits on a bit.
61- * For instance, if one were to have waiters on a bitflag, one would
62- * call wait_on_bit() in threads waiting for the bit to clear.
63- * One uses wait_on_bit() where one is waiting for the bit to clear,
64- * but has no intention of setting it.
65- * Returned value will be zero if the bit was cleared, or non-zero
66- * if the process received a signal and the mode permitted wakeup
67- * on that signal.
59+ * Wait for the given bit in an unsigned long or bitmap (see DECLARE_BITMAP())
60+ * to be cleared. The clearing of the bit must be signalled with
61+ * wake_up_bit(), often as clear_and_wake_up_bit().
62+ *
63+ * The process will wait on a waitqueue selected by hash from a shared
64+ * pool. It will only be woken on a wake_up for the target bit, even
65+ * if other processes on the same queue are waiting for other bits.
66+ *
67+ * Returned value will be zero if the bit was cleared in which case the
68+ * call has ACQUIRE semantics, or %-EINTR if the process received a
69+ * signal and the mode permitted wake up on that signal.
6870 */
6971static inline int
7072wait_on_bit (unsigned long * word , int bit , unsigned mode )
@@ -79,17 +81,20 @@ wait_on_bit(unsigned long *word, int bit, unsigned mode)
7981
8082/**
8183 * wait_on_bit_io - wait for a bit to be cleared
82- * @word: the word being waited on, a kernel virtual address
83- * @bit: the bit of the word being waited on
84+ * @word: the address containing the bit being waited on
85+ * @bit: the bit at that address being waited on
8486 * @mode: the task state to sleep in
8587 *
86- * Use the standard hashed waitqueue table to wait for a bit
87- * to be cleared. This is similar to wait_on_bit(), but calls
88- * io_schedule() instead of schedule() for the actual waiting.
88+ * Wait for the given bit in an unsigned long or bitmap (see DECLARE_BITMAP())
89+ * to be cleared. The clearing of the bit must be signalled with
90+ * wake_up_bit(), often as clear_and_wake_up_bit().
91+ *
92+ * This is similar to wait_on_bit(), but calls io_schedule() instead of
93+ * schedule() for the actual waiting.
8994 *
90- * Returned value will be zero if the bit was cleared, or non-zero
91- * if the process received a signal and the mode permitted wakeup
92- * on that signal.
95+ * Returned value will be zero if the bit was cleared in which case the
96+ * call has ACQUIRE semantics, or %-EINTR if the process received a
97+ * signal and the mode permitted wake up on that signal.
9398 */
9499static inline int
95100wait_on_bit_io (unsigned long * word , int bit , unsigned mode )
@@ -103,19 +108,24 @@ wait_on_bit_io(unsigned long *word, int bit, unsigned mode)
103108}
104109
105110/**
106- * wait_on_bit_timeout - wait for a bit to be cleared or a timeout elapses
107- * @word: the word being waited on, a kernel virtual address
108- * @bit: the bit of the word being waited on
111+ * wait_on_bit_timeout - wait for a bit to be cleared or a timeout to elapse
112+ * @word: the address containing the bit being waited on
113+ * @bit: the bit at that address being waited on
109114 * @mode: the task state to sleep in
110115 * @timeout: timeout, in jiffies
111116 *
112- * Use the standard hashed waitqueue table to wait for a bit
113- * to be cleared. This is similar to wait_on_bit(), except also takes a
114- * timeout parameter.
117+ * Wait for the given bit in an unsigned long or bitmap (see
118+ * DECLARE_BITMAP()) to be cleared, or for a timeout to expire. The
119+ * clearing of the bit must be signalled with wake_up_bit(), often as
120+ * clear_and_wake_up_bit().
115121 *
116- * Returned value will be zero if the bit was cleared before the
117- * @timeout elapsed, or non-zero if the @timeout elapsed or process
118- * received a signal and the mode permitted wakeup on that signal.
122+ * This is similar to wait_on_bit(), except it also takes a timeout
123+ * parameter.
124+ *
125+ * Returned value will be zero if the bit was cleared in which case the
126+ * call has ACQUIRE semantics, or %-EINTR if the process received a
127+ * signal and the mode permitted wake up on that signal, or %-EAGAIN if the
128+ * timeout elapsed.
119129 */
120130static inline int
121131wait_on_bit_timeout (unsigned long * word , int bit , unsigned mode ,
@@ -131,19 +141,21 @@ wait_on_bit_timeout(unsigned long *word, int bit, unsigned mode,
131141
132142/**
133143 * wait_on_bit_action - wait for a bit to be cleared
134- * @word: the word being waited on, a kernel virtual address
135- * @bit: the bit of the word being waited on
144+ * @word: the address containing the bit waited on
145+ * @bit: the bit at that address being waited on
136146 * @action: the function used to sleep, which may take special actions
137147 * @mode: the task state to sleep in
138148 *
139- * Use the standard hashed waitqueue table to wait for a bit
140- * to be cleared, and allow the waiting action to be specified.
141- * This is like wait_on_bit() but allows fine control of how the waiting
142- * is done.
149+ * Wait for the given bit in an unsigned long or bitmap (see DECLARE_BITMAP())
150+ * to be cleared. The clearing of the bit must be signalled with
151+ * wake_up_bit(), often as clear_and_wake_up_bit().
152+ *
153+ * This is similar to wait_on_bit(), but calls @action() instead of
154+ * schedule() for the actual waiting.
143155 *
144- * Returned value will be zero if the bit was cleared, or non-zero
145- * if the process received a signal and the mode permitted wakeup
146- * on that signal .
156+ * Returned value will be zero if the bit was cleared in which case the
157+ * call has ACQUIRE semantics, or the error code returned by @action if
158+ * that call returned non-zero .
147159 */
148160static inline int
149161wait_on_bit_action (unsigned long * word , int bit , wait_bit_action_f * action ,
@@ -156,23 +168,22 @@ wait_on_bit_action(unsigned long *word, int bit, wait_bit_action_f *action,
156168}
157169
158170/**
159- * wait_on_bit_lock - wait for a bit to be cleared, when wanting to set it
160- * @word: the word being waited on, a kernel virtual address
161- * @bit: the bit of the word being waited on
171+ * wait_on_bit_lock - wait for a bit to be cleared, then set it
172+ * @word: the address containing the bit being waited on
173+ * @bit: the bit of the word being waited on and set
162174 * @mode: the task state to sleep in
163175 *
164- * There is a standard hashed waitqueue table for generic use. This
165- * is the part of the hashtable's accessor API that waits on a bit
166- * when one intends to set it, for instance, trying to lock bitflags.
167- * For instance, if one were to have waiters trying to set bitflag
168- * and waiting for it to clear before setting it, one would call
169- * wait_on_bit() in threads waiting to be able to set the bit.
170- * One uses wait_on_bit_lock() where one is waiting for the bit to
171- * clear with the intention of setting it, and when done, clearing it.
176+ * Wait for the given bit in an unsigned long or bitmap (see
177+ * DECLARE_BITMAP()) to be cleared. The clearing of the bit must be
178+ * signalled with wake_up_bit(), often as clear_and_wake_up_bit(). As
179+ * soon as it is clear, atomically set it and return.
172180 *
173- * Returns zero if the bit was (eventually) found to be clear and was
174- * set. Returns non-zero if a signal was delivered to the process and
175- * the @mode allows that signal to wake the process.
181+ * This is similar to wait_on_bit(), but sets the bit before returning.
182+ *
183+ * Returned value will be zero if the bit was successfully set in which
184+ * case the call has the same memory sequencing semantics as
185+ * test_and_clear_bit(), or %-EINTR if the process received a signal and
186+ * the mode permitted wake up on that signal.
176187 */
177188static inline int
178189wait_on_bit_lock (unsigned long * word , int bit , unsigned mode )
@@ -184,15 +195,18 @@ wait_on_bit_lock(unsigned long *word, int bit, unsigned mode)
184195}
185196
186197/**
187- * wait_on_bit_lock_io - wait for a bit to be cleared, when wanting to set it
188- * @word: the word being waited on, a kernel virtual address
189- * @bit: the bit of the word being waited on
198+ * wait_on_bit_lock_io - wait for a bit to be cleared, then set it
199+ * @word: the address containing the bit being waited on
200+ * @bit: the bit of the word being waited on and set
190201 * @mode: the task state to sleep in
191202 *
192- * Use the standard hashed waitqueue table to wait for a bit
193- * to be cleared and then to atomically set it. This is similar
194- * to wait_on_bit(), but calls io_schedule() instead of schedule()
195- * for the actual waiting.
203+ * Wait for the given bit in an unsigned long or bitmap (see
204+ * DECLARE_BITMAP()) to be cleared. The clearing of the bit must be
205+ * signalled with wake_up_bit(), often as clear_and_wake_up_bit(). As
206+ * soon as it is clear, atomically set it and return.
207+ *
208+ * This is similar to wait_on_bit_lock(), but calls io_schedule() instead
209+ * of schedule().
196210 *
197211 * Returns zero if the bit was (eventually) found to be clear and was
198212 * set. Returns non-zero if a signal was delivered to the process and
@@ -208,21 +222,19 @@ wait_on_bit_lock_io(unsigned long *word, int bit, unsigned mode)
208222}
209223
210224/**
211- * wait_on_bit_lock_action - wait for a bit to be cleared, when wanting to set it
212- * @word: the word being waited on, a kernel virtual address
213- * @bit: the bit of the word being waited on
225+ * wait_on_bit_lock_action - wait for a bit to be cleared, then set it
226+ * @word: the address containing the bit being waited on
227+ * @bit: the bit of the word being waited on and set
214228 * @action: the function used to sleep, which may take special actions
215229 * @mode: the task state to sleep in
216230 *
217- * Use the standard hashed waitqueue table to wait for a bit
218- * to be cleared and then to set it, and allow the waiting action
219- * to be specified.
220- * This is like wait_on_bit() but allows fine control of how the waiting
221- * is done.
231+ * This is similar to wait_on_bit_lock(), but calls @action() instead of
232+ * schedule() for the actual waiting.
222233 *
223- * Returns zero if the bit was (eventually) found to be clear and was
224- * set. Returns non-zero if a signal was delivered to the process and
225- * the @mode allows that signal to wake the process.
234+ * Returned value will be zero if the bit was successfully set in which
235+ * case the call has the same memory sequencing semantics as
236+ * test_and_clear_bit(), or the error code returned by @action if that
237+ * call returned non-zero.
226238 */
227239static inline int
228240wait_on_bit_lock_action (unsigned long * word , int bit , wait_bit_action_f * action ,
@@ -319,12 +331,13 @@ do { \
319331
320332/**
321333 * clear_and_wake_up_bit - clear a bit and wake up anyone waiting on that bit
322- *
323334 * @bit: the bit of the word being waited on
324- * @word: the word being waited on, a kernel virtual address
335+ * @word: the address containing the bit being waited on
325336 *
326- * You can use this helper if bitflags are manipulated atomically rather than
327- * non-atomically under a lock.
337+ * The designated bit is cleared and any tasks waiting in wait_on_bit()
338+ * or similar will be woken. This call has RELEASE semantics so that
339+ * any changes to memory made before this call are guaranteed to be visible
340+ * after the corresponding wait_on_bit() completes.
328341 */
329342static inline void clear_and_wake_up_bit (int bit , unsigned long * word )
330343{
0 commit comments