diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-04-30 18:27:42 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-30 20:04:04 -0400 |
commit | 450d89ec0a91dbad81adaa635fdb1325b57f8d69 (patch) | |
tree | 939059552c8bb7dd83e12937e355d1548880195b /fs/eventpoll.c | |
parent | ddf676c38b56a8641c8eb9fb856fa304018ff390 (diff) |
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: Eric Wong <normalperson@yhbt.net>
Cc: Davide Libenzi <davidel@xmailserver.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/eventpoll.c')
-rw-r--r-- | fs/eventpoll.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 5744a7f01875..c5d9880b5fcf 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -772,6 +772,13 @@ static int ep_eventpoll_release(struct inode *inode, struct file *file) | |||
772 | return 0; | 772 | return 0; |
773 | } | 773 | } |
774 | 774 | ||
775 | static inline unsigned int ep_item_poll(struct epitem *epi, poll_table *pt) | ||
776 | { | ||
777 | pt->_key = epi->event.events; | ||
778 | |||
779 | return epi->ffd.file->f_op->poll(epi->ffd.file, pt) & epi->event.events; | ||
780 | } | ||
781 | |||
775 | static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, | 782 | static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, |
776 | void *priv) | 783 | void *priv) |
777 | { | 784 | { |
@@ -779,10 +786,9 @@ static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, | |||
779 | poll_table pt; | 786 | poll_table pt; |
780 | 787 | ||
781 | init_poll_funcptr(&pt, NULL); | 788 | init_poll_funcptr(&pt, NULL); |
789 | |||
782 | list_for_each_entry_safe(epi, tmp, head, rdllink) { | 790 | list_for_each_entry_safe(epi, tmp, head, rdllink) { |
783 | pt._key = epi->event.events; | 791 | if (ep_item_poll(epi, &pt)) |
784 | if (epi->ffd.file->f_op->poll(epi->ffd.file, &pt) & | ||
785 | epi->event.events) | ||
786 | return POLLIN | POLLRDNORM; | 792 | return POLLIN | POLLRDNORM; |
787 | else { | 793 | else { |
788 | /* | 794 | /* |
@@ -1256,7 +1262,6 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event, | |||
1256 | /* Initialize the poll table using the queue callback */ | 1262 | /* Initialize the poll table using the queue callback */ |
1257 | epq.epi = epi; | 1263 | epq.epi = epi; |
1258 | init_poll_funcptr(&epq.pt, ep_ptable_queue_proc); | 1264 | init_poll_funcptr(&epq.pt, ep_ptable_queue_proc); |
1259 | epq.pt._key = event->events; | ||
1260 | 1265 | ||
1261 | /* | 1266 | /* |
1262 | * Attach the item to the poll hooks and get current event bits. | 1267 | * 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 | * this operation completes, the poll callback can start hitting | 1270 | * this operation completes, the poll callback can start hitting |
1266 | * the new item. | 1271 | * the new item. |
1267 | */ | 1272 | */ |
1268 | revents = tfile->f_op->poll(tfile, &epq.pt); | 1273 | revents = ep_item_poll(epi, &epq.pt); |
1269 | 1274 | ||
1270 | /* | 1275 | /* |
1271 | * We have to check if something went wrong during the poll wait queue | 1276 | * 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 | * f_op->poll() call and the new event set registering. | 1370 | * f_op->poll() call and the new event set registering. |
1366 | */ | 1371 | */ |
1367 | epi->event.events = event->events; /* need barrier below */ | 1372 | epi->event.events = event->events; /* need barrier below */ |
1368 | pt._key = event->events; | ||
1369 | epi->event.data = event->data; /* protected by mtx */ | 1373 | epi->event.data = event->data; /* protected by mtx */ |
1370 | if (epi->event.events & EPOLLWAKEUP) { | 1374 | if (epi->event.events & EPOLLWAKEUP) { |
1371 | if (!ep_has_wakeup_source(epi)) | 1375 | if (!ep_has_wakeup_source(epi)) |
@@ -1398,7 +1402,7 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, struct epoll_even | |||
1398 | * Get current event bits. We can safely use the file* here because | 1402 | * Get current event bits. We can safely use the file* here because |
1399 | * its usage count has been increased by the caller of this function. | 1403 | * its usage count has been increased by the caller of this function. |
1400 | */ | 1404 | */ |
1401 | revents = epi->ffd.file->f_op->poll(epi->ffd.file, &pt); | 1405 | revents = ep_item_poll(epi, &pt); |
1402 | 1406 | ||
1403 | /* | 1407 | /* |
1404 | * If the item is "hot" and it is not registered inside the ready | 1408 | * 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 | 1470 | ||
1467 | list_del_init(&epi->rdllink); | 1471 | list_del_init(&epi->rdllink); |
1468 | 1472 | ||
1469 | pt._key = epi->event.events; | 1473 | revents = ep_item_poll(epi, &pt); |
1470 | revents = epi->ffd.file->f_op->poll(epi->ffd.file, &pt) & | ||
1471 | epi->event.events; | ||
1472 | 1474 | ||
1473 | /* | 1475 | /* |
1474 | * If the event mask intersect the caller-requested one, | 1476 | * If the event mask intersect the caller-requested one, |