Commit 450d89ec authored by Eric Wong's avatar Eric Wong Committed by Linus Torvalds

epoll: cleanup: hoist out f_op->poll calls

This reduces the amount of code inside the ready list iteration loops for
better readability IMHO.
Signed-off-by: default avatarEric Wong <normalperson@yhbt.net>
Cc: Davide Libenzi <davidel@xmailserver.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ddf676c3
...@@ -772,6 +772,13 @@ static int ep_eventpoll_release(struct inode *inode, struct file *file) ...@@ -772,6 +772,13 @@ static int ep_eventpoll_release(struct inode *inode, struct file *file)
return 0; return 0;
} }
static inline unsigned int ep_item_poll(struct epitem *epi, poll_table *pt)
{
pt->_key = epi->event.events;
return epi->ffd.file->f_op->poll(epi->ffd.file, pt) & epi->event.events;
}
static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head,
void *priv) void *priv)
{ {
...@@ -779,10 +786,9 @@ static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, ...@@ -779,10 +786,9 @@ static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head,
poll_table pt; poll_table pt;
init_poll_funcptr(&pt, NULL); init_poll_funcptr(&pt, NULL);
list_for_each_entry_safe(epi, tmp, head, rdllink) { list_for_each_entry_safe(epi, tmp, head, rdllink) {
pt._key = epi->event.events; if (ep_item_poll(epi, &pt))
if (epi->ffd.file->f_op->poll(epi->ffd.file, &pt) &
epi->event.events)
return POLLIN | POLLRDNORM; return POLLIN | POLLRDNORM;
else { else {
/* /*
...@@ -1256,7 +1262,6 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event, ...@@ -1256,7 +1262,6 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
/* Initialize the poll table using the queue callback */ /* Initialize the poll table using the queue callback */
epq.epi = epi; epq.epi = epi;
init_poll_funcptr(&epq.pt, ep_ptable_queue_proc); init_poll_funcptr(&epq.pt, ep_ptable_queue_proc);
epq.pt._key = event->events;
/* /*
* Attach the item to the poll hooks and get current event bits. * Attach the item to the poll hooks and get current event bits.
...@@ -1265,7 +1270,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event, ...@@ -1265,7 +1270,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
* this operation completes, the poll callback can start hitting * this operation completes, the poll callback can start hitting
* the new item. * the new item.
*/ */
revents = tfile->f_op->poll(tfile, &epq.pt); revents = ep_item_poll(epi, &epq.pt);
/* /*
* We have to check if something went wrong during the poll wait queue * We have to check if something went wrong during the poll wait queue
...@@ -1365,7 +1370,6 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even ...@@ -1365,7 +1370,6 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even
* f_op->poll() call and the new event set registering. * f_op->poll() call and the new event set registering.
*/ */
epi->event.events = event->events; /* need barrier below */ epi->event.events = event->events; /* need barrier below */
pt._key = event->events;
epi->event.data = event->data; /* protected by mtx */ epi->event.data = event->data; /* protected by mtx */
if (epi->event.events & EPOLLWAKEUP) { if (epi->event.events & EPOLLWAKEUP) {
if (!ep_has_wakeup_source(epi)) if (!ep_has_wakeup_source(epi))
...@@ -1398,7 +1402,7 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even ...@@ -1398,7 +1402,7 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even
* Get current event bits. We can safely use the file* here because * Get current event bits. We can safely use the file* here because
* its usage count has been increased by the caller of this function. * its usage count has been increased by the caller of this function.
*/ */
revents = epi->ffd.file->f_op->poll(epi->ffd.file, &pt); revents = ep_item_poll(epi, &pt);
/* /*
* If the item is "hot" and it is not registered inside the ready * If the item is "hot" and it is not registered inside the ready
...@@ -1466,9 +1470,7 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, ...@@ -1466,9 +1470,7 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head,
list_del_init(&epi->rdllink); list_del_init(&epi->rdllink);
pt._key = epi->event.events; revents = ep_item_poll(epi, &pt);
revents = epi->ffd.file->f_op->poll(epi->ffd.file, &pt) &
epi->event.events;
/* /*
* If the event mask intersect the caller-requested one, * If the event mask intersect the caller-requested one,
......
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