* [PATCH liburing 1/5] tests/msg_ring: use correct exit codes
2023-01-24 1:21 [PATCH liburing 0/5] deferred tw msg_ring tests Pavel Begunkov
@ 2023-01-24 1:21 ` Pavel Begunkov
2023-01-24 1:21 ` [PATCH liburing 2/5] tests/msg_ring: test msg_ring with deferred tw Pavel Begunkov
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2023-01-24 1:21 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/msg-ring.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/test/msg-ring.c b/test/msg-ring.c
index a825bf9..afe3192 100644
--- a/test/msg-ring.c
+++ b/test/msg-ring.c
@@ -220,27 +220,27 @@ int main(int argc, char *argv[])
ret = test_own(&ring);
if (ret) {
fprintf(stderr, "test_own failed\n");
- return ret;
+ return T_EXIT_FAIL;
}
if (no_msg)
return T_EXIT_SKIP;
ret = test_own(&pring);
if (ret) {
fprintf(stderr, "test_own iopoll failed\n");
- return ret;
+ return T_EXIT_FAIL;
}
ret = test_invalid(&ring, 0);
if (ret) {
fprintf(stderr, "test_invalid failed\n");
- return ret;
+ return T_EXIT_FAIL;
}
for (i = 0; i < 2; i++) {
ret = test_invalid(&ring, 1);
if (ret) {
fprintf(stderr, "test_invalid fixed failed\n");
- return ret;
+ return T_EXIT_FAIL;
}
}
@@ -249,7 +249,7 @@ int main(int argc, char *argv[])
ret = test_remote(&ring, &ring2);
if (ret) {
fprintf(stderr, "test_remote failed\n");
- return ret;
+ return T_EXIT_FAIL;
}
pthread_join(thread, &tret);
--
2.38.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH liburing 2/5] tests/msg_ring: test msg_ring with deferred tw
2023-01-24 1:21 [PATCH liburing 0/5] deferred tw msg_ring tests Pavel Begunkov
2023-01-24 1:21 ` [PATCH liburing 1/5] tests/msg_ring: use correct exit codes Pavel Begunkov
@ 2023-01-24 1:21 ` Pavel Begunkov
2023-01-24 1:21 ` [PATCH liburing 3/5] test/msg_ring: test msg_ring to a disabled ring Pavel Begunkov
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2023-01-24 1:21 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Extend msg_ring.c to test IORING_SETUP_DEFER_TASKRUN rings
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/msg-ring.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/test/msg-ring.c b/test/msg-ring.c
index afe3192..6db7680 100644
--- a/test/msg-ring.c
+++ b/test/msg-ring.c
@@ -254,5 +254,33 @@ int main(int argc, char *argv[])
pthread_join(thread, &tret);
+ io_uring_queue_exit(&ring);
+ io_uring_queue_exit(&ring2);
+ io_uring_queue_exit(&pring);
+
+ if (t_probe_defer_taskrun()) {
+ ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
+ IORING_SETUP_DEFER_TASKRUN);
+ if (ret) {
+ fprintf(stderr, "deferred ring setup failed: %d\n", ret);
+ return T_EXIT_FAIL;
+ }
+
+ ret = test_own(&ring);
+ if (ret) {
+ fprintf(stderr, "test_own deferred failed\n");
+ return T_EXIT_FAIL;
+ }
+
+ for (i = 0; i < 2; i++) {
+ ret = test_invalid(&ring, i);
+ if (ret) {
+ fprintf(stderr, "test_invalid(0) deferred failed\n");
+ return T_EXIT_FAIL;
+ }
+ }
+ io_uring_queue_exit(&ring);
+ }
+
return T_EXIT_PASS;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH liburing 3/5] test/msg_ring: test msg_ring to a disabled ring
2023-01-24 1:21 [PATCH liburing 0/5] deferred tw msg_ring tests Pavel Begunkov
2023-01-24 1:21 ` [PATCH liburing 1/5] tests/msg_ring: use correct exit codes Pavel Begunkov
2023-01-24 1:21 ` [PATCH liburing 2/5] tests/msg_ring: test msg_ring with deferred tw Pavel Begunkov
@ 2023-01-24 1:21 ` Pavel Begunkov
2023-01-24 1:21 ` [PATCH liburing 4/5] tests/msg_ring: refactor test_remote Pavel Begunkov
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2023-01-24 1:21 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
A regression test trying to message IORING_SETUP_R_DISABLED rings.
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/msg-ring.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/test/msg-ring.c b/test/msg-ring.c
index 6db7680..66c60b3 100644
--- a/test/msg-ring.c
+++ b/test/msg-ring.c
@@ -191,6 +191,49 @@ err:
return 1;
}
+static int test_disabled_ring(struct io_uring *ring, int flags)
+{
+ struct io_uring_cqe *cqe;
+ struct io_uring_sqe *sqe;
+ struct io_uring disabled_ring;
+ int ret;
+
+ flags |= IORING_SETUP_R_DISABLED;
+ ret = io_uring_queue_init(8, &disabled_ring, flags);
+ if (ret) {
+ fprintf(stderr, "ring setup failed: %d\n", ret);
+ return 1;
+ }
+
+ sqe = io_uring_get_sqe(ring);
+ io_uring_prep_msg_ring(sqe, disabled_ring.ring_fd, 0x10, 0x1234, 0);
+ sqe->user_data = 1;
+
+ ret = io_uring_submit(ring);
+ if (ret != 1) {
+ fprintf(stderr, "sqe submit failed: %d\n", ret);
+ return 1;
+ }
+
+ ret = io_uring_wait_cqe(ring, &cqe);
+ if (ret < 0) {
+ fprintf(stderr, "wait completion %d\n", ret);
+ return 1;
+ }
+ if (cqe->res != 0 && cqe->res != -EBADFD) {
+ fprintf(stderr, "cqe res %d\n", cqe->res);
+ return 1;
+ }
+ if (cqe->user_data != 1) {
+ fprintf(stderr, "user_data %llx\n", (long long) cqe->user_data);
+ return 1;
+ }
+
+ io_uring_cqe_seen(ring, cqe);
+ io_uring_queue_exit(&disabled_ring);
+ return 0;
+}
+
int main(int argc, char *argv[])
{
struct io_uring ring, ring2, pring;
@@ -280,6 +323,18 @@ int main(int argc, char *argv[])
}
}
io_uring_queue_exit(&ring);
+
+ if (test_disabled_ring(&ring2, 0)) {
+ fprintf(stderr, "test_disabled_ring failed\n");
+ return T_EXIT_FAIL;
+ }
+
+ if (test_disabled_ring(&ring2, IORING_SETUP_SINGLE_ISSUER |
+ IORING_SETUP_DEFER_TASKRUN)) {
+ fprintf(stderr, "test_disabled_ring defer failed\n");
+ return T_EXIT_FAIL;
+ }
+
}
return T_EXIT_PASS;
--
2.38.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH liburing 4/5] tests/msg_ring: refactor test_remote
2023-01-24 1:21 [PATCH liburing 0/5] deferred tw msg_ring tests Pavel Begunkov
` (2 preceding siblings ...)
2023-01-24 1:21 ` [PATCH liburing 3/5] test/msg_ring: test msg_ring to a disabled ring Pavel Begunkov
@ 2023-01-24 1:21 ` Pavel Begunkov
2023-01-24 1:21 ` [PATCH liburing 5/5] tests/msg_ring: remote submit to a deferred tw ring Pavel Begunkov
2023-01-24 2:31 ` [PATCH liburing 0/5] deferred tw msg_ring tests Jens Axboe
5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2023-01-24 1:21 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Refactor test_remote() by folding all pthread accounting inside of it
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/msg-ring.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/test/msg-ring.c b/test/msg-ring.c
index 66c60b3..495c127 100644
--- a/test/msg-ring.c
+++ b/test/msg-ring.c
@@ -93,17 +93,23 @@ static void *wait_cqe_fn(void *data)
goto err;
}
+ io_uring_cqe_seen(ring, cqe);
return NULL;
err:
+ io_uring_cqe_seen(ring, cqe);
return (void *) (unsigned long) 1;
}
static int test_remote(struct io_uring *ring, struct io_uring *target)
{
+ pthread_t thread;
+ void *tret;
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
int ret;
+ pthread_create(&thread, NULL, wait_cqe_fn, target);
+
sqe = io_uring_get_sqe(ring);
if (!sqe) {
fprintf(stderr, "get sqe failed\n");
@@ -134,6 +140,7 @@ static int test_remote(struct io_uring *ring, struct io_uring *target)
}
io_uring_cqe_seen(ring, cqe);
+ pthread_join(thread, &tret);
return 0;
err:
return 1;
@@ -237,8 +244,6 @@ static int test_disabled_ring(struct io_uring *ring, int flags)
int main(int argc, char *argv[])
{
struct io_uring ring, ring2, pring;
- pthread_t thread;
- void *tret;
int ret, i;
if (argc > 1)
@@ -287,18 +292,13 @@ int main(int argc, char *argv[])
}
}
- pthread_create(&thread, NULL, wait_cqe_fn, &ring2);
-
ret = test_remote(&ring, &ring2);
if (ret) {
fprintf(stderr, "test_remote failed\n");
return T_EXIT_FAIL;
}
- pthread_join(thread, &tret);
-
io_uring_queue_exit(&ring);
- io_uring_queue_exit(&ring2);
io_uring_queue_exit(&pring);
if (t_probe_defer_taskrun()) {
@@ -337,5 +337,6 @@ int main(int argc, char *argv[])
}
+ io_uring_queue_exit(&ring2);
return T_EXIT_PASS;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH liburing 5/5] tests/msg_ring: remote submit to a deferred tw ring
2023-01-24 1:21 [PATCH liburing 0/5] deferred tw msg_ring tests Pavel Begunkov
` (3 preceding siblings ...)
2023-01-24 1:21 ` [PATCH liburing 4/5] tests/msg_ring: refactor test_remote Pavel Begunkov
@ 2023-01-24 1:21 ` Pavel Begunkov
2023-01-24 2:31 ` [PATCH liburing 0/5] deferred tw msg_ring tests Jens Axboe
5 siblings, 0 replies; 7+ messages in thread
From: Pavel Begunkov @ 2023-01-24 1:21 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Test sending messages to a deferred ring from another task
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/msg-ring.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 79 insertions(+), 1 deletion(-)
diff --git a/test/msg-ring.c b/test/msg-ring.c
index 495c127..cb6687f 100644
--- a/test/msg-ring.c
+++ b/test/msg-ring.c
@@ -146,6 +146,79 @@ err:
return 1;
}
+static void *remote_submit_fn(void *data)
+{
+ struct io_uring_sqe *sqe;
+ struct io_uring_cqe *cqe;
+ struct io_uring *target = data;
+ struct io_uring ring;
+ int ret;
+
+ ret = io_uring_queue_init(8, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "thread ring setup failed: %d\n", ret);
+ goto err;
+ }
+ sqe = io_uring_get_sqe(&ring);
+ if (!sqe) {
+ fprintf(stderr, "get sqe failed\n");
+ goto err;
+ }
+
+ io_uring_prep_msg_ring(sqe, target->ring_fd, 0x20, 0x5aa5, 0);
+ sqe->user_data = 1;
+
+ ret = io_uring_submit(&ring);
+ if (ret <= 0) {
+ fprintf(stderr, "sqe submit failed: %d\n", ret);
+ goto err;
+ }
+
+ ret = io_uring_wait_cqe(&ring, &cqe);
+ if (ret < 0) {
+ fprintf(stderr, "wait completion %d\n", ret);
+ goto err;
+ }
+ if (cqe->res != 0 || cqe->user_data != 1) {
+ fprintf(stderr, "invalid cqe\n");
+ goto err;
+ }
+ io_uring_cqe_seen(&ring, cqe);
+ io_uring_queue_exit(&ring);
+ return NULL;
+err:
+ return (void *) (unsigned long) 1;
+}
+
+static int test_remote_submit(struct io_uring *target)
+{
+ struct io_uring_cqe *cqe;
+ pthread_t thread;
+ void *tret;
+ int ret;
+
+ pthread_create(&thread, NULL, remote_submit_fn, target);
+
+ ret = io_uring_wait_cqe(target, &cqe);
+ if (ret < 0) {
+ fprintf(stderr, "wait completion %d\n", ret);
+ goto err;
+ }
+ if (cqe->res != 0x20) {
+ fprintf(stderr, "cqe res %d\n", cqe->res);
+ return -1;
+ }
+ if (cqe->user_data != 0x5aa5) {
+ fprintf(stderr, "user_data %llx\n", (long long) cqe->user_data);
+ return -1;
+ }
+ io_uring_cqe_seen(target, cqe);
+ pthread_join(thread, &tret);
+ return 0;
+err:
+ return 1;
+}
+
static int test_invalid(struct io_uring *ring, bool fixed)
{
struct io_uring_cqe *cqe;
@@ -322,6 +395,12 @@ int main(int argc, char *argv[])
return T_EXIT_FAIL;
}
}
+
+ ret = test_remote_submit(&ring);
+ if (ret) {
+ fprintf(stderr, "test_remote_submit failed\n");
+ return T_EXIT_FAIL;
+ }
io_uring_queue_exit(&ring);
if (test_disabled_ring(&ring2, 0)) {
@@ -334,7 +413,6 @@ int main(int argc, char *argv[])
fprintf(stderr, "test_disabled_ring defer failed\n");
return T_EXIT_FAIL;
}
-
}
io_uring_queue_exit(&ring2);
--
2.38.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH liburing 0/5] deferred tw msg_ring tests
2023-01-24 1:21 [PATCH liburing 0/5] deferred tw msg_ring tests Pavel Begunkov
` (4 preceding siblings ...)
2023-01-24 1:21 ` [PATCH liburing 5/5] tests/msg_ring: remote submit to a deferred tw ring Pavel Begunkov
@ 2023-01-24 2:31 ` Jens Axboe
5 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2023-01-24 2:31 UTC (permalink / raw)
To: io-uring, Pavel Begunkov
On Tue, 24 Jan 2023 01:21:44 +0000, Pavel Begunkov wrote:
> Add a regression test for a recent null deref regression with
> disabled deferred ring and cover a couple more deferred tw cases.
>
> Pavel Begunkov (5):
> tests/msg_ring: use correct exit codes
> tests/msg_ring: test msg_ring with deferred tw
> test/msg_ring: test msg_ring to a disabled ring
> tests/msg_ring: refactor test_remote
> tests/msg_ring: remote submit to a deferred tw ring
>
> [...]
Applied, thanks!
[1/5] tests/msg_ring: use correct exit codes
commit: f4b49d6a04209799e7919abc10cca0a6fafff5f7
[2/5] tests/msg_ring: test msg_ring with deferred tw
commit: 52ca1bf33fc80425755a8b0f79a8dd91b0833e6b
[3/5] test/msg_ring: test msg_ring to a disabled ring
commit: 538a3a3357a10b9030b4bba0e39e4e14e3726ce8
[4/5] tests/msg_ring: refactor test_remote
commit: b78d76aa18aed2dc6750f4185f6941ce74281779
[5/5] tests/msg_ring: remote submit to a deferred tw ring
commit: 5e065b4d137a5da7d390402f854484e33bb20a5c
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread