Skip to content

Commit 52dd864

Browse files
Dylan Yudakenaxboe
authored andcommitted
io_uring: enable EPOLLEXCLUSIVE for accept poll
When polling sockets for accept, use EPOLLEXCLUSIVE. This is helpful when multiple accept SQEs are submitted. For O_NONBLOCK sockets multiple queued SQEs would previously have all completed at once, but most with -EAGAIN as the result. Now only one wakes up and completes. For sockets without O_NONBLOCK there is no user facing change, but internally the extra requests would previously be queued onto a worker thread as they would wake up with no connection waiting, and be punted. Now they do not wake up unnecessarily. Co-developed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Dylan Yudaken <dylany@fb.com> Link: https://lore.kernel.org/r/20220325093755.4123343-1-dylany@fb.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 34d2bfe commit 52dd864

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

fs/io_uring.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ struct io_op_def {
967967
/* set if opcode supports polled "wait" */
968968
unsigned pollin : 1;
969969
unsigned pollout : 1;
970+
unsigned poll_exclusive : 1;
970971
/* op supports buffer selection */
971972
unsigned buffer_select : 1;
972973
/* do prep async if is going to be punted */
@@ -1061,6 +1062,7 @@ static const struct io_op_def io_op_defs[] = {
10611062
.needs_file = 1,
10621063
.unbound_nonreg_file = 1,
10631064
.pollin = 1,
1065+
.poll_exclusive = 1,
10641066
},
10651067
[IORING_OP_ASYNC_CANCEL] = {
10661068
.audit_skip = 1,
@@ -6280,7 +6282,8 @@ static int io_arm_poll_handler(struct io_kiocb *req, unsigned issue_flags)
62806282
} else {
62816283
mask |= POLLOUT | POLLWRNORM;
62826284
}
6283-
6285+
if (def->poll_exclusive)
6286+
mask |= EPOLLEXCLUSIVE;
62846287
if (!(issue_flags & IO_URING_F_UNLOCKED) &&
62856288
!list_empty(&ctx->apoll_cache)) {
62866289
apoll = list_first_entry(&ctx->apoll_cache, struct async_poll,

0 commit comments

Comments
 (0)