* [PATCH liburing] tests: fix poll update compatibility check
@ 2021-07-26 15:50 Pavel Begunkov
2021-07-26 16:37 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-07-26 15:50 UTC (permalink / raw)
To: Jens Axboe, io-uring
Compatibility checks in poll-mshot-update doesn't always work well, and
so the test can fail even if poll updates are not supported. Do the
check separately and at the beginning.
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/poll-mshot-update.c | 63 +++++++++++++++++++++++++---------------
1 file changed, 40 insertions(+), 23 deletions(-)
diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c
index 1a9ea0a..a3e4951 100644
--- a/test/poll-mshot-update.c
+++ b/test/poll-mshot-update.c
@@ -28,7 +28,37 @@ struct p {
};
static struct p p[NFILES];
-static int no_update;
+
+static int has_poll_update(void)
+{
+ struct io_uring ring;
+ struct io_uring_cqe *cqe;
+ struct io_uring_sqe *sqe;
+ bool has_update = false;
+ int ret;
+
+ ret = io_uring_queue_init(8, &ring, 0);
+ if (ret)
+ return -1;
+
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_poll_update(sqe, NULL, NULL, POLLIN, IORING_TIMEOUT_UPDATE);
+
+ ret = io_uring_submit(&ring);
+ if (ret != 1)
+ return -1;
+
+ ret = io_uring_wait_cqe(&ring, &cqe);
+ if (!ret) {
+ if (cqe->res == -ENOENT)
+ has_update = true;
+ else if (cqe->res != -EINVAL)
+ return -1;
+ io_uring_cqe_seen(&ring, cqe);
+ }
+ io_uring_queue_exit(&ring);
+ return has_update;
+}
static int arm_poll(struct io_uring *ring, int off)
{
@@ -128,19 +158,6 @@ static void *trigger_polls_fn(void *data)
return NULL;
}
-static int check_no_update(struct io_uring *ring)
-{
- struct io_uring_cqe *cqe;
- int ret;
-
- ret = io_uring_wait_cqe(ring, &cqe);
- if (ret)
- return 0;
- ret = cqe->res;
- io_uring_cqe_seen(ring, cqe);
- return ret == -EINVAL;
-}
-
static int arm_polls(struct io_uring *ring)
{
int ret, to_arm = NFILES, i, off;
@@ -163,10 +180,6 @@ static int arm_polls(struct io_uring *ring)
ret = io_uring_submit(ring);
if (ret != this_arm) {
- if (ret > 0 && check_no_update(ring)) {
- no_update = 1;
- return 0;
- }
fprintf(stderr, "submitted %d, %d\n", ret, this_arm);
return 1;
}
@@ -187,6 +200,15 @@ int main(int argc, char *argv[])
if (argc > 1)
return 0;
+ ret = has_poll_update();
+ if (ret < 0) {
+ fprintf(stderr, "poll update check failed %i\n", ret);
+ return -1;
+ } else if (!ret) {
+ fprintf(stderr, "no poll update, skip\n");
+ return 0;
+ }
+
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
perror("getrlimit");
goto err_noring;
@@ -227,10 +249,6 @@ int main(int argc, char *argv[])
if (arm_polls(&ring))
goto err;
- if (no_update) {
- printf("No poll update support, skipping\n");
- goto done;
- }
for (i = 0; i < NLOOPS; i++) {
pthread_create(&thread, NULL, trigger_polls_fn, NULL);
@@ -240,7 +258,6 @@ int main(int argc, char *argv[])
pthread_join(thread, NULL);
}
-done:
io_uring_queue_exit(&ring);
return 0;
err:
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH liburing] tests: fix poll update compatibility check
2021-07-26 15:50 [PATCH liburing] tests: fix poll update compatibility check Pavel Begunkov
@ 2021-07-26 16:37 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-07-26 16:37 UTC (permalink / raw)
To: Pavel Begunkov, io-uring
On 7/26/21 9:50 AM, Pavel Begunkov wrote:
> Compatibility checks in poll-mshot-update doesn't always work well, and
> so the test can fail even if poll updates are not supported. Do the
> check separately and at the beginning.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-26 16:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-26 15:50 [PATCH liburing] tests: fix poll update compatibility check Pavel Begunkov
2021-07-26 16:37 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox