lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu,  6 May 2010 09:57:34 +0800
From:	Changli Gao <xiaosuo@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Alexander Viro <viro@...iv.linux.org.uk>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Davide Libenzi <davidel@...ilserver.org>,
	Roland Dreier <rolandd@...co.com>,
	Stefan Richter <stefanr@...6.in-berlin.de>,
	Ingo Molnar <mingo@...e.hu>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Takashi Iwai <tiwai@...e.de>,
	David Howells <dhowells@...hat.com>,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	Changli Gao <xiaosuo@...il.com>
Subject: [PATCH] epoll: use wrapper functions

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@...il.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);
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ