diff options
| author | Jens Axboe <axboe@kernel.dk> | 2026-10-15 14:18:22 -0600 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-10-15 14:26:00 -0600 |
| commit | fdfce905a58edea053ee7b68b5bd4348dd1b36e0 (patch) | |
| tree | 2bbcf08000eada9652fdf2d8b8fee92314b3ccd1 /io_uring | |
| parent | 937d38dcacd675dc0572d6c9b6743960df3128ed (diff) | |
io_uring/timeout: don't put a sequence target behind the last flush
io_timeout_fn() and io_kill_timeout() bump ->cq_timeouts when a timeout
fires, but its CQE is only posted later from task_work. Until then the
sequence io_timeout() computes is one below the last flush per fired
timeout. Now that ->cq_last_tm_flush is kept while sequence timeouts are
pending, a timeout armed in that window with a small offset gets a target
behind the base. Its distance from the base wraps, and it's never
completed by events, only by its timer. With DEFER_TASKRUN that window
is as wide as the application makes it, as submission runs before the
local task_work.
Nothing but those in flight CQEs separates the two, so use the last
flush as the base for the target when the sequence is behind it.
Fixes: c6c0b3eba88c ("io_uring/timeout: don't skip over reached sequences")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring')
| -rw-r--r-- | io_uring/timeout.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/io_uring/timeout.c b/io_uring/timeout.c index b219dfdf7af5..e52ba4ad53cb 100644 --- a/io_uring/timeout.c +++ b/io_uring/timeout.c @@ -690,7 +690,6 @@ int io_timeout(struct io_kiocb *req, unsigned int issue_flags) } tail = data_race(ctx->cached_cq_tail) - atomic_read(&ctx->cq_timeouts); - timeout->target_seq = tail + off; /* * Update the last seq here in case io_flush_timeouts() hasn't, it only @@ -705,6 +704,15 @@ int io_timeout(struct io_kiocb *req, unsigned int issue_flags) base = ctx->cq_last_tm_flush; /* + * A fired timeout bumps ->cq_timeouts before its CQE is posted, which + * leaves the sequence behind the last flush until it is. Nothing else + * separates the two then, so count from the flush. + */ + if ((s32)(tail - base) < 0) + tail = base; + timeout->target_seq = tail + off; + + /* * Insertion sort, ensuring the first entry in the list is always * the one we need first. */ |
