From: Changli Gao <xiaosuo@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Davide Libenzi <davidel@xmailserver.org>,
Roland Dreier <rolandd@cisco.com>,
Stefan Richter <stefanr@s5r6.in-berlin.de>,
Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Takashi Iwai <tiwai@suse.de>, David Howells <dhowells@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Changli Gao <xiaosuo@gmail.com>
Subject: [PATCH] epoll: use wrapper functions
Date: Thu, 6 May 2010 09:57:34 +0800 [thread overview]
Message-ID: <1273111054-10141-1-git-send-email-xiaosuo@gmail.com> (raw)
use wrapper functions.
epoll should not touch flags in wait_queue_t. This patch introduces a new
function add_wait_queue_head_exclusive_locked(), for the users, who use
wait queue as a LIFO queue.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
----
fs/eventpoll.c | 5 ++---
include/linux/wait.h | 15 +++++++++++++--
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index bd056a5..8137f6e 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1140,8 +1140,7 @@ retry:
* ep_poll_callback() when events will become available.
*/
init_waitqueue_entry(&wait, current);
- wait.flags |= WQ_FLAG_EXCLUSIVE;
- __add_wait_queue(&ep->wq, &wait);
+ add_wait_queue_head_exclusive_locked(&ep->wq, &wait);
for (;;) {
/*
@@ -1161,7 +1160,7 @@ retry:
jtimeout = schedule_timeout(jtimeout);
spin_lock_irqsave(&ep->lock, flags);
}
- __remove_wait_queue(&ep->wq, &wait);
+ remove_wait_queue_locked(&ep->wq, &wait);
set_current_state(TASK_RUNNING);
}
diff --git a/include/linux/wait.h b/include/linux/wait.h
index a48e16b..de2566d 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -407,17 +407,28 @@ do { \
* 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_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, and
+ * q must be for exclusive wait only.
+ */
+static inline void add_wait_queue_head_exclusive_locked(wait_queue_head_t *q,
+ wait_queue_t *wait)
+{
+ wait->flags |= WQ_FLAG_EXCLUSIVE;
+ __add_wait_queue(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)
+ wait_queue_t *wait)
{
__remove_wait_queue(q, wait);
}
next reply other threads:[~2010-05-06 1:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-06 1:57 Changli Gao [this message]
2010-05-06 18:47 ` [PATCH] epoll: use wrapper functions Davide Libenzi
2010-05-06 18:51 ` Peter Zijlstra
2010-05-07 2:48 ` Changli Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1273111054-10141-1-git-send-email-xiaosuo@gmail.com \
--to=xiaosuo@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=davidel@xmailserver.org \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rolandd@cisco.com \
--cc=stefanr@s5r6.in-berlin.de \
--cc=tiwai@suse.de \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).