Commit 144efe3e authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Linus Torvalds

[PATCH] sem2mutex: eventpoll

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: default avatarArjan van de Ven <arjan@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: Davide Libenzi <davidel@xmailserver.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 70522e12
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/eventpoll.h> #include <linux/eventpoll.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -46,7 +47,7 @@ ...@@ -46,7 +47,7 @@
* LOCKING: * LOCKING:
* There are three level of locking required by epoll : * There are three level of locking required by epoll :
* *
* 1) epsem (semaphore) * 1) epmutex (mutex)
* 2) ep->sem (rw_semaphore) * 2) ep->sem (rw_semaphore)
* 3) ep->lock (rw_lock) * 3) ep->lock (rw_lock)
* *
...@@ -67,9 +68,9 @@ ...@@ -67,9 +68,9 @@
* if a file has been pushed inside an epoll set and it is then * if a file has been pushed inside an epoll set and it is then
* close()d without a previous call toepoll_ctl(EPOLL_CTL_DEL). * close()d without a previous call toepoll_ctl(EPOLL_CTL_DEL).
* It is possible to drop the "ep->sem" and to use the global * It is possible to drop the "ep->sem" and to use the global
* semaphore "epsem" (together with "ep->lock") to have it working, * semaphore "epmutex" (together with "ep->lock") to have it working,
* but having "ep->sem" will make the interface more scalable. * but having "ep->sem" will make the interface more scalable.
* Events that require holding "epsem" are very rare, while for * Events that require holding "epmutex" are very rare, while for
* normal operations the epoll private "ep->sem" will guarantee * normal operations the epoll private "ep->sem" will guarantee
* a greater scalability. * a greater scalability.
*/ */
...@@ -274,7 +275,7 @@ static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type, ...@@ -274,7 +275,7 @@ static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type,
/* /*
* This semaphore is used to serialize ep_free() and eventpoll_release_file(). * This semaphore is used to serialize ep_free() and eventpoll_release_file().
*/ */
static struct semaphore epsem; static struct mutex epmutex;
/* Safe wake up implementation */ /* Safe wake up implementation */
static struct poll_safewake psw; static struct poll_safewake psw;
...@@ -477,10 +478,10 @@ void eventpoll_release_file(struct file *file) ...@@ -477,10 +478,10 @@ void eventpoll_release_file(struct file *file)
* cleanup path, and this means that noone is using this file anymore. * cleanup path, and this means that noone is using this file anymore.
* The only hit might come from ep_free() but by holding the semaphore * The only hit might come from ep_free() but by holding the semaphore
* will correctly serialize the operation. We do need to acquire * will correctly serialize the operation. We do need to acquire
* "ep->sem" after "epsem" because ep_remove() requires it when called * "ep->sem" after "epmutex" because ep_remove() requires it when called
* from anywhere but ep_free(). * from anywhere but ep_free().
*/ */
down(&epsem); mutex_lock(&epmutex);
while (!list_empty(lsthead)) { while (!list_empty(lsthead)) {
epi = list_entry(lsthead->next, struct epitem, fllink); epi = list_entry(lsthead->next, struct epitem, fllink);
...@@ -492,7 +493,7 @@ void eventpoll_release_file(struct file *file) ...@@ -492,7 +493,7 @@ void eventpoll_release_file(struct file *file)
up_write(&ep->sem); up_write(&ep->sem);
} }
up(&epsem); mutex_unlock(&epmutex);
} }
...@@ -819,9 +820,9 @@ static void ep_free(struct eventpoll *ep) ...@@ -819,9 +820,9 @@ static void ep_free(struct eventpoll *ep)
* We do not need to hold "ep->sem" here because the epoll file * We do not need to hold "ep->sem" here because the epoll file
* is on the way to be removed and no one has references to it * is on the way to be removed and no one has references to it
* anymore. The only hit might come from eventpoll_release_file() but * anymore. The only hit might come from eventpoll_release_file() but
* holding "epsem" is sufficent here. * holding "epmutex" is sufficent here.
*/ */
down(&epsem); mutex_lock(&epmutex);
/* /*
* Walks through the whole tree by unregistering poll callbacks. * Walks through the whole tree by unregistering poll callbacks.
...@@ -843,7 +844,7 @@ static void ep_free(struct eventpoll *ep) ...@@ -843,7 +844,7 @@ static void ep_free(struct eventpoll *ep)
ep_remove(ep, epi); ep_remove(ep, epi);
} }
up(&epsem); mutex_unlock(&epmutex);
} }
...@@ -1615,7 +1616,7 @@ static int __init eventpoll_init(void) ...@@ -1615,7 +1616,7 @@ static int __init eventpoll_init(void)
{ {
int error; int error;
init_MUTEX(&epsem); mutex_init(&epmutex);
/* Initialize the structure used to perform safe poll wait head wake ups */ /* Initialize the structure used to perform safe poll wait head wake ups */
ep_poll_safewake_init(&psw); ep_poll_safewake_init(&psw);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment