Skip to contentSkip to conversation

fs/io_uring: Prioritise checking faster conditions first in io_write

PATCH Applied Noah Goldstein 2 participants 2 messages Oct 17, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
index 6b9e70208782..321de7ddf2cf 100644
@@ -3660,7 +3660,7 @@ static int io_write(struct io_kiocb *req, unsigned int issue_flags)
 		goto done;
 	if (!force_nonblock || ret2 != -EAGAIN) {
 		/* 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;
 done:
 		kiocb_done(kiocb, ret2, issue_flags);
Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 6 lines · Noah Goldstein

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.

Applied, thanks!

[1/1] fs/io_uring: Prioritise checking faster conditions first in io_write

      commit: 02a8286be94bb1fce86afa6b487717eb4ca2956e

Best regards,

Signature · 1 line
Jens Axboe