From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing] tests: fix poll update compatibility check
Date: Mon, 26 Jul 2021 16:50:55 +0100 [thread overview]
Message-ID: <2a5f83d0cda642d97ea633b55ba0d53e82cbb064.1627314599.git.asml.silence@gmail.com> (raw)
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
next reply other threads:[~2021-07-26 15:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 15:50 Pavel Begunkov [this message]
2021-07-26 16:37 ` [PATCH liburing] tests: fix poll update compatibility check Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2a5f83d0cda642d97ea633b55ba0d53e82cbb064.1627314599.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox