summaryrefslogtreecommitdiff
path: root/io_uring/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-04-24 12:28:39 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-05-29 11:02:01 +0200
commit218c838d0356a4305a5705fa4599b682d6312144 (patch)
tree7583876f660720fb0803c2fc3aad3f38c69ca571 /io_uring/io_uring.c
parent64f505b08e0cfd8163491c8c082d4f47a88e51d4 (diff)
downloadlinux-218c838d0356a4305a5705fa4599b682d6312144.tar.gz
linux-218c838d0356a4305a5705fa4599b682d6312144.tar.bz2
linux-218c838d0356a4305a5705fa4599b682d6312144.zip
io_uring: don't duplicate flushing in io_req_post_cqe
[ Upstream commit 5e16f1a68d28965c12b6fa227a306fef8a680f84 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'io_uring/io_uring.c')
-rw-r--r--io_uring/io_uring.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 8ef0603c07f1..985c87ea09a9 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -874,10 +874,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;
}