fs: optimize away ->_qproc indirection for poll_mask based polling

From: Christoph Hellwig
Date: Fri Jun 22 2018 - 05:36:26 EST


Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
fs/select.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/fs/select.c b/fs/select.c
index bc3cc0f98896..54406e0ad23e 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -845,7 +845,25 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait,
/* userland u16 ->events contains POLL... bitmap */
filter = demangle_poll(pollfd->events) | EPOLLERR | EPOLLHUP;
pwait->_key = filter | busy_flag;
- mask = vfs_poll(f.file, pwait);
+ if (f.file->f_op->poll) {
+ mask = f.file->f_op->poll(f.file, pwait);
+ } else if (file_has_poll_mask(f.file)) {
+ struct wait_queue_head *head;
+
+ head = f.file->f_op->get_poll_head(f.file, pwait->_key);
+ if (!head) {
+ mask = DEFAULT_POLLMASK;
+ } else if (IS_ERR(head)) {
+ mask = EPOLLERR;
+ } else {
+ if (pwait->_qproc)
+ __pollwait(f.file, head, pwait);
+ mask = f.file->f_op->poll_mask(f.file, pwait->_key);
+ }
+ } else {
+ mask = DEFAULT_POLLMASK;
+ }
+
if (mask & busy_flag)
*can_busy_poll = true;
mask &= filter; /* Mask out unneeded events. */
--
2.17.1