summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-10-03 12:11:00 +0100
committerJens Axboe <axboe@kernel.dk>2021-10-03 07:06:49 -0600
commitf5b052a4f57d740258690cf77f99ea08225e12c4 (patch)
tree7a70e05f985ec0735b756c14ec4daea267c53c38
parenta987d7031d95d88f0fdb0301cd5187c5bf3fb889 (diff)
downloadliburing-f5b052a4f57d740258690cf77f99ea08225e12c4.tar.gz
liburing-f5b052a4f57d740258690cf77f99ea08225e12c4.tar.bz2
io_uring: fix SQPOLL timeout-new test
Happens pretty rarely, but there were cases when CQE waitinig in test_return_before_timeout() time outs before the SQPOLL thread kicks in and executes submitted requests, give SQPOLL a little bit more time. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/5faf8ade7e161931d76a47b809650e68a1b361ba.1633259449.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/timeout-new.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/test/timeout-new.c b/test/timeout-new.c
index 19c5ac3..6efcfb4 100644
--- a/test/timeout-new.c
+++ b/test/timeout-new.c
@@ -53,14 +53,12 @@ static int test_return_before_timeout(struct io_uring *ring)
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
int ret;
+ bool retried = false;
struct __kernel_timespec ts;
- sqe = io_uring_get_sqe(ring);
- if (!sqe) {
- fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
- return 1;
- }
+ msec_to_ts(&ts, TIMEOUT_MSEC);
+ sqe = io_uring_get_sqe(ring);
io_uring_prep_nop(sqe);
ret = io_uring_submit(ring);
@@ -69,13 +67,21 @@ static int test_return_before_timeout(struct io_uring *ring)
return 1;
}
- msec_to_ts(&ts, TIMEOUT_MSEC);
+again:
ret = io_uring_wait_cqe_timeout(ring, &cqe, &ts);
- if (ret < 0) {
+ if (ret == -ETIME && (ring->flags & IORING_SETUP_SQPOLL) && !retried) {
+ /*
+ * there is a small chance SQPOLL hasn't been waked up yet,
+ * give it one more try.
+ */
+ printf("warning: funky SQPOLL timing\n");
+ sleep(1);
+ retried = true;
+ goto again;
+ } else if (ret < 0) {
fprintf(stderr, "%s: timeout error: %d\n", __FUNCTION__, ret);
return 1;
}
-
io_uring_cqe_seen(ring, cqe);
return 0;
}