Commit 60053be8 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: remove extra ifs around io_commit_cqring

Now io_commit_cqring() is simple and it tolerates well being called
without a new CQE filled, so kill a bunch of not needed anymore
guards.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/36aed692dff402bba00a444a63a9cd2e97a340ea.1647897811.git.asml.silence@gmail.com
[axboe: fold in followup fix]
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 68ca8fc0
...@@ -1920,8 +1920,7 @@ static bool __io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force) ...@@ -1920,8 +1920,7 @@ static bool __io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force)
ctx->rings->sq_flags & ~IORING_SQ_CQ_OVERFLOW); ctx->rings->sq_flags & ~IORING_SQ_CQ_OVERFLOW);
} }
if (posted) io_commit_cqring(ctx);
io_commit_cqring(ctx);
spin_unlock(&ctx->completion_lock); spin_unlock(&ctx->completion_lock);
if (posted) if (posted)
io_cqring_ev_posted(ctx); io_cqring_ev_posted(ctx);
...@@ -2361,8 +2360,7 @@ static void __io_req_find_next_prep(struct io_kiocb *req) ...@@ -2361,8 +2360,7 @@ static void __io_req_find_next_prep(struct io_kiocb *req)
spin_lock(&ctx->completion_lock); spin_lock(&ctx->completion_lock);
posted = io_disarm_next(req); posted = io_disarm_next(req);
if (posted) io_commit_cqring(ctx);
io_commit_cqring(ctx);
spin_unlock(&ctx->completion_lock); spin_unlock(&ctx->completion_lock);
if (posted) if (posted)
io_cqring_ev_posted(ctx); io_cqring_ev_posted(ctx);
...@@ -10128,8 +10126,7 @@ static __cold bool io_kill_timeouts(struct io_ring_ctx *ctx, ...@@ -10128,8 +10126,7 @@ static __cold bool io_kill_timeouts(struct io_ring_ctx *ctx,
} }
} }
spin_unlock_irq(&ctx->timeout_lock); spin_unlock_irq(&ctx->timeout_lock);
if (canceled != 0) io_commit_cqring(ctx);
io_commit_cqring(ctx);
spin_unlock(&ctx->completion_lock); spin_unlock(&ctx->completion_lock);
if (canceled != 0) if (canceled != 0)
io_cqring_ev_posted(ctx); io_cqring_ev_posted(ctx);
...@@ -10149,11 +10146,13 @@ static __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx) ...@@ -10149,11 +10146,13 @@ static __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
io_unregister_personality(ctx, index); io_unregister_personality(ctx, index);
mutex_unlock(&ctx->uring_lock); mutex_unlock(&ctx->uring_lock);
io_kill_timeouts(ctx, NULL, true); /* failed during ring init, it couldn't have issued any requests */
io_poll_remove_all(ctx, NULL, true); if (ctx->rings) {
io_kill_timeouts(ctx, NULL, true);
/* if we failed setting up the ctx, we might not have any rings */ io_poll_remove_all(ctx, NULL, true);
io_iopoll_try_reap_events(ctx); /* if we failed setting up the ctx, we might not have any rings */
io_iopoll_try_reap_events(ctx);
}
INIT_WORK(&ctx->exit_work, io_ring_exit_work); INIT_WORK(&ctx->exit_work, io_ring_exit_work);
/* /*
...@@ -10245,6 +10244,10 @@ static __cold void io_uring_try_cancel_requests(struct io_ring_ctx *ctx, ...@@ -10245,6 +10244,10 @@ static __cold void io_uring_try_cancel_requests(struct io_ring_ctx *ctx,
struct io_task_cancel cancel = { .task = task, .all = cancel_all, }; struct io_task_cancel cancel = { .task = task, .all = cancel_all, };
struct io_uring_task *tctx = task ? task->io_uring : NULL; struct io_uring_task *tctx = task ? task->io_uring : NULL;
/* failed during ring init, it couldn't have issued any requests */
if (!ctx->rings)
return;
while (1) { while (1) {
enum io_wq_cancel cret; enum io_wq_cancel cret;
bool ret = false; bool ret = false;
......
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