Skip to content

Commit c3222fd

Browse files
isilencegregkh
authored andcommitted
io_uring: fix CQ waiting timeout handling
commit 12521a5 upstream. Jiffy to ktime CQ waiting conversion broke how we treat timeouts, in particular we rearm it anew every time we get into io_cqring_wait_schedule() without adjusting the timeout. Waiting for 2 CQEs and getting a task_work in the middle may double the timeout value, or even worse in some cases task may wait indefinitely. Cc: stable@vger.kernel.org Fixes: 2283396 ("io_uring: don't convert to jiffies for waiting on timeouts") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/f7bffddd71b08f28a877d44d37ac953ddb01590d.1672915663.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b7b9bc9 commit c3222fd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

io_uring/io_uring.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7598,7 +7598,7 @@ static int io_run_task_work_sig(void)
75987598
/* when returns >0, the caller should retry */
75997599
static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
76007600
struct io_wait_queue *iowq,
7601-
ktime_t timeout)
7601+
ktime_t *timeout)
76027602
{
76037603
int ret;
76047604

@@ -7610,7 +7610,7 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
76107610
if (test_bit(0, &ctx->check_cq_overflow))
76117611
return 1;
76127612

7613-
if (!schedule_hrtimeout(&timeout, HRTIMER_MODE_ABS))
7613+
if (!schedule_hrtimeout(timeout, HRTIMER_MODE_ABS))
76147614
return -ETIME;
76157615
return 1;
76167616
}
@@ -7673,7 +7673,7 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
76737673
}
76747674
prepare_to_wait_exclusive(&ctx->cq_wait, &iowq.wq,
76757675
TASK_INTERRUPTIBLE);
7676-
ret = io_cqring_wait_schedule(ctx, &iowq, timeout);
7676+
ret = io_cqring_wait_schedule(ctx, &iowq, &timeout);
76777677
finish_wait(&ctx->cq_wait, &iowq.wq);
76787678
cond_resched();
76797679
} while (ret > 0);

0 commit comments

Comments
 (0)