Skip to content

Commit 4693014

Browse files
isilenceaxboe
authored andcommitted
io_uring: consolidate *_check_overflow accounting
Add a helper to mark ctx->{cq,sq}_check_overflow to get rid of duplicates, and it's clearer to check cq_overflow_list directly anyway. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent dd9dfcd commit 4693014

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

fs/io_uring.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,15 @@ static void io_cqring_ev_posted(struct io_ring_ctx *ctx)
13031303
eventfd_signal(ctx->cq_ev_fd, 1);
13041304
}
13051305

1306+
static void io_cqring_mark_overflow(struct io_ring_ctx *ctx)
1307+
{
1308+
if (list_empty(&ctx->cq_overflow_list)) {
1309+
clear_bit(0, &ctx->sq_check_overflow);
1310+
clear_bit(0, &ctx->cq_check_overflow);
1311+
ctx->rings->sq_flags &= ~IORING_SQ_CQ_OVERFLOW;
1312+
}
1313+
}
1314+
13061315
/* Returns true if there are no backlogged entries after the flush */
13071316
static bool io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force)
13081317
{
@@ -1347,11 +1356,8 @@ static bool io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force)
13471356
}
13481357

13491358
io_commit_cqring(ctx);
1350-
if (cqe) {
1351-
clear_bit(0, &ctx->sq_check_overflow);
1352-
clear_bit(0, &ctx->cq_check_overflow);
1353-
ctx->rings->sq_flags &= ~IORING_SQ_CQ_OVERFLOW;
1354-
}
1359+
io_cqring_mark_overflow(ctx);
1360+
13551361
spin_unlock_irqrestore(&ctx->completion_lock, flags);
13561362
io_cqring_ev_posted(ctx);
13571363

@@ -7842,11 +7848,8 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
78427848
spin_lock_irq(&ctx->completion_lock);
78437849
list_del(&cancel_req->compl.list);
78447850
cancel_req->flags &= ~REQ_F_OVERFLOW;
7845-
if (list_empty(&ctx->cq_overflow_list)) {
7846-
clear_bit(0, &ctx->sq_check_overflow);
7847-
clear_bit(0, &ctx->cq_check_overflow);
7848-
ctx->rings->sq_flags &= ~IORING_SQ_CQ_OVERFLOW;
7849-
}
7851+
7852+
io_cqring_mark_overflow(ctx);
78507853
WRITE_ONCE(ctx->rings->cq_overflow,
78517854
atomic_inc_return(&ctx->cached_cq_overflow));
78527855
io_commit_cqring(ctx);

0 commit comments

Comments
 (0)