Skip to content

Commit 6805b32

Browse files
isilenceaxboe
authored andcommitted
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: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent b84477d commit 6805b32

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

fs/io_uring.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -591,14 +591,6 @@ static void io_cqring_add_event(struct io_ring_ctx *ctx, u64 user_data,
591591
io_cqring_ev_posted(ctx);
592592
}
593593

594-
static void io_ring_drop_ctx_refs(struct io_ring_ctx *ctx, unsigned refs)
595-
{
596-
percpu_ref_put_many(&ctx->refs, refs);
597-
598-
if (waitqueue_active(&ctx->wait))
599-
wake_up(&ctx->wait);
600-
}
601-
602594
static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx,
603595
struct io_submit_state *state)
604596
{
@@ -646,15 +638,15 @@ static struct io_kiocb *io_get_req(struct io_ring_ctx *ctx,
646638
req->result = 0;
647639
return req;
648640
out:
649-
io_ring_drop_ctx_refs(ctx, 1);
641+
percpu_ref_put(&ctx->refs);
650642
return NULL;
651643
}
652644

653645
static void io_free_req_many(struct io_ring_ctx *ctx, void **reqs, int *nr)
654646
{
655647
if (*nr) {
656648
kmem_cache_free_bulk(req_cachep, *nr, reqs);
657-
io_ring_drop_ctx_refs(ctx, *nr);
649+
percpu_ref_put_many(&ctx->refs, *nr);
658650
*nr = 0;
659651
}
660652
}
@@ -663,7 +655,7 @@ static void __io_free_req(struct io_kiocb *req)
663655
{
664656
if (req->file && !(req->flags & REQ_F_FIXED_FILE))
665657
fput(req->file);
666-
io_ring_drop_ctx_refs(req->ctx, 1);
658+
percpu_ref_put(&req->ctx->refs);
667659
kmem_cache_free(req_cachep, req);
668660
}
669661

@@ -3584,7 +3576,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
35843576
}
35853577
}
35863578

3587-
io_ring_drop_ctx_refs(ctx, 1);
3579+
percpu_ref_put(&ctx->refs);
35883580
out_fput:
35893581
fdput(f);
35903582
return submitted ? submitted : ret;

0 commit comments

Comments
 (0)