[tip:sched/core] sched/wait: Introduce ___wait_event()
From: tip-bot for Peter Zijlstra
Date: Fri Oct 04 2013 - 13:34:39 EST
Commit-ID: 41a1431b178c3b731d6dfc40b987528b333dd93e
Gitweb: http://git.kernel.org/tip/41a1431b178c3b731d6dfc40b987528b333dd93e
Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
AuthorDate: Wed, 2 Oct 2013 11:22:21 +0200
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitDate: Fri, 4 Oct 2013 10:14:46 +0200
sched/wait: Introduce ___wait_event()
There's far too much duplication in the __wait_event macros; in order
to fix this introduce ___wait_event() a macro with the capability to
replace most other macros.
With the previous patches changing the various __wait_event*()
implementations to be more uniform; we can now collapse the lot
without also changing generated code.
Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>
Signed-off-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Link: http://lkml.kernel.org/r/20131002092528.181897111@xxxxxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
include/linux/wait.h | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 7d7819d..29d0249 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -187,6 +187,42 @@ wait_queue_head_t *bit_waitqueue(void *, int);
__cond || !ret; \
})
+#define ___wait_signal_pending(state) \
+ ((state == TASK_INTERRUPTIBLE && signal_pending(current)) || \
+ (state == TASK_KILLABLE && fatal_signal_pending(current)))
+
+#define ___wait_nop_ret int ret __always_unused
+
+#define ___wait_event(wq, condition, state, exclusive, ret, cmd) \
+do { \
+ __label__ __out; \
+ DEFINE_WAIT(__wait); \
+ \
+ for (;;) { \
+ if (exclusive) \
+ prepare_to_wait_exclusive(&wq, &__wait, state); \
+ else \
+ prepare_to_wait(&wq, &__wait, state); \
+ \
+ if (condition) \
+ break; \
+ \
+ if (___wait_signal_pending(state)) { \
+ ret = -ERESTARTSYS; \
+ if (exclusive) { \
+ abort_exclusive_wait(&wq, &__wait, \
+ state, NULL); \
+ goto __out; \
+ } \
+ break; \
+ } \
+ \
+ cmd; \
+ } \
+ finish_wait(&wq, &__wait); \
+__out: ; \
+} while (0)
+
#define __wait_event(wq, condition) \
do { \
DEFINE_WAIT(__wait); \
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/