Skip to content

Commit

Permalink
test/timeout: modify update timeout case for PREEMPT_RT
Browse files Browse the repository at this point in the history
For some reason, on PREEMPT_RT, a just enqueued hrtimer will still
return that it's in the process of being executed and hence io_uring
will fail to extract it. Just overlook that case, by skipping the
elapsed time check if we ran into -EALREADY when attempting to
update the timer.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
axboe committed Sep 27, 2024
1 parent db4b040 commit b6658a9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ static int test_update_timeout(struct io_uring *ring, unsigned long ms,
struct io_uring_cqe *cqe;
struct __kernel_timespec ts, ts_upd;
unsigned long long exp_ms, base_ms = 10000;
bool update_ealready = false;
struct timeval tv;
int ret, i, nr = 2;
__u32 mode = abs ? IORING_TIMEOUT_ABS : 0;
Expand Down Expand Up @@ -1017,6 +1018,16 @@ static int test_update_timeout(struct io_uring *ring, unsigned long ms,
}
break;
case 2:
/*
* We should not be hitting this case, but for
* a kernel with PREEMPT_RT, even an instant attempt
* to remove a timer will return that the timer is
* already running... Deal with it.
*/
if (cqe->res == -EALREADY) {
update_ealready = true;
break;
}
if (cqe->res != 0) {
fprintf(stderr, "%s: got %d, wanted %d\n",
__FUNCTION__, cqe->res,
Expand All @@ -1037,7 +1048,7 @@ static int test_update_timeout(struct io_uring *ring, unsigned long ms,
}

exp_ms = mtime_since_now(&tv);
if (exp_ms >= base_ms / 2) {
if (!update_ealready && exp_ms >= base_ms / 2) {
fprintf(stderr, "too long, timeout wasn't updated\n");
goto err;
}
Expand Down

0 comments on commit b6658a9

Please sign in to comment.