Skip to content

Commit 5e16f1a

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't duplicate flushing in io_req_post_cqe
io_req_post_cqe() sets submit_state.cq_flush so that *flush_completions() can take care of batch commiting CQEs. Don't commit it twice by using __io_cq_unlock_post(). Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/41c416660c509cee676b6cad96081274bcb459f3.1745493861.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent f12ecf5 commit 5e16f1a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

io_uring/io_uring.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,15 @@ bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags)
872872
lockdep_assert(!io_wq_current_is_worker());
873873
lockdep_assert_held(&ctx->uring_lock);
874874

875-
__io_cq_lock(ctx);
876-
posted = io_fill_cqe_aux(ctx, req->cqe.user_data, res, cflags);
875+
if (!ctx->lockless_cq) {
876+
spin_lock(&ctx->completion_lock);
877+
posted = io_fill_cqe_aux(ctx, req->cqe.user_data, res, cflags);
878+
spin_unlock(&ctx->completion_lock);
879+
} else {
880+
posted = io_fill_cqe_aux(ctx, req->cqe.user_data, res, cflags);
881+
}
882+
877883
ctx->submit_state.cq_flush = true;
878-
__io_cq_unlock_post(ctx);
879884
return posted;
880885
}
881886

0 commit comments

Comments
 (0)