diff options
Diffstat (limited to 'include/linux/swait.h')
-rw-r--r-- | include/linux/swait.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/include/linux/swait.h b/include/linux/swait.h index c1f9c62a8a50..4a4e180d0a35 100644 --- a/include/linux/swait.h +++ b/include/linux/swait.h | |||
@@ -169,4 +169,59 @@ do { \ | |||
169 | __ret; \ | 169 | __ret; \ |
170 | }) | 170 | }) |
171 | 171 | ||
172 | #define __swait_event_idle(wq, condition) \ | ||
173 | (void)___swait_event(wq, condition, TASK_IDLE, 0, schedule()) | ||
174 | |||
175 | /** | ||
176 | * swait_event_idle - wait without system load contribution | ||
177 | * @wq: the waitqueue to wait on | ||
178 | * @condition: a C expression for the event to wait for | ||
179 | * | ||
180 | * The process is put to sleep (TASK_IDLE) until the @condition evaluates to | ||
181 | * true. The @condition is checked each time the waitqueue @wq is woken up. | ||
182 | * | ||
183 | * This function is mostly used when a kthread or workqueue waits for some | ||
184 | * condition and doesn't want to contribute to system load. Signals are | ||
185 | * ignored. | ||
186 | */ | ||
187 | #define swait_event_idle(wq, condition) \ | ||
188 | do { \ | ||
189 | if (condition) \ | ||
190 | break; \ | ||
191 | __swait_event_idle(wq, condition); \ | ||
192 | } while (0) | ||
193 | |||
194 | #define __swait_event_idle_timeout(wq, condition, timeout) \ | ||
195 | ___swait_event(wq, ___wait_cond_timeout(condition), \ | ||
196 | TASK_IDLE, timeout, \ | ||
197 | __ret = schedule_timeout(__ret)) | ||
198 | |||
199 | /** | ||
200 | * swait_event_idle_timeout - wait up to timeout without load contribution | ||
201 | * @wq: the waitqueue to wait on | ||
202 | * @condition: a C expression for the event to wait for | ||
203 | * @timeout: timeout at which we'll give up in jiffies | ||
204 | * | ||
205 | * The process is put to sleep (TASK_IDLE) until the @condition evaluates to | ||
206 | * true. The @condition is checked each time the waitqueue @wq is woken up. | ||
207 | * | ||
208 | * This function is mostly used when a kthread or workqueue waits for some | ||
209 | * condition and doesn't want to contribute to system load. Signals are | ||
210 | * ignored. | ||
211 | * | ||
212 | * Returns: | ||
213 | * 0 if the @condition evaluated to %false after the @timeout elapsed, | ||
214 | * 1 if the @condition evaluated to %true after the @timeout elapsed, | ||
215 | * or the remaining jiffies (at least 1) if the @condition evaluated | ||
216 | * to %true before the @timeout elapsed. | ||
217 | */ | ||
218 | #define swait_event_idle_timeout(wq, condition, timeout) \ | ||
219 | ({ \ | ||
220 | long __ret = timeout; \ | ||
221 | if (!___wait_cond_timeout(condition)) \ | ||
222 | __ret = __swait_event_idle_timeout(wq, \ | ||
223 | condition, timeout); \ | ||
224 | __ret; \ | ||
225 | }) | ||
226 | |||
172 | #endif /* _LINUX_SWAIT_H */ | 227 | #endif /* _LINUX_SWAIT_H */ |