Skip to content

Commit c66ae3e

Browse files
isilenceaxboe
authored andcommitted
io_uring: refactor __io_cq_unlock_post_flush()
Separate ->task_complete path in __io_cq_unlock_post_flush(). Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/baa9b8d822f024e4ee01c40209dbbe38d9c8c11d.1680782017.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8751d15 commit c66ae3e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

io_uring/io_uring.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -627,21 +627,23 @@ static inline void __io_cq_unlock_post(struct io_ring_ctx *ctx)
627627
io_cqring_wake(ctx);
628628
}
629629

630-
static inline void __io_cq_unlock_post_flush(struct io_ring_ctx *ctx)
630+
static void __io_cq_unlock_post_flush(struct io_ring_ctx *ctx)
631631
__releases(ctx->completion_lock)
632632
{
633633
io_commit_cqring(ctx);
634-
__io_cq_unlock(ctx);
635-
io_commit_cqring_flush(ctx);
636634

637-
/*
638-
* As ->task_complete implies that the ring is single tasked, cq_wait
639-
* may only be waited on by the current in io_cqring_wait(), but since
640-
* it will re-check the wakeup conditions once we return we can safely
641-
* skip waking it up.
642-
*/
643-
if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN))
635+
if (ctx->task_complete) {
636+
/*
637+
* ->task_complete implies that only current might be waiting
638+
* for CQEs, and obviously, we currently don't. No one is
639+
* waiting, wakeups are futile, skip them.
640+
*/
641+
io_commit_cqring_flush(ctx);
642+
} else {
643+
__io_cq_unlock(ctx);
644+
io_commit_cqring_flush(ctx);
644645
io_cqring_wake(ctx);
646+
}
645647
}
646648

647649
void io_cq_unlock_post(struct io_ring_ctx *ctx)

0 commit comments

Comments
 (0)