io_uring/timeout: account for timeouts whose CQE is not posted yet
PATCH 1/1 io_uring/timeout: account for timeouts whose CQE is not posted yet
The sequence of non-timeout CQEs is derived from ->cached_cq_tail minus ->cq_timeouts, but a timeout bumps the latter when it fires, is killed or is cancelled, which is ahead of its CQE being posted. Reading the sequence in between comes out low, and a target counted from such a reading is reached that much early: a counted timeout completes with 0 while nothing but the already posted CQEs has happened, and it can also be satisfied by timeouts posted before it was armed. Keep track of the timeouts whose CQE is still in flight and add them back, so that the sequence is exact whenever it is read.
Fixes c6c0b3eba88c ("io_uring/timeout: don't skip over reached sequences")
Signed-off-by Yichong Chen <[email protected]>
--- include/linux/io_uring_types.h | 1 + io_uring/timeout.c | 53 ++++++++++++++++++++++++++++++------------ 2 files changed, 39 insertions(+), 15 deletions(-)
include/linux/io_uring_types.h +1 -0
@@ -457,6 +457,7 @@ struct io_ring_ctx {unsigned long check_cq;atomic_t cq_wait_nr;atomic_t cq_timeouts; +atomic_t cq_timeouts_pending;struct wait_queue_head cq_wait; }____cacheline_aligned_in_smp ;
io_uring/timeout.c +38 -15
118 lines not on this page · raw message