Skip to content

Commit eb0089d

Browse files
isilenceaxboe
authored andcommitted
io_uring: single shot poll removal optimisation
We don't need to poll oneshot request if we've got a desired mask in io_poll_wake(), task_work will clean it up correctly, but as we already hold a wq spinlock, we can remove ourselves and save on additional spinlocking in io_poll_remove_entries(). Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/ee170a344a18c9ef36b554d806c64caadfd61c31.1639605189.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent aa43477 commit eb0089d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/io_uring.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5568,8 +5568,14 @@ static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
55685568
if (mask && !(mask & poll->events))
55695569
return 0;
55705570

5571-
if (io_poll_get_ownership(req))
5571+
if (io_poll_get_ownership(req)) {
5572+
/* optional, saves extra locking for removal in tw handler */
5573+
if (mask && poll->events & EPOLLONESHOT) {
5574+
list_del_init(&poll->wait.entry);
5575+
poll->head = NULL;
5576+
}
55725577
__io_poll_execute(req, mask);
5578+
}
55735579
return 1;
55745580
}
55755581

0 commit comments

Comments
 (0)