sched, wait: Use wrapper functions
epoll should not touch flags in wait_queue_t. This patch introduces a new function __add_wait_queue_exclusive(), for the users, who use wait queue as a LIFO queue. __add_wait_queue_tail_exclusive() is introduced too instead of add_wait_queue_exclusive_locked(). remove_wait_queue_locked() is removed, as it is a duplicate of __remove_wait_queue(), disliked by users, and with less users. Signed-off-by: Changli Gao <xiaosuo@gmail.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Paul Menage <menage@google.com> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Davide Libenzi <davidel@xmailserver.org> Cc: <containers@lists.linux-foundation.org> LKML-Reference: <1273214006-2979-1-git-send-email-xiaosuo@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
af507ae8a0
commit
a93d2f1744
|
@ -1140,8 +1140,7 @@ retry:
|
||||||
* ep_poll_callback() when events will become available.
|
* ep_poll_callback() when events will become available.
|
||||||
*/
|
*/
|
||||||
init_waitqueue_entry(&wait, current);
|
init_waitqueue_entry(&wait, current);
|
||||||
wait.flags |= WQ_FLAG_EXCLUSIVE;
|
__add_wait_queue_exclusive(&ep->wq, &wait);
|
||||||
__add_wait_queue(&ep->wq, &wait);
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -127,12 +127,26 @@ static inline void __add_wait_queue(wait_queue_head_t *head, wait_queue_t *new)
|
||||||
/*
|
/*
|
||||||
* Used for wake-one threads:
|
* Used for wake-one threads:
|
||||||
*/
|
*/
|
||||||
|
static inline void __add_wait_queue_exclusive(wait_queue_head_t *q,
|
||||||
|
wait_queue_t *wait)
|
||||||
|
{
|
||||||
|
wait->flags |= WQ_FLAG_EXCLUSIVE;
|
||||||
|
__add_wait_queue(q, wait);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void __add_wait_queue_tail(wait_queue_head_t *head,
|
static inline void __add_wait_queue_tail(wait_queue_head_t *head,
|
||||||
wait_queue_t *new)
|
wait_queue_t *new)
|
||||||
{
|
{
|
||||||
list_add_tail(&new->task_list, &head->task_list);
|
list_add_tail(&new->task_list, &head->task_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void __add_wait_queue_tail_exclusive(wait_queue_head_t *q,
|
||||||
|
wait_queue_t *wait)
|
||||||
|
{
|
||||||
|
wait->flags |= WQ_FLAG_EXCLUSIVE;
|
||||||
|
__add_wait_queue_tail(q, wait);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void __remove_wait_queue(wait_queue_head_t *head,
|
static inline void __remove_wait_queue(wait_queue_head_t *head,
|
||||||
wait_queue_t *old)
|
wait_queue_t *old)
|
||||||
{
|
{
|
||||||
|
@ -403,25 +417,6 @@ do { \
|
||||||
__ret; \
|
__ret; \
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
|
||||||
* Must be called with the spinlock in the wait_queue_head_t held.
|
|
||||||
*/
|
|
||||||
static inline void add_wait_queue_exclusive_locked(wait_queue_head_t *q,
|
|
||||||
wait_queue_t * wait)
|
|
||||||
{
|
|
||||||
wait->flags |= WQ_FLAG_EXCLUSIVE;
|
|
||||||
__add_wait_queue_tail(q, wait);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Must be called with the spinlock in the wait_queue_head_t held.
|
|
||||||
*/
|
|
||||||
static inline void remove_wait_queue_locked(wait_queue_head_t *q,
|
|
||||||
wait_queue_t * wait)
|
|
||||||
{
|
|
||||||
__remove_wait_queue(q, wait);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are the old interfaces to sleep waiting for an event.
|
* These are the old interfaces to sleep waiting for an event.
|
||||||
* They are racy. DO NOT use them, use the wait_event* interfaces above.
|
* They are racy. DO NOT use them, use the wait_event* interfaces above.
|
||||||
|
|
|
@ -3010,7 +3010,7 @@ static int cgroup_event_wake(wait_queue_t *wait, unsigned mode,
|
||||||
unsigned long flags = (unsigned long)key;
|
unsigned long flags = (unsigned long)key;
|
||||||
|
|
||||||
if (flags & POLLHUP) {
|
if (flags & POLLHUP) {
|
||||||
remove_wait_queue_locked(event->wqh, &event->wait);
|
__remove_wait_queue(event->wqh, &event->wait);
|
||||||
spin_lock(&cgrp->event_list_lock);
|
spin_lock(&cgrp->event_list_lock);
|
||||||
list_del(&event->list);
|
list_del(&event->list);
|
||||||
spin_unlock(&cgrp->event_list_lock);
|
spin_unlock(&cgrp->event_list_lock);
|
||||||
|
|
|
@ -3983,8 +3983,7 @@ do_wait_for_common(struct completion *x, long timeout, int state)
|
||||||
if (!x->done) {
|
if (!x->done) {
|
||||||
DECLARE_WAITQUEUE(wait, current);
|
DECLARE_WAITQUEUE(wait, current);
|
||||||
|
|
||||||
wait.flags |= WQ_FLAG_EXCLUSIVE;
|
__add_wait_queue_tail_exclusive(&x->wait, &wait);
|
||||||
__add_wait_queue_tail(&x->wait, &wait);
|
|
||||||
do {
|
do {
|
||||||
if (signal_pending_state(state, current)) {
|
if (signal_pending_state(state, current)) {
|
||||||
timeout = -ERESTARTSYS;
|
timeout = -ERESTARTSYS;
|
||||||
|
|
Loading…
Reference in New Issue