summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-12-16 01:08:49 +0300
committerJens Axboe <axboe@kernel.dk>2021-12-28 20:51:15 +0300
commiteb0089d629ba413ebf820733ad11b4b2bed45514 (patch)
tree873f92c415984cd4be1ca8c0de5e441d10ce3129 /fs/io_uring.c
parentaa43477b040251f451db0d844073ac00a8ab66ee (diff)
downloadlinux-eb0089d629ba413ebf820733ad11b4b2bed45514.tar.xz
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 <asml.silence@gmail.com> Link: https://lore.kernel.org/r/ee170a344a18c9ef36b554d806c64caadfd61c31.1639605189.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index a36eb6060e7e..206066b59b62 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5568,8 +5568,14 @@ static int io_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
if (mask && !(mask & poll->events))
return 0;
- if (io_poll_get_ownership(req))
+ if (io_poll_get_ownership(req)) {
+ /* optional, saves extra locking for removal in tw handler */
+ if (mask && poll->events & EPOLLONESHOT) {
+ list_del_init(&poll->wait.entry);
+ poll->head = NULL;
+ }
__io_poll_execute(req, mask);
+ }
return 1;
}