Commit 6805b32e authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: remove wait loop spurious wakeups

Any changes interesting to tasks waiting in io_cqring_wait() are
commited with io_cqring_ev_posted(). However, io_ring_drop_ctx_refs()
also tries to do that but with no reason, that means spurious wakeups
every io_free_req() and io_uring_enter().

Just use percpu_ref_put() instead.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent b84477d3
...@@ -591,14 +591,6 @@ static void io_cqring_add_event(struct io_ring_ctx *ctx, u64 user_data, ...@@ -591,14 +591,6 @@ static void io_cqring_add_event(struct io_ring_ctx *ctx, u64 user_data,
io_cqring_ev_posted(ctx); io_cqring_ev_posted(ctx);
} }
static void io_ring_drop_ctx_refs(struct io_ring_ctx *ctx, unsigned refs)
{
percpu_ref_put_many(&ctx->refs, refs);
if (waitqueue_active(&ctx->wait))
wake_up(&ctx->wait);
}
static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx, static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx,
struct io_submit_state *state) struct io_submit_state *state)
{ {
...@@ -646,7 +638,7 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx, ...@@ -646,7 +638,7 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx,
req->result = 0; req->result = 0;
return req; return req;
out: out:
io_ring_drop_ctx_refs(ctx, 1); percpu_ref_put(&ctx->refs);
return NULL; return NULL;
} }
...@@ -654,7 +646,7 @@ static void io_free_req_many(struct io_ring_ctx *ctx, void **reqs, int *nr) ...@@ -654,7 +646,7 @@ static void io_free_req_many(struct io_ring_ctx *ctx, void **reqs, int *nr)
{ {
if (*nr) { if (*nr) {
kmem_cache_free_bulk(req_cachep, *nr, reqs); kmem_cache_free_bulk(req_cachep, *nr, reqs);
io_ring_drop_ctx_refs(ctx, *nr); percpu_ref_put_many(&ctx->refs, *nr);
*nr = 0; *nr = 0;
} }
} }
...@@ -663,7 +655,7 @@ static void __io_free_req(struct io_kiocb *req) ...@@ -663,7 +655,7 @@ static void __io_free_req(struct io_kiocb *req)
{ {
if (req->file && !(req->flags & REQ_F_FIXED_FILE)) if (req->file && !(req->flags & REQ_F_FIXED_FILE))
fput(req->file); fput(req->file);
io_ring_drop_ctx_refs(req->ctx, 1); percpu_ref_put(&req->ctx->refs);
kmem_cache_free(req_cachep, req); kmem_cache_free(req_cachep, req);
} }
...@@ -3584,7 +3576,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit, ...@@ -3584,7 +3576,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
} }
} }
io_ring_drop_ctx_refs(ctx, 1); percpu_ref_put(&ctx->refs);
out_fput: out_fput:
fdput(f); fdput(f);
return submitted ? submitted : ret; return submitted ? submitted : ret;
......
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