@@ -53,19 +53,21 @@ extern int bit_wait_io_timeout(struct wait_bit_key *key, int mode);
5353
5454/**
5555 * wait_on_bit - wait for a bit to be cleared
56- * @word: the word being waited on, a kernel virtual address
57- * @bit: the bit of the word being waited on
56+ * @word: the address containing the bit being waited on
57+ * @bit: the bit at that address being waited on
5858 * @mode: the task state to sleep in
5959 *
60- * There is a standard hashed waitqueue table for generic use. This
61- * is the part of the hashtable's accessor API that waits on a bit.
62- * For instance, if one were to have waiters on a bitflag, one would
63- * call wait_on_bit() in threads waiting for the bit to clear.
64- * One uses wait_on_bit() where one is waiting for the bit to clear,
65- * but has no intention of setting it.
66- * Returned value will be zero if the bit was cleared, or non-zero
67- * if the process received a signal and the mode permitted wakeup
68- * on that signal.
60+ * Wait for the given bit in an unsigned long or bitmap (see DECLARE_BITMAP())
61+ * to be cleared. The clearing of the bit must be signalled with
62+ * wake_up_bit(), often as clear_and_wake_up_bit().
63+ *
64+ * The process will wait on a waitqueue selected by hash from a shared
65+ * pool. It will only be woken on a wake_up for the target bit, even
66+ * if other processes on the same queue are waiting for other bits.
67+ *
68+ * Returned value will be zero if the bit was cleared in which case the
69+ * call has ACQUIRE semantics, or %-EINTR if the process received a
70+ * signal and the mode permitted wake up on that signal.
6971 */
7072static inline int
7173wait_on_bit (unsigned long * word , int bit , unsigned mode )
@@ -80,17 +82,20 @@ wait_on_bit(unsigned long *word, int bit, unsigned mode)
8082
8183/**
8284 * wait_on_bit_io - wait for a bit to be cleared
83- * @word: the word being waited on, a kernel virtual address
84- * @bit: the bit of the word being waited on
85+ * @word: the address containing the bit being waited on
86+ * @bit: the bit at that address being waited on
8587 * @mode: the task state to sleep in
8688 *
87- * Use the standard hashed waitqueue table to wait for a bit
88- * to be cleared. This is similar to wait_on_bit(), but calls
89- * io_schedule() instead of schedule() for the actual waiting.
89+ * Wait for the given bit in an unsigned long or bitmap (see DECLARE_BITMAP())
90+ * to be cleared. The clearing of the bit must be signalled with
91+ * wake_up_bit(), often as clear_and_wake_up_bit().
92+ *
93+ * This is similar to wait_on_bit(), but calls io_schedule() instead of
94+ * schedule() for the actual waiting.
9095 *
91- * Returned value will be zero if the bit was cleared, or non-zero
92- * if the process received a signal and the mode permitted wakeup
93- * on that signal.
96+ * Returned value will be zero if the bit was cleared in which case the
97+ * call has ACQUIRE semantics, or %-EINTR if the process received a
98+ * signal and the mode permitted wake up on that signal.
9499 */
95100static inline int
96101wait_on_bit_io (unsigned long * word , int bit , unsigned mode )
@@ -104,19 +109,24 @@ wait_on_bit_io(unsigned long *word, int bit, unsigned mode)
104109}
105110
106111/**
107- * wait_on_bit_timeout - wait for a bit to be cleared or a timeout elapses
108- * @word: the word being waited on, a kernel virtual address
109- * @bit: the bit of the word being waited on
112+ * wait_on_bit_timeout - wait for a bit to be cleared or a timeout to elapse
113+ * @word: the address containing the bit being waited on
114+ * @bit: the bit at that address being waited on
110115 * @mode: the task state to sleep in
111116 * @timeout: timeout, in jiffies
112117 *
113- * Use the standard hashed waitqueue table to wait for a bit
114- * to be cleared. This is similar to wait_on_bit(), except also takes a
115- * timeout parameter.
118+ * Wait for the given bit in an unsigned long or bitmap (see
119+ * DECLARE_BITMAP()) to be cleared, or for a timeout to expire. The
120+ * clearing of the bit must be signalled with wake_up_bit(), often as
121+ * clear_and_wake_up_bit().
116122 *
117- * Returned value will be zero if the bit was cleared before the
118- * @timeout elapsed, or non-zero if the @timeout elapsed or process
119- * received a signal and the mode permitted wakeup on that signal.
123+ * This is similar to wait_on_bit(), except it also takes a timeout
124+ * parameter.
125+ *
126+ * Returned value will be zero if the bit was cleared in which case the
127+ * call has ACQUIRE semantics, or %-EINTR if the process received a
128+ * signal and the mode permitted wake up on that signal, or %-EAGAIN if the
129+ * timeout elapsed.
120130 */
121131static inline int
122132wait_on_bit_timeout (unsigned long * word , int bit , unsigned mode ,
@@ -132,19 +142,21 @@ wait_on_bit_timeout(unsigned long *word, int bit, unsigned mode,
132142
133143/**
134144 * wait_on_bit_action - wait for a bit to be cleared
135- * @word: the word being waited on, a kernel virtual address
136- * @bit: the bit of the word being waited on
145+ * @word: the address containing the bit waited on
146+ * @bit: the bit at that address being waited on
137147 * @action: the function used to sleep, which may take special actions
138148 * @mode: the task state to sleep in
139149 *
140- * Use the standard hashed waitqueue table to wait for a bit
141- * to be cleared, and allow the waiting action to be specified.
142- * This is like wait_on_bit() but allows fine control of how the waiting
143- * is done.
150+ * Wait for the given bit in an unsigned long or bitmap (see DECLARE_BITMAP())
151+ * to be cleared. The clearing of the bit must be signalled with
152+ * wake_up_bit(), often as clear_and_wake_up_bit().
153+ *
154+ * This is similar to wait_on_bit(), but calls @action() instead of
155+ * schedule() for the actual waiting.
144156 *
145- * Returned value will be zero if the bit was cleared, or non-zero
146- * if the process received a signal and the mode permitted wakeup
147- * on that signal .
157+ * Returned value will be zero if the bit was cleared in which case the
158+ * call has ACQUIRE semantics, or the error code returned by @action if
159+ * that call returned non-zero .
148160 */
149161static inline int
150162wait_on_bit_action (unsigned long * word , int bit , wait_bit_action_f * action ,
@@ -157,23 +169,22 @@ wait_on_bit_action(unsigned long *word, int bit, wait_bit_action_f *action,
157169}
158170
159171/**
160- * wait_on_bit_lock - wait for a bit to be cleared, when wanting to set it
161- * @word: the word being waited on, a kernel virtual address
162- * @bit: the bit of the word being waited on
172+ * wait_on_bit_lock - wait for a bit to be cleared, then set it
173+ * @word: the address containing the bit being waited on
174+ * @bit: the bit of the word being waited on and set
163175 * @mode: the task state to sleep in
164176 *
165- * There is a standard hashed waitqueue table for generic use. This
166- * is the part of the hashtable's accessor API that waits on a bit
167- * when one intends to set it, for instance, trying to lock bitflags.
168- * For instance, if one were to have waiters trying to set bitflag
169- * and waiting for it to clear before setting it, one would call
170- * wait_on_bit() in threads waiting to be able to set the bit.
171- * One uses wait_on_bit_lock() where one is waiting for the bit to
172- * clear with the intention of setting it, and when done, clearing it.
177+ * Wait for the given bit in an unsigned long or bitmap (see
178+ * DECLARE_BITMAP()) to be cleared. The clearing of the bit must be
179+ * signalled with wake_up_bit(), often as clear_and_wake_up_bit(). As
180+ * soon as it is clear, atomically set it and return.
173181 *
174- * Returns zero if the bit was (eventually) found to be clear and was
175- * set. Returns non-zero if a signal was delivered to the process and
176- * the @mode allows that signal to wake the process.
182+ * This is similar to wait_on_bit(), but sets the bit before returning.
183+ *
184+ * Returned value will be zero if the bit was successfully set in which
185+ * case the call has the same memory sequencing semantics as
186+ * test_and_clear_bit(), or %-EINTR if the process received a signal and
187+ * the mode permitted wake up on that signal.
177188 */
178189static inline int
179190wait_on_bit_lock (unsigned long * word , int bit , unsigned mode )
@@ -185,15 +196,18 @@ wait_on_bit_lock(unsigned long *word, int bit, unsigned mode)
185196}
186197
187198/**
188- * wait_on_bit_lock_io - wait for a bit to be cleared, when wanting to set it
189- * @word: the word being waited on, a kernel virtual address
190- * @bit: the bit of the word being waited on
199+ * wait_on_bit_lock_io - wait for a bit to be cleared, then set it
200+ * @word: the address containing the bit being waited on
201+ * @bit: the bit of the word being waited on and set
191202 * @mode: the task state to sleep in
192203 *
193- * Use the standard hashed waitqueue table to wait for a bit
194- * to be cleared and then to atomically set it. This is similar
195- * to wait_on_bit(), but calls io_schedule() instead of schedule()
196- * for the actual waiting.
204+ * Wait for the given bit in an unsigned long or bitmap (see
205+ * DECLARE_BITMAP()) to be cleared. The clearing of the bit must be
206+ * signalled with wake_up_bit(), often as clear_and_wake_up_bit(). As
207+ * soon as it is clear, atomically set it and return.
208+ *
209+ * This is similar to wait_on_bit_lock(), but calls io_schedule() instead
210+ * of schedule().
197211 *
198212 * Returns zero if the bit was (eventually) found to be clear and was
199213 * set. Returns non-zero if a signal was delivered to the process and
@@ -209,21 +223,19 @@ wait_on_bit_lock_io(unsigned long *word, int bit, unsigned mode)
209223}
210224
211225/**
212- * wait_on_bit_lock_action - wait for a bit to be cleared, when wanting to set it
213- * @word: the word being waited on, a kernel virtual address
214- * @bit: the bit of the word being waited on
226+ * wait_on_bit_lock_action - wait for a bit to be cleared, then set it
227+ * @word: the address containing the bit being waited on
228+ * @bit: the bit of the word being waited on and set
215229 * @action: the function used to sleep, which may take special actions
216230 * @mode: the task state to sleep in
217231 *
218- * Use the standard hashed waitqueue table to wait for a bit
219- * to be cleared and then to set it, and allow the waiting action
220- * to be specified.
221- * This is like wait_on_bit() but allows fine control of how the waiting
222- * is done.
232+ * This is similar to wait_on_bit_lock(), but calls @action() instead of
233+ * schedule() for the actual waiting.
223234 *
224- * Returns zero if the bit was (eventually) found to be clear and was
225- * set. Returns non-zero if a signal was delivered to the process and
226- * the @mode allows that signal to wake the process.
235+ * Returned value will be zero if the bit was successfully set in which
236+ * case the call has the same memory sequencing semantics as
237+ * test_and_clear_bit(), or the error code returned by @action if that
238+ * call returned non-zero.
227239 */
228240static inline int
229241wait_on_bit_lock_action (unsigned long * word , int bit , wait_bit_action_f * action ,
@@ -320,12 +332,13 @@ do { \
320332
321333/**
322334 * clear_and_wake_up_bit - clear a bit and wake up anyone waiting on that bit
323- *
324335 * @bit: the bit of the word being waited on
325- * @word: the word being waited on, a kernel virtual address
336+ * @word: the address containing the bit being waited on
326337 *
327- * You can use this helper if bitflags are manipulated atomically rather than
328- * non-atomically under a lock.
338+ * The designated bit is cleared and any tasks waiting in wait_on_bit()
339+ * or similar will be woken. This call has RELEASE semantics so that
340+ * any changes to memory made before this call are guaranteed to be visible
341+ * after the corresponding wait_on_bit() completes.
329342 */
330343static inline void clear_and_wake_up_bit (int bit , unsigned long * word )
331344{
0 commit comments