mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
io_uring/timeout: don't flush with the sequence behind the last flush
io_flush_timeouts() measures the events since the last flush as the
distance of the current sequence from ->cq_last_tm_flush. A fired
timeout bumps ->cq_timeouts before its CQE is posted, so until it is
the sequence can be behind the last flush, and the distance wraps:
last flush: seq 100, cq_last_tm_flush = 100
Y: IORING_OP_TIMEOUT, off 50, target_seq 150
pure timeout A fires, cq_timeouts = 1
task_work posts A's CQE, cached_cq_tail = 101
pure timeout B fires before the flush, cq_timeouts = 2
io_flush_timeouts(): seq = 99, events_got = 0xffffffff
Y, and every sequence timeout behind it, is ended with -ETIME although
no event happened. Two timeouts expiring close together is all it takes,
a completion with IOSQE_CQE_SKIP_SUCCESS after a single one does it too.
Nothing but those in flight CQEs separates the two, so count from the
last flush when the sequence is behind it, as io_timeout() does.
Fixes: f010505b78 ("io_uring: flush timeouts that should already have expired")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
fdfce905a5
commit
85f85d573f
|
|
@ -171,6 +171,14 @@ __cold void io_flush_timeouts(struct io_ring_ctx *ctx)
|
|||
raw_spin_lock_irq(&ctx->timeout_lock);
|
||||
seq = READ_ONCE(ctx->cached_cq_tail) - atomic_read(&ctx->cq_timeouts);
|
||||
|
||||
/*
|
||||
* A fired timeout bumps ->cq_timeouts before its CQE is posted, which
|
||||
* leaves the sequence behind the last flush until it is. No event has
|
||||
* happened then, see io_timeout().
|
||||
*/
|
||||
if ((s32)(seq - ctx->cq_last_tm_flush) < 0)
|
||||
seq = ctx->cq_last_tm_flush;
|
||||
|
||||
list_for_each_entry_safe(timeout, tmp, &ctx->timeout_list, list) {
|
||||
struct io_kiocb *req = cmd_to_io_kiocb(timeout);
|
||||
u32 events_needed, events_got;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user