提交 35a2af94 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

sched/wait: Make the __wait_event*() interface more friendly

Change all __wait_event*() implementations to match the corresponding
wait_event*() signature for convenience.

In particular this does away with the weird 'ret' logic. Since there
are __wait_event*() users this requires we update them too.
Reviewed-by: NOleg Nesterov <oleg@redhat.com>
Signed-off-by: NPeter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20131002092529.042563462@infradead.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 ebdc195f
master alk-4.19.24 alk-4.19.30 alk-4.19.34 alk-4.19.36 alk-4.19.43 alk-4.19.48 alk-4.19.57 ck-4.19.67 ck-4.19.81 ck-4.19.91 github/fork/deepanshu1422/fix-typo-in-comment github/fork/haosdent/fix-typo linux-next v4.19.91 v4.19.90 v4.19.89 v4.19.88 v4.19.87 v4.19.86 v4.19.85 v4.19.84 v4.19.83 v4.19.82 v4.19.81 v4.19.80 v4.19.79 v4.19.78 v4.19.77 v4.19.76 v4.19.75 v4.19.74 v4.19.73 v4.19.72 v4.19.71 v4.19.70 v4.19.69 v4.19.68 v4.19.67 v4.19.66 v4.19.65 v4.19.64 v4.19.63 v4.19.62 v4.19.61 v4.19.60 v4.19.59 v4.19.58 v4.19.57 v4.19.56 v4.19.55 v4.19.54 v4.19.53 v4.19.52 v4.19.51 v4.19.50 v4.19.49 v4.19.48 v4.19.47 v4.19.46 v4.19.45 v4.19.44 v4.19.43 v4.19.42 v4.19.41 v4.19.40 v4.19.39 v4.19.38 v4.19.37 v4.19.36 v4.19.35 v4.19.34 v4.19.33 v4.19.32 v4.19.31 v4.19.30 v4.19.29 v4.19.28 v4.19.27 v4.19.26 v4.19.25 v4.19.24 v4.19.23 v4.19.22 v4.19.21 v4.19.20 v4.19.19 v4.19.18 v4.19.17 v4.19.16 v4.19.15 v4.19.14 v4.19.13 v4.19.12 v4.19.11 v4.19.10 v4.19.9 v4.19.8 v4.19.7 v4.19.6 v4.19.5 v4.19.4 v4.19.3 v4.19.2 v4.19.1 v4.19 v4.19-rc8 v4.19-rc7 v4.19-rc6 v4.19-rc5 v4.19-rc4 v4.19-rc3 v4.19-rc2 v4.19-rc1 ck-release-21 ck-release-20 ck-release-19.2 ck-release-19.1 ck-release-19 ck-release-18 ck-release-17.2 ck-release-17.1 ck-release-17 ck-release-16 ck-release-15.1 ck-release-15 ck-release-14 ck-release-13.2 ck-release-13 ck-release-12 ck-release-11 ck-release-10 ck-release-9 ck-release-7 alk-release-15 alk-release-14 alk-release-13.2 alk-release-13 alk-release-12 alk-release-11 alk-release-10 alk-release-9 alk-release-7
无相关合并请求
...@@ -172,8 +172,9 @@ int rtlx_open(int index, int can_sleep) ...@@ -172,8 +172,9 @@ int rtlx_open(int index, int can_sleep)
if (rtlx == NULL) { if (rtlx == NULL) {
if( (p = vpe_get_shared(tclimit)) == NULL) { if( (p = vpe_get_shared(tclimit)) == NULL) {
if (can_sleep) { if (can_sleep) {
__wait_event_interruptible(channel_wqs[index].lx_queue, ret = __wait_event_interruptible(
(p = vpe_get_shared(tclimit)), ret); channel_wqs[index].lx_queue,
(p = vpe_get_shared(tclimit)));
if (ret) if (ret)
goto out_fail; goto out_fail;
} else { } else {
...@@ -263,11 +264,10 @@ unsigned int rtlx_read_poll(int index, int can_sleep) ...@@ -263,11 +264,10 @@ unsigned int rtlx_read_poll(int index, int can_sleep)
/* data available to read? */ /* data available to read? */
if (chan->lx_read == chan->lx_write) { if (chan->lx_read == chan->lx_write) {
if (can_sleep) { if (can_sleep) {
int ret = 0; int ret = __wait_event_interruptible(
channel_wqs[index].lx_queue,
__wait_event_interruptible(channel_wqs[index].lx_queue,
(chan->lx_read != chan->lx_write) || (chan->lx_read != chan->lx_write) ||
sp_stopping, ret); sp_stopping);
if (ret) if (ret)
return ret; return ret;
...@@ -440,14 +440,13 @@ static ssize_t file_write(struct file *file, const char __user * buffer, ...@@ -440,14 +440,13 @@ static ssize_t file_write(struct file *file, const char __user * buffer,
/* any space left... */ /* any space left... */
if (!rtlx_write_poll(minor)) { if (!rtlx_write_poll(minor)) {
int ret = 0; int ret;
if (file->f_flags & O_NONBLOCK) if (file->f_flags & O_NONBLOCK)
return -EAGAIN; return -EAGAIN;
__wait_event_interruptible(channel_wqs[minor].rt_queue, ret = __wait_event_interruptible(channel_wqs[minor].rt_queue,
rtlx_write_poll(minor), rtlx_write_poll(minor));
ret);
if (ret) if (ret)
return ret; return ret;
} }
......
...@@ -672,14 +672,14 @@ static inline void tty_wait_until_sent_from_close(struct tty_struct *tty, ...@@ -672,14 +672,14 @@ static inline void tty_wait_until_sent_from_close(struct tty_struct *tty,
#define wait_event_interruptible_tty(tty, wq, condition) \ #define wait_event_interruptible_tty(tty, wq, condition) \
({ \ ({ \
int __ret = 0; \ int __ret = 0; \
if (!(condition)) { \ if (!(condition)) \
__wait_event_interruptible_tty(tty, wq, condition, __ret); \ __ret = __wait_event_interruptible_tty(tty, wq, \
} \ condition); \
__ret; \ __ret; \
}) })
#define __wait_event_interruptible_tty(tty, wq, condition, ret) \ #define __wait_event_interruptible_tty(tty, wq, condition) \
___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, ret, \ ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0, \
tty_unlock(tty); \ tty_unlock(tty); \
schedule(); \ schedule(); \
tty_lock(tty)) tty_lock(tty))
......
...@@ -179,24 +179,23 @@ wait_queue_head_t *bit_waitqueue(void *, int); ...@@ -179,24 +179,23 @@ wait_queue_head_t *bit_waitqueue(void *, int);
#define wake_up_interruptible_sync_poll(x, m) \ #define wake_up_interruptible_sync_poll(x, m) \
__wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m)) __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m))
#define ___wait_cond_timeout(condition, ret) \ #define ___wait_cond_timeout(condition) \
({ \ ({ \
bool __cond = (condition); \ bool __cond = (condition); \
if (__cond && !ret) \ if (__cond && !__ret) \
ret = 1; \ __ret = 1; \
__cond || !ret; \ __cond || !__ret; \
}) })
#define ___wait_signal_pending(state) \ #define ___wait_signal_pending(state) \
((state == TASK_INTERRUPTIBLE && signal_pending(current)) || \ ((state == TASK_INTERRUPTIBLE && signal_pending(current)) || \
(state == TASK_KILLABLE && fatal_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) \ #define ___wait_event(wq, condition, state, exclusive, ret, cmd) \
do { \ ({ \
__label__ __out; \ __label__ __out; \
DEFINE_WAIT(__wait); \ DEFINE_WAIT(__wait); \
long __ret = ret; \
\ \
for (;;) { \ for (;;) { \
if (exclusive) \ if (exclusive) \
...@@ -208,7 +207,7 @@ do { \ ...@@ -208,7 +207,7 @@ do { \
break; \ break; \
\ \
if (___wait_signal_pending(state)) { \ if (___wait_signal_pending(state)) { \
ret = -ERESTARTSYS; \ __ret = -ERESTARTSYS; \
if (exclusive) { \ if (exclusive) { \
abort_exclusive_wait(&wq, &__wait, \ abort_exclusive_wait(&wq, &__wait, \
state, NULL); \ state, NULL); \
...@@ -220,12 +219,12 @@ do { \ ...@@ -220,12 +219,12 @@ do { \
cmd; \ cmd; \
} \ } \
finish_wait(&wq, &__wait); \ finish_wait(&wq, &__wait); \
__out: ; \ __out: __ret; \
} while (0) })
#define __wait_event(wq, condition) \ #define __wait_event(wq, condition) \
___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, \ (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0, \
___wait_nop_ret, schedule()) schedule())
/** /**
* wait_event - sleep until a condition gets true * wait_event - sleep until a condition gets true
...@@ -246,10 +245,10 @@ do { \ ...@@ -246,10 +245,10 @@ do { \
__wait_event(wq, condition); \ __wait_event(wq, condition); \
} while (0) } while (0)
#define __wait_event_timeout(wq, condition, ret) \ #define __wait_event_timeout(wq, condition, timeout) \
___wait_event(wq, ___wait_cond_timeout(condition, ret), \ ___wait_event(wq, ___wait_cond_timeout(condition), \
TASK_UNINTERRUPTIBLE, 0, ret, \ TASK_UNINTERRUPTIBLE, 0, timeout, \
ret = schedule_timeout(ret)) __ret = schedule_timeout(__ret))
/** /**
* wait_event_timeout - sleep until a condition gets true or a timeout elapses * wait_event_timeout - sleep until a condition gets true or a timeout elapses
...@@ -272,12 +271,12 @@ do { \ ...@@ -272,12 +271,12 @@ do { \
({ \ ({ \
long __ret = timeout; \ long __ret = timeout; \
if (!(condition)) \ if (!(condition)) \
__wait_event_timeout(wq, condition, __ret); \ __ret = __wait_event_timeout(wq, condition, timeout); \
__ret; \ __ret; \
}) })
#define __wait_event_interruptible(wq, condition, ret) \ #define __wait_event_interruptible(wq, condition) \
___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, ret, \ ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0, \
schedule()) schedule())
/** /**
...@@ -299,14 +298,14 @@ do { \ ...@@ -299,14 +298,14 @@ do { \
({ \ ({ \
int __ret = 0; \ int __ret = 0; \
if (!(condition)) \ if (!(condition)) \
__wait_event_interruptible(wq, condition, __ret); \ __ret = __wait_event_interruptible(wq, condition); \
__ret; \ __ret; \
}) })
#define __wait_event_interruptible_timeout(wq, condition, ret) \ #define __wait_event_interruptible_timeout(wq, condition, timeout) \
___wait_event(wq, ___wait_cond_timeout(condition, ret), \ ___wait_event(wq, ___wait_cond_timeout(condition), \
TASK_INTERRUPTIBLE, 0, ret, \ TASK_INTERRUPTIBLE, 0, timeout, \
ret = schedule_timeout(ret)) __ret = schedule_timeout(__ret))
/** /**
* wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses * wait_event_interruptible_timeout - sleep until a condition gets true or a timeout elapses
...@@ -330,7 +329,8 @@ do { \ ...@@ -330,7 +329,8 @@ do { \
({ \ ({ \
long __ret = timeout; \ long __ret = timeout; \
if (!(condition)) \ if (!(condition)) \
__wait_event_interruptible_timeout(wq, condition, __ret); \ __ret = __wait_event_interruptible_timeout(wq, \
condition, timeout); \
__ret; \ __ret; \
}) })
...@@ -347,7 +347,7 @@ do { \ ...@@ -347,7 +347,7 @@ do { \
current->timer_slack_ns, \ current->timer_slack_ns, \
HRTIMER_MODE_REL); \ HRTIMER_MODE_REL); \
\ \
___wait_event(wq, condition, state, 0, __ret, \ __ret = ___wait_event(wq, condition, state, 0, 0, \
if (!__t.task) { \ if (!__t.task) { \
__ret = -ETIME; \ __ret = -ETIME; \
break; \ break; \
...@@ -409,15 +409,15 @@ do { \ ...@@ -409,15 +409,15 @@ do { \
__ret; \ __ret; \
}) })
#define __wait_event_interruptible_exclusive(wq, condition, ret) \ #define __wait_event_interruptible_exclusive(wq, condition) \
___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, ret, \ ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \
schedule()) schedule())
#define wait_event_interruptible_exclusive(wq, condition) \ #define wait_event_interruptible_exclusive(wq, condition) \
({ \ ({ \
int __ret = 0; \ int __ret = 0; \
if (!(condition)) \ if (!(condition)) \
__wait_event_interruptible_exclusive(wq, condition, __ret);\ __ret = __wait_event_interruptible_exclusive(wq, condition);\
__ret; \ __ret; \
}) })
...@@ -570,8 +570,8 @@ do { \ ...@@ -570,8 +570,8 @@ do { \
#define __wait_event_killable(wq, condition, ret) \ #define __wait_event_killable(wq, condition) \
___wait_event(wq, condition, TASK_KILLABLE, 0, ret, schedule()) ___wait_event(wq, condition, TASK_KILLABLE, 0, 0, schedule())
/** /**
* wait_event_killable - sleep until a condition gets true * wait_event_killable - sleep until a condition gets true
...@@ -592,18 +592,17 @@ do { \ ...@@ -592,18 +592,17 @@ do { \
({ \ ({ \
int __ret = 0; \ int __ret = 0; \
if (!(condition)) \ if (!(condition)) \
__wait_event_killable(wq, condition, __ret); \ __ret = __wait_event_killable(wq, condition); \
__ret; \ __ret; \
}) })
#define __wait_event_lock_irq(wq, condition, lock, cmd) \ #define __wait_event_lock_irq(wq, condition, lock, cmd) \
___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, \ (void)___wait_event(wq, condition, TASK_UNINTERRUPTIBLE, 0, 0, \
___wait_nop_ret, \ spin_unlock_irq(&lock); \
spin_unlock_irq(&lock); \ cmd; \
cmd; \ schedule(); \
schedule(); \ spin_lock_irq(&lock))
spin_lock_irq(&lock))
/** /**
* wait_event_lock_irq_cmd - sleep until a condition gets true. The * wait_event_lock_irq_cmd - sleep until a condition gets true. The
...@@ -663,11 +662,11 @@ do { \ ...@@ -663,11 +662,11 @@ do { \
} while (0) } while (0)
#define __wait_event_interruptible_lock_irq(wq, condition, lock, ret, cmd) \ #define __wait_event_interruptible_lock_irq(wq, condition, lock, cmd) \
___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, ret, \ ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 0, 0, \
spin_unlock_irq(&lock); \ spin_unlock_irq(&lock); \
cmd; \ cmd; \
schedule(); \ schedule(); \
spin_lock_irq(&lock)) spin_lock_irq(&lock))
/** /**
...@@ -698,10 +697,9 @@ do { \ ...@@ -698,10 +697,9 @@ do { \
#define wait_event_interruptible_lock_irq_cmd(wq, condition, lock, cmd) \ #define wait_event_interruptible_lock_irq_cmd(wq, condition, lock, cmd) \
({ \ ({ \
int __ret = 0; \ int __ret = 0; \
\
if (!(condition)) \ if (!(condition)) \
__wait_event_interruptible_lock_irq(wq, condition, \ __ret = __wait_event_interruptible_lock_irq(wq, \
lock, __ret, cmd); \ condition, lock, cmd); \
__ret; \ __ret; \
}) })
...@@ -730,18 +728,18 @@ do { \ ...@@ -730,18 +728,18 @@ do { \
#define wait_event_interruptible_lock_irq(wq, condition, lock) \ #define wait_event_interruptible_lock_irq(wq, condition, lock) \
({ \ ({ \
int __ret = 0; \ int __ret = 0; \
\
if (!(condition)) \ if (!(condition)) \
__wait_event_interruptible_lock_irq(wq, condition, \ __ret = __wait_event_interruptible_lock_irq(wq, \
lock, __ret, ); \ condition, lock,) \
__ret; \ __ret; \
}) })
#define __wait_event_interruptible_lock_irq_timeout(wq, condition, lock, ret) \ #define __wait_event_interruptible_lock_irq_timeout(wq, condition, \
___wait_event(wq, ___wait_cond_timeout(condition, ret), \ lock, timeout) \
TASK_INTERRUPTIBLE, 0, ret, \ ___wait_event(wq, ___wait_cond_timeout(condition), \
spin_unlock_irq(&lock); \ TASK_INTERRUPTIBLE, 0, ret, \
ret = schedule_timeout(ret); \ spin_unlock_irq(&lock); \
__ret = schedule_timeout(__ret); \
spin_lock_irq(&lock)); spin_lock_irq(&lock));
/** /**
...@@ -771,11 +769,10 @@ do { \ ...@@ -771,11 +769,10 @@ do { \
#define wait_event_interruptible_lock_irq_timeout(wq, condition, lock, \ #define wait_event_interruptible_lock_irq_timeout(wq, condition, lock, \
timeout) \ timeout) \
({ \ ({ \
int __ret = timeout; \ long __ret = timeout; \
\
if (!(condition)) \ if (!(condition)) \
__wait_event_interruptible_lock_irq_timeout( \ __ret = __wait_event_interruptible_lock_irq_timeout( \
wq, condition, lock, __ret); \ wq, condition, lock, timeout); \
__ret; \ __ret; \
}) })
......
...@@ -2563,9 +2563,8 @@ static int irda_getsockopt(struct socket *sock, int level, int optname, ...@@ -2563,9 +2563,8 @@ static int irda_getsockopt(struct socket *sock, int level, int optname,
jiffies + msecs_to_jiffies(val)); jiffies + msecs_to_jiffies(val));
/* Wait for IR-LMP to call us back */ /* Wait for IR-LMP to call us back */
__wait_event_interruptible(self->query_wait, err = __wait_event_interruptible(self->query_wait,
(self->cachedaddr != 0 || self->errno == -ETIME), (self->cachedaddr != 0 || self->errno == -ETIME));
err);
/* If watchdog is still activated, kill it! */ /* If watchdog is still activated, kill it! */
del_timer(&(self->watchdog)); del_timer(&(self->watchdog));
......
...@@ -1637,12 +1637,9 @@ static int sync_thread_master(void *data) ...@@ -1637,12 +1637,9 @@ static int sync_thread_master(void *data)
continue; continue;
} }
while (ip_vs_send_sync_msg(tinfo->sock, sb->mesg) < 0) { while (ip_vs_send_sync_msg(tinfo->sock, sb->mesg) < 0) {
int ret = 0; int ret = __wait_event_interruptible(*sk_sleep(sk),
__wait_event_interruptible(*sk_sleep(sk),
sock_writeable(sk) || sock_writeable(sk) ||
kthread_should_stop(), kthread_should_stop());
ret);
if (unlikely(kthread_should_stop())) if (unlikely(kthread_should_stop()))
goto done; goto done;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部