Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23048
b: refs/heads/master
c: 144efe3
h: refs/heads/master
v: v3
  • Loading branch information
Arjan van de Ven authored and Linus Torvalds committed Mar 23, 2006
1 parent fb03cb0 commit 8c8e987
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 70522e121a521aa09bd0f4e62e1aa68708b798e1
refs/heads/master: 144efe3e3e5ad57af549bf800fa4560d7c74e9fe
23 changes: 12 additions & 11 deletions trunk/fs/eventpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <linux/eventpoll.h>
#include <linux/mount.h>
#include <linux/bitops.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/io.h>
Expand All @@ -46,7 +47,7 @@
* LOCKING:
* There are three level of locking required by epoll :
*
* 1) epsem (semaphore)
* 1) epmutex (mutex)
* 2) ep->sem (rw_semaphore)
* 3) ep->lock (rw_lock)
*
Expand All @@ -67,9 +68,9 @@
* 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).
* 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.
* 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
* a greater scalability.
*/
Expand Down Expand Up @@ -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().
*/
static struct semaphore epsem;
static struct mutex epmutex;

/* Safe wake up implementation */
static struct poll_safewake psw;
Expand Down Expand Up @@ -477,10 +478,10 @@ void eventpoll_release_file(struct file *file)
* 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
* 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().
*/
down(&epsem);
mutex_lock(&epmutex);

while (!list_empty(lsthead)) {
epi = list_entry(lsthead->next, struct epitem, fllink);
Expand All @@ -492,7 +493,7 @@ void eventpoll_release_file(struct file *file)
up_write(&ep->sem);
}

up(&epsem);
mutex_unlock(&epmutex);
}


Expand Down Expand Up @@ -819,9 +820,9 @@ static void ep_free(struct eventpoll *ep)
* 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
* 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.
Expand All @@ -843,7 +844,7 @@ static void ep_free(struct eventpoll *ep)
ep_remove(ep, epi);
}

up(&epsem);
mutex_unlock(&epmutex);
}


Expand Down Expand Up @@ -1615,7 +1616,7 @@ static int __init eventpoll_init(void)
{
int error;

init_MUTEX(&epsem);
mutex_init(&epmutex);

/* Initialize the structure used to perform safe poll wait head wake ups */
ep_poll_safewake_init(&psw);
Expand Down

0 comments on commit 8c8e987

Please sign in to comment.