Skip to content

Commit 3afcb3b

Browse files
isilenceaxboe
authored andcommitted
io_uring: defer iowq cqe overflow via task_work
Don't handle CQE overflows in io_req_complete_post() and defer it to flush_completions. It cuts some duplication, and I also want to limit the number of places directly overflowing completions. Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/9046410ac27e18f2baa6f7cdb363ec921cbc3b79.1742829388.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 3f0cb8d commit 3afcb3b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

io_uring/io_uring.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,7 @@ bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags)
892892
static void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
893893
{
894894
struct io_ring_ctx *ctx = req->ctx;
895+
bool completed = true;
895896

896897
/*
897898
* All execution paths but io-wq use the deferred completions by
@@ -905,18 +906,20 @@ static void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
905906
* the submitter task context, IOPOLL protects with uring_lock.
906907
*/
907908
if (ctx->lockless_cq || (req->flags & REQ_F_REISSUE)) {
909+
defer_complete:
908910
req->io_task_work.func = io_req_task_complete;
909911
io_req_task_work_add(req);
910912
return;
911913
}
912914

913915
io_cq_lock(ctx);
914-
if (!(req->flags & REQ_F_CQE_SKIP)) {
915-
if (!io_fill_cqe_req(ctx, req))
916-
io_req_cqe_overflow(req);
917-
}
916+
if (!(req->flags & REQ_F_CQE_SKIP))
917+
completed = io_fill_cqe_req(ctx, req);
918918
io_cq_unlock_post(ctx);
919919

920+
if (!completed)
921+
goto defer_complete;
922+
920923
/*
921924
* We don't free the request here because we know it's called from
922925
* io-wq only, which holds a reference, so it cannot be the last put.

0 commit comments

Comments
 (0)