From: Noah Goldstein <[email protected]>
To: unlisted-recipients:; (no To-header on input)
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected]
Subject: [PATCH v2] fs/io_uring: Hoist ret2 == -EAGAIN check in tail of io_write
Date: Mon, 18 Oct 2021 10:56:13 -0400 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
This commit reorganizes the branches in the tail of io_write so that
the 'ret2 == -EAGAIN' check is not repeated and done first.
The previous version was duplicating the 'ret2 == -EAGAIN'. As well
'ret2 != -EAGAIN' gurantees the 'done:' path so it makes sense to
move that check to the front before the likely more expensive branches
which require memory derefences.
Signed-off-by: Noah Goldstein <[email protected]>
---
fs/io_uring.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index d1e672e7a2d1..18293407e8bc 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3648,21 +3648,19 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
*/
if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))
ret2 = -EAGAIN;
- /* no retry on NONBLOCK nor RWF_NOWAIT */
- if (ret2 == -EAGAIN && (req->flags & REQ_F_NOWAIT))
- goto done;
- if (!force_nonblock || ret2 != -EAGAIN) {
- /* IOPOLL retry should happen for io-wq threads */
- if (ret2 == -EAGAIN && (req->ctx->flags & IORING_SETUP_IOPOLL))
- goto copy_iov;
-done:
+
+ if (ret2 != -EAGAIN ||
+ /* no retry on NONBLOCK nor RWF_NOWAIT */
+ (req->flags & REQ_F_NOWAIT)
+ /* IOPOLL retry should happen for io-wq threads */
+ || (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL))) {
kiocb_done(kiocb, ret2, issue_flags);
} else {
copy_iov:
iov_iter_restore(&s->iter, &s->iter_state);
ret = io_setup_async_rw(req, iovec, s, false);
return ret ?: -EAGAIN;
- }
+}
out_free:
/* it's reportedly faster than delegating the null check to kfree() */
if (iovec)
--
2.29.2
prev parent reply other threads:[~2021-10-18 14:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 7:02 [PATCH v1] fs/io_uring: Hoist ret2 == -EAGAIN check in tail of io_write Noah Goldstein
2021-10-18 12:17 ` Hao Xu
2021-10-18 14:56 ` Noah Goldstein [this message]
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 \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[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