Commit 41a1431b178c3b731d6dfc40b987528b333dd93e

Authored by Peter Zijlstra
Committed by Ingo Molnar
1 parent bb632bc449

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@redhat.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20131002092528.181897111@infradead.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Showing 1 changed file with 36 additions and 0 deletions Side-by-side Diff

include/linux/wait.h
... ... @@ -187,6 +187,42 @@
187 187 __cond || !ret; \
188 188 })
189 189  
  190 +#define ___wait_signal_pending(state) \
  191 + ((state == TASK_INTERRUPTIBLE && signal_pending(current)) || \
  192 + (state == TASK_KILLABLE && fatal_signal_pending(current)))
  193 +
  194 +#define ___wait_nop_ret int ret __always_unused
  195 +
  196 +#define ___wait_event(wq, condition, state, exclusive, ret, cmd) \
  197 +do { \
  198 + __label__ __out; \
  199 + DEFINE_WAIT(__wait); \
  200 + \
  201 + for (;;) { \
  202 + if (exclusive) \
  203 + prepare_to_wait_exclusive(&wq, &__wait, state); \
  204 + else \
  205 + prepare_to_wait(&wq, &__wait, state); \
  206 + \
  207 + if (condition) \
  208 + break; \
  209 + \
  210 + if (___wait_signal_pending(state)) { \
  211 + ret = -ERESTARTSYS; \
  212 + if (exclusive) { \
  213 + abort_exclusive_wait(&wq, &__wait, \
  214 + state, NULL); \
  215 + goto __out; \
  216 + } \
  217 + break; \
  218 + } \
  219 + \
  220 + cmd; \
  221 + } \
  222 + finish_wait(&wq, &__wait); \
  223 +__out: ; \
  224 +} while (0)
  225 +
190 226 #define __wait_event(wq, condition) \
191 227 do { \
192 228 DEFINE_WAIT(__wait); \