mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-16 04:04:06 +00:00
io_uring: refactor io_arm_poll_handler()
gcc 11 goes a weird path and duplicates most of io_arm_poll_handler() for READ and WRITE cases. Help it and move all pollin vs pollout specific bits under a single if-else, so there is no temptation for this kind of unfolding. before vs after: text data bss dec hex filename 85362 12650 8 98020 17ee4 ./fs/io_uring.o 85186 12650 8 97844 17e34 ./fs/io_uring.o Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/1deea0037293a922a0358e2958384b2e42437885.1624739600.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
59b735aeeb
commit
b2d9c3da77
1 changed files with 17 additions and 22 deletions
|
@ -5172,19 +5172,29 @@ static int io_arm_poll_handler(struct io_kiocb *req)
|
|||
struct io_ring_ctx *ctx = req->ctx;
|
||||
struct async_poll *apoll;
|
||||
struct io_poll_table ipt;
|
||||
__poll_t mask, ret;
|
||||
__poll_t ret, mask = EPOLLONESHOT | POLLERR | POLLPRI;
|
||||
int rw;
|
||||
|
||||
if (!req->file || !file_can_poll(req->file))
|
||||
return IO_APOLL_ABORTED;
|
||||
if (req->flags & REQ_F_POLLED)
|
||||
return IO_APOLL_ABORTED;
|
||||
if (def->pollin)
|
||||
rw = READ;
|
||||
else if (def->pollout)
|
||||
rw = WRITE;
|
||||
else
|
||||
if (!def->pollin && !def->pollout)
|
||||
return IO_APOLL_ABORTED;
|
||||
|
||||
if (def->pollin) {
|
||||
rw = READ;
|
||||
mask |= POLLIN | POLLRDNORM;
|
||||
|
||||
/* If reading from MSG_ERRQUEUE using recvmsg, ignore POLLIN */
|
||||
if ((req->opcode == IORING_OP_RECVMSG) &&
|
||||
(req->sr_msg.msg_flags & MSG_ERRQUEUE))
|
||||
mask &= ~POLLIN;
|
||||
} else {
|
||||
rw = WRITE;
|
||||
mask |= POLLOUT | POLLWRNORM;
|
||||
}
|
||||
|
||||
/* if we can't nonblock try, then no point in arming a poll handler */
|
||||
if (!io_file_supports_async(req, rw))
|
||||
return IO_APOLL_ABORTED;
|
||||
|
@ -5193,23 +5203,8 @@ static int io_arm_poll_handler(struct io_kiocb *req)
|
|||
if (unlikely(!apoll))
|
||||
return IO_APOLL_ABORTED;
|
||||
apoll->double_poll = NULL;
|
||||
|
||||
req->flags |= REQ_F_POLLED;
|
||||
req->apoll = apoll;
|
||||
|
||||
mask = EPOLLONESHOT;
|
||||
if (def->pollin)
|
||||
mask |= POLLIN | POLLRDNORM;
|
||||
if (def->pollout)
|
||||
mask |= POLLOUT | POLLWRNORM;
|
||||
|
||||
/* If reading from MSG_ERRQUEUE using recvmsg, ignore POLLIN */
|
||||
if ((req->opcode == IORING_OP_RECVMSG) &&
|
||||
(req->sr_msg.msg_flags & MSG_ERRQUEUE))
|
||||
mask &= ~POLLIN;
|
||||
|
||||
mask |= POLLERR | POLLPRI;
|
||||
|
||||
req->flags |= REQ_F_POLLED;
|
||||
ipt.pt._qproc = io_async_queue_proc;
|
||||
|
||||
ret = __io_arm_poll_handler(req, &apoll->poll, &ipt, mask,
|
||||
|
|
Loading…
Add table
Reference in a new issue