Commit 0aa7aa5f authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: move multishot cqe cache in ctx

We cache multishot CQEs before flushing them to the CQ in
submit_state.cqe. It's a 16 entry cache totalling 256 bytes in the
middle of the io_submit_state structure. Move it out of there, it
should help with CPU caches for the submission state, and shouldn't
affect cached CQEs.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/dbe1f39c043ee23da918836be44fcec252ce6711.1692916914.git.asml.silence@gmail.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c9def23d
...@@ -176,7 +176,6 @@ struct io_submit_state { ...@@ -176,7 +176,6 @@ struct io_submit_state {
unsigned short submit_nr; unsigned short submit_nr;
unsigned int cqes_count; unsigned int cqes_count;
struct blk_plug plug; struct blk_plug plug;
struct io_uring_cqe cqes[16];
}; };
struct io_ev_fd { struct io_ev_fd {
...@@ -307,6 +306,8 @@ struct io_ring_ctx { ...@@ -307,6 +306,8 @@ struct io_ring_ctx {
unsigned cq_last_tm_flush; unsigned cq_last_tm_flush;
} ____cacheline_aligned_in_smp; } ____cacheline_aligned_in_smp;
struct io_uring_cqe completion_cqes[16];
/* IRQ completion list, under ->completion_lock */ /* IRQ completion list, under ->completion_lock */
struct io_wq_work_list locked_free_list; struct io_wq_work_list locked_free_list;
unsigned int locked_free_nr; unsigned int locked_free_nr;
......
...@@ -880,7 +880,7 @@ static void __io_flush_post_cqes(struct io_ring_ctx *ctx) ...@@ -880,7 +880,7 @@ static void __io_flush_post_cqes(struct io_ring_ctx *ctx)
lockdep_assert_held(&ctx->uring_lock); lockdep_assert_held(&ctx->uring_lock);
for (i = 0; i < state->cqes_count; i++) { for (i = 0; i < state->cqes_count; i++) {
struct io_uring_cqe *cqe = &state->cqes[i]; struct io_uring_cqe *cqe = &ctx->completion_cqes[i];
if (!io_fill_cqe_aux(ctx, cqe->user_data, cqe->res, cqe->flags)) { if (!io_fill_cqe_aux(ctx, cqe->user_data, cqe->res, cqe->flags)) {
if (ctx->task_complete) { if (ctx->task_complete) {
...@@ -931,7 +931,7 @@ bool io_fill_cqe_req_aux(struct io_kiocb *req, bool defer, s32 res, u32 cflags) ...@@ -931,7 +931,7 @@ bool io_fill_cqe_req_aux(struct io_kiocb *req, bool defer, s32 res, u32 cflags)
lockdep_assert_held(&ctx->uring_lock); lockdep_assert_held(&ctx->uring_lock);
if (ctx->submit_state.cqes_count == ARRAY_SIZE(ctx->submit_state.cqes)) { if (ctx->submit_state.cqes_count == ARRAY_SIZE(ctx->completion_cqes)) {
__io_cq_lock(ctx); __io_cq_lock(ctx);
__io_flush_post_cqes(ctx); __io_flush_post_cqes(ctx);
/* no need to flush - flush is deferred */ /* no need to flush - flush is deferred */
...@@ -945,7 +945,7 @@ bool io_fill_cqe_req_aux(struct io_kiocb *req, bool defer, s32 res, u32 cflags) ...@@ -945,7 +945,7 @@ bool io_fill_cqe_req_aux(struct io_kiocb *req, bool defer, s32 res, u32 cflags)
if (test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq)) if (test_bit(IO_CHECK_CQ_OVERFLOW_BIT, &ctx->check_cq))
return false; return false;
cqe = &ctx->submit_state.cqes[ctx->submit_state.cqes_count++]; cqe = &ctx->completion_cqes[ctx->submit_state.cqes_count++];
cqe->user_data = user_data; cqe->user_data = user_data;
cqe->res = res; cqe->res = res;
cqe->flags = cflags; cqe->flags = cflags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment