From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 2/2] tests: fix and improve nop tests
Date: Fri, 17 Jun 2022 09:42:42 +0100 [thread overview]
Message-ID: <92f01041e5ef933a6018bd89dd54cc1fae57c6f6.1655455225.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
We removed CQE32 for nops from the kernel, fix the tests and instead
test that we return zeroes in the extra fields instead of garbage.
Loop over the tests multiple times so it exhausts CQ and we also test
CQ entries recycling and internal caching mechanism. Also excersie
IOSQE_ASYNC.
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/nop.c | 47 ++++++++++++++++++++++-------------------------
1 file changed, 22 insertions(+), 25 deletions(-)
diff --git a/test/nop.c b/test/nop.c
index ce223b3..1aa88fc 100644
--- a/test/nop.c
+++ b/test/nop.c
@@ -15,7 +15,7 @@
static int seq;
-static int test_single_nop(struct io_uring *ring)
+static int test_single_nop(struct io_uring *ring, unsigned req_flags)
{
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
@@ -29,11 +29,8 @@ static int test_single_nop(struct io_uring *ring)
}
io_uring_prep_nop(sqe);
- if (cqe32) {
- sqe->addr = 1234;
- sqe->addr2 = 5678;
- }
sqe->user_data = ++seq;
+ sqe->flags |= req_flags;
ret = io_uring_submit(ring);
if (ret <= 0) {
@@ -51,12 +48,12 @@ static int test_single_nop(struct io_uring *ring)
goto err;
}
if (cqe32) {
- if (cqe->big_cqe[0] != 1234) {
+ if (cqe->big_cqe[0] != 0) {
fprintf(stderr, "Unexpected extra1\n");
goto err;
}
- if (cqe->big_cqe[1] != 5678) {
+ if (cqe->big_cqe[1] != 0) {
fprintf(stderr, "Unexpected extra2\n");
goto err;
}
@@ -67,7 +64,7 @@ err:
return 1;
}
-static int test_barrier_nop(struct io_uring *ring)
+static int test_barrier_nop(struct io_uring *ring, unsigned req_flags)
{
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
@@ -84,11 +81,8 @@ static int test_barrier_nop(struct io_uring *ring)
io_uring_prep_nop(sqe);
if (i == 4)
sqe->flags = IOSQE_IO_DRAIN;
- if (cqe32) {
- sqe->addr = 1234;
- sqe->addr2 = 5678;
- }
sqe->user_data = ++seq;
+ sqe->flags |= req_flags;
}
ret = io_uring_submit(ring);
@@ -111,11 +105,11 @@ static int test_barrier_nop(struct io_uring *ring)
goto err;
}
if (cqe32) {
- if (cqe->big_cqe[0] != 1234) {
+ if (cqe->big_cqe[0] != 0) {
fprintf(stderr, "Unexpected extra1\n");
goto err;
}
- if (cqe->big_cqe[1] != 5678) {
+ if (cqe->big_cqe[1] != 0) {
fprintf(stderr, "Unexpected extra2\n");
goto err;
}
@@ -132,7 +126,7 @@ static int test_ring(unsigned flags)
{
struct io_uring ring;
struct io_uring_params p = { };
- int ret;
+ int ret, i;
p.flags = flags;
ret = io_uring_queue_init_params(8, &ring, &p);
@@ -143,18 +137,21 @@ static int test_ring(unsigned flags)
return 1;
}
- ret = test_single_nop(&ring);
- if (ret) {
- fprintf(stderr, "test_single_nop failed\n");
- goto err;
- }
+ for (i = 0; i < 1000; i++) {
+ unsigned req_flags = (i & 1) ? IOSQE_ASYNC : 0;
- ret = test_barrier_nop(&ring);
- if (ret) {
- fprintf(stderr, "test_barrier_nop failed\n");
- goto err;
- }
+ ret = test_single_nop(&ring, req_flags);
+ if (ret) {
+ fprintf(stderr, "test_single_nop failed\n");
+ goto err;
+ }
+ ret = test_barrier_nop(&ring, req_flags);
+ if (ret) {
+ fprintf(stderr, "test_barrier_nop failed\n");
+ goto err;
+ }
+ }
err:
io_uring_queue_exit(&ring);
return ret;
--
2.36.1
next prev parent reply other threads:[~2022-06-17 8:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-17 8:42 [PATCH liburing 0/2] use nop CQE32 tests to test some assumptions Pavel Begunkov
2022-06-17 8:42 ` [PATCH liburing 1/2] Revert "test/nop: kill cqe32 test code" Pavel Begunkov
2022-06-17 8:42 ` Pavel Begunkov [this message]
2022-06-17 11:36 ` [PATCH liburing 2/2] tests: fix and improve nop tests Jens Axboe
2022-06-17 11:37 ` [PATCH liburing 0/2] use nop CQE32 tests to test some assumptions 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=92f01041e5ef933a6018bd89dd54cc1fae57c6f6.1655455225.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