Skip to content

Commit e0b23d9

Browse files
isilenceaxboe
authored andcommitted
io_uring: optimise ltimeout for inline execution
At one point in time we had an optimisation that would not spin up a linked timeout timer when the master request successfully completes inline (during the first nowait execution attempt). We somehow lost it, so this patch restores it back. Note, that it's fine using io_arm_ltimeout() after the io_issue_sqe() completes the request because of delayed completion, but that that adds unwanted overhead. Reported-by: Christian Mazakas <christian.mazakas@gmail.com> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/8bf69c2a4beec14c565c85c86edb871ca8b8bcc8.1701390926.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9b43ef3 commit e0b23d9

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

io_uring/io_uring.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,14 +1902,15 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
19021902
return 0;
19031903
}
19041904

1905-
if (ret != IOU_ISSUE_SKIP_COMPLETE)
1906-
return ret;
1907-
1908-
/* If the op doesn't have a file, we're not polling for it */
1909-
if ((req->ctx->flags & IORING_SETUP_IOPOLL) && def->iopoll_queue)
1910-
io_iopoll_req_issued(req, issue_flags);
1905+
if (ret == IOU_ISSUE_SKIP_COMPLETE) {
1906+
ret = 0;
1907+
io_arm_ltimeout(req);
19111908

1912-
return 0;
1909+
/* If the op doesn't have a file, we're not polling for it */
1910+
if ((req->ctx->flags & IORING_SETUP_IOPOLL) && def->iopoll_queue)
1911+
io_iopoll_req_issued(req, issue_flags);
1912+
}
1913+
return ret;
19131914
}
19141915

19151916
int io_poll_issue(struct io_kiocb *req, struct io_tw_state *ts)
@@ -2080,9 +2081,7 @@ static inline void io_queue_sqe(struct io_kiocb *req)
20802081
* We async punt it if the file wasn't marked NOWAIT, or if the file
20812082
* doesn't support non-blocking read/write attempts
20822083
*/
2083-
if (likely(!ret))
2084-
io_arm_ltimeout(req);
2085-
else
2084+
if (unlikely(ret))
20862085
io_queue_async(req, ret);
20872086
}
20882087

0 commit comments

Comments
 (0)