Commit 758e48e4 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Use fancy wakeups in wait.h

Use the more SMP-friendly prepare_to_wait()/finish_wait() in wait_event() and
friends.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0ac04ac1
...@@ -120,18 +120,15 @@ extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int ...@@ -120,18 +120,15 @@ extern void FASTCALL(__wake_up_sync(wait_queue_head_t *q, unsigned int mode, int
#define __wait_event(wq, condition) \ #define __wait_event(wq, condition) \
do { \ do { \
wait_queue_t __wait; \ DEFINE_WAIT(__wait); \
init_waitqueue_entry(&__wait, current); \
\ \
add_wait_queue(&wq, &__wait); \
for (;;) { \ for (;;) { \
set_current_state(TASK_UNINTERRUPTIBLE); \ prepare_to_wait(&wq, &__wait, TASK_UNINTERRUPTIBLE); \
if (condition) \ if (condition) \
break; \ break; \
schedule(); \ schedule(); \
} \ } \
current->state = TASK_RUNNING; \ finish_wait(&wq, &__wait); \
remove_wait_queue(&wq, &__wait); \
} while (0) } while (0)
#define wait_event(wq, condition) \ #define wait_event(wq, condition) \
...@@ -143,12 +140,10 @@ do { \ ...@@ -143,12 +140,10 @@ do { \
#define __wait_event_interruptible(wq, condition, ret) \ #define __wait_event_interruptible(wq, condition, ret) \
do { \ do { \
wait_queue_t __wait; \ DEFINE_WAIT(__wait); \
init_waitqueue_entry(&__wait, current); \
\ \
add_wait_queue(&wq, &__wait); \
for (;;) { \ for (;;) { \
set_current_state(TASK_INTERRUPTIBLE); \ prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
if (condition) \ if (condition) \
break; \ break; \
if (!signal_pending(current)) { \ if (!signal_pending(current)) { \
...@@ -158,8 +153,7 @@ do { \ ...@@ -158,8 +153,7 @@ do { \
ret = -ERESTARTSYS; \ ret = -ERESTARTSYS; \
break; \ break; \
} \ } \
current->state = TASK_RUNNING; \ finish_wait(&wq, &__wait); \
remove_wait_queue(&wq, &__wait); \
} while (0) } while (0)
#define wait_event_interruptible(wq, condition) \ #define wait_event_interruptible(wq, condition) \
...@@ -172,12 +166,10 @@ do { \ ...@@ -172,12 +166,10 @@ do { \
#define __wait_event_interruptible_timeout(wq, condition, ret) \ #define __wait_event_interruptible_timeout(wq, condition, ret) \
do { \ do { \
wait_queue_t __wait; \ DEFINE_WAIT(__wait); \
init_waitqueue_entry(&__wait, current); \
\ \
add_wait_queue(&wq, &__wait); \
for (;;) { \ for (;;) { \
set_current_state(TASK_INTERRUPTIBLE); \ prepare_to_wait(&wq, &__wait, TASK_INTERRUPTIBLE); \
if (condition) \ if (condition) \
break; \ break; \
if (!signal_pending(current)) { \ if (!signal_pending(current)) { \
...@@ -189,8 +181,7 @@ do { \ ...@@ -189,8 +181,7 @@ do { \
ret = -ERESTARTSYS; \ ret = -ERESTARTSYS; \
break; \ break; \
} \ } \
current->state = TASK_RUNNING; \ finish_wait(&wq, &__wait); \
remove_wait_queue(&wq, &__wait); \
} while (0) } while (0)
#define wait_event_interruptible_timeout(wq, condition, timeout) \ #define wait_event_interruptible_timeout(wq, condition, timeout) \
...@@ -203,12 +194,11 @@ do { \ ...@@ -203,12 +194,11 @@ do { \
#define __wait_event_interruptible_exclusive(wq, condition, ret) \ #define __wait_event_interruptible_exclusive(wq, condition, ret) \
do { \ do { \
wait_queue_t __wait; \ DEFINE_WAIT(__wait); \
init_waitqueue_entry(&__wait, current); \
\ \
add_wait_queue_exclusive(&wq, &__wait); \
for (;;) { \ for (;;) { \
set_current_state(TASK_INTERRUPTIBLE); \ prepare_to_wait_exclusive(&wq, &__wait, \
TASK_INTERRUPTIBLE); \
if (condition) \ if (condition) \
break; \ break; \
if (!signal_pending(current)) { \ if (!signal_pending(current)) { \
...@@ -218,8 +208,7 @@ do { \ ...@@ -218,8 +208,7 @@ do { \
ret = -ERESTARTSYS; \ ret = -ERESTARTSYS; \
break; \ break; \
} \ } \
current->state = TASK_RUNNING; \ finish_wait(&wq, &__wait); \
remove_wait_queue(&wq, &__wait); \
} while (0) } while (0)
#define wait_event_interruptible_exclusive(wq, condition) \ #define wait_event_interruptible_exclusive(wq, condition) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment