public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCH 6/7] io_uring: single shot poll removal optimisation
Date: Wed, 15 Dec 2021 22:08:49 +0000	[thread overview]
Message-ID: <ee170a344a18c9ef36b554d806c64caadfd61c31.1639605189.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

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]>
---
 fs/io_uring.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index d59d3fa93c9c..20feca3d86ae 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;
 }
 
-- 
2.34.0


  parent reply	other threads:[~2021-12-15 22:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15 22:08 [PATCH for-next 0/7] reworking io_uring's poll and internal poll Pavel Begunkov
2021-12-15 22:08 ` [PATCH 1/7] io_uring: remove double poll on poll update Pavel Begunkov
2021-12-15 22:08 ` [PATCH 2/7] io_uring: refactor " Pavel Begunkov
2021-12-15 22:08 ` [PATCH 3/7] io_uring: move common poll bits Pavel Begunkov
2021-12-15 22:08 ` [PATCH 4/7] io_uring: kill poll linking optimisation Pavel Begunkov
2021-12-15 22:08 ` [PATCH 5/7] io_uring: poll rework Pavel Begunkov
2021-12-15 22:08 ` Pavel Begunkov [this message]
2021-12-15 22:08 ` [PATCH 7/7] io_uring: use completion batching for poll rem/upd Pavel Begunkov
2021-12-17 15:02 ` [PATCH for-next 0/7] reworking io_uring's poll and internal poll Hao Xu
2021-12-17 19:40   ` Pavel Begunkov
2021-12-28 17:51 ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee170a344a18c9ef36b554d806c64caadfd61c31.1639605189.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox