Skip to content

Commit 12521a5

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix CQ waiting timeout handling
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: [email protected] Fixes: 2283396 ("io_uring: don't convert to jiffies for waiting on timeouts") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/f7bffddd71b08f28a877d44d37ac953ddb01590d.1672915663.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 59b745b commit 12521a5

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
@@ -2470,7 +2470,7 @@ int io_run_task_work_sig(struct io_ring_ctx *ctx)
24702470
/* when returns >0, the caller should retry */
24712471
static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
24722472
struct io_wait_queue *iowq,
2473-
ktime_t timeout)
2473+
ktime_t *timeout)
24742474
{
24752475
int ret;
24762476
unsigned long check_cq;
@@ -2488,7 +2488,7 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx,
24882488
if (check_cq & BIT(IO_CHECK_CQ_DROPPED_BIT))
24892489
return -EBADR;
24902490
}
2491-
if (!schedule_hrtimeout(&timeout, HRTIMER_MODE_ABS))
2491+
if (!schedule_hrtimeout(timeout, HRTIMER_MODE_ABS))
24922492
return -ETIME;
24932493

24942494
/*
@@ -2564,7 +2564,7 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
25642564
}
25652565
prepare_to_wait_exclusive(&ctx->cq_wait, &iowq.wq,
25662566
TASK_INTERRUPTIBLE);
2567-
ret = io_cqring_wait_schedule(ctx, &iowq, timeout);
2567+
ret = io_cqring_wait_schedule(ctx, &iowq, &timeout);
25682568
if (__io_cqring_events_user(ctx) >= min_events)
25692569
break;
25702570
cond_resched();

0 commit comments

Comments
 (0)