fs/io_uring: Prioritise checking faster conditions first in io_write

This commit reorders the conditions in a branch in io_write. The
reorder to check 'ret2 == -EAGAIN' first as checking
'(req->ctx->flags & IORING_SETUP_IOPOLL)' will likely be more
expensive due to 2x memory derefences.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Link: https://lore.kernel.org/r/20211017013229.4124279-1-goldstein.w.n@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Noah Goldstein 2021-10-16 20:32:29 -05:00 committed by Jens Axboe
parent 5cb03d6342
commit b10841c98c

View File

@ -3654,7 +3654,7 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
goto done; goto done;
if (!force_nonblock || ret2 != -EAGAIN) { if (!force_nonblock || ret2 != -EAGAIN) {
/* IOPOLL retry should happen for io-wq threads */ /* IOPOLL retry should happen for io-wq threads */
if ((req->ctx->flags & IORING_SETUP_IOPOLL) && ret2 == -EAGAIN) if (ret2 == -EAGAIN && (req->ctx->flags & IORING_SETUP_IOPOLL))
goto copy_iov; goto copy_iov;
done: done:
kiocb_done(kiocb, ret2, issue_flags); kiocb_done(kiocb, ret2, issue_flags);