]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
io_uring: don't duplicate flushing in io_req_post_cqe
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 24 Apr 2025 11:28:39 +0000 (12:28 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 24 Apr 2025 12:28:43 +0000 (06:28 -0600)
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>
io_uring/io_uring.c

index c6209fe44cb175c02687d6b734542c4aacf74d16..eedb47c8c79e0a963023f5135668f874285838c5 100644 (file)
@@ -872,10 +872,15 @@ bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags)
        lockdep_assert(!io_wq_current_is_worker());
        lockdep_assert_held(&ctx->uring_lock);
 
-       __io_cq_lock(ctx);
-       posted = io_fill_cqe_aux(ctx, req->cqe.user_data, res, cflags);
+       if (!ctx->lockless_cq) {
+               spin_lock(&ctx->completion_lock);
+               posted = io_fill_cqe_aux(ctx, req->cqe.user_data, res, cflags);
+               spin_unlock(&ctx->completion_lock);
+       } else {
+               posted = io_fill_cqe_aux(ctx, req->cqe.user_data, res, cflags);
+       }
+
        ctx->submit_state.cq_flush = true;
-       __io_cq_unlock_post(ctx);
        return posted;
 }