[PATCH] epoll: use wrapper functions

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Changli Gao
Date: Wednesday, May 5, 2010 - 6:57 pm

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);
 }
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] epoll: use wrapper functions, Changli Gao, (Wed May 5, 6:57 pm)
Re: indiscriminate get_maintainer.pl usage, Stefan Richter, (Wed May 5, 11:40 pm)
Re: indiscriminate get_maintainer.pl usage, Davide Libenzi, (Thu May 6, 8:42 am)
Re: indiscriminate get_maintainer.pl usage, Joe Perches, (Thu May 6, 9:52 am)
Re: indiscriminate get_maintainer.pl usage, Davide Libenzi, (Thu May 6, 10:59 am)
Re: [PATCH] epoll: use wrapper functions, Davide Libenzi, (Thu May 6, 11:47 am)
Re: [PATCH] epoll: use wrapper functions, Peter Zijlstra, (Thu May 6, 11:51 am)
Re: indiscriminate get_maintainer.pl usage, Roland Dreier, (Thu May 6, 1:13 pm)
Re: indiscriminate get_maintainer.pl usage, Joe Perches, (Thu May 6, 1:52 pm)
Re: [PATCH] epoll: use wrapper functions, Changli Gao, (Thu May 6, 7:48 pm)
Re: [PATCH] get_maintainer.pl: ignore non-maintainer tags, Florian Mickler, (Fri May 7, 12:02 am)
Re: [PATCH] get_maintainer.pl: ignore non-maintainer tags, Stefan Richter, (Fri May 7, 12:48 pm)