deferred tw msg_ring tests
cover deferred tw msg_ring tests
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
test/msg-ring.c | 182 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 172 insertions(+), 10 deletions(-)
Signature · 1 line
2.38.1
PATCH 1/5 tests/msg_ring: use correct exit codes
--- test/msg-ring.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
test/msg-ring.c +5 -5
@@ -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);
Signature · 1 line
2.38.1
PATCH 2/5 tests/msg_ring: test msg_ring with deferred tw
In reply to Pavel BegunkovExtend msg_ring.c to test IORING_SETUP_DEFER_TASKRUN rings
--- test/msg-ring.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
test/msg-ring.c +28 -0
@@ -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 ; }
Signature · 1 line
2.38.1
PATCH 3/5 test/msg_ring: test msg_ring to a disabled ring
In reply to Pavel BegunkovA regression test trying to message IORING_SETUP_R_DISABLED rings.
--- test/msg-ring.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+)
test/msg-ring.c +55 -0
@@ -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 ;
Signature · 1 line
2.38.1
PATCH 4/5 tests/msg_ring: refactor test_remote
In reply to Pavel BegunkovRefactor test_remote() by folding all pthread accounting inside of it
--- test/msg-ring.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
test/msg-ring.c +8 -7
@@ -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 ; }
Signature · 1 line
2.38.1
PATCH 5/5 tests/msg_ring: remote submit to a deferred tw ring
In reply to Pavel BegunkovTest sending messages to a deferred ring from another task
--- test/msg-ring.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-)
test/msg-ring.c +79 -1
@@ -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);
Signature · 1 line
2.38.1
Quoted 11 lines · Pavel Begunkov
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: testmsg_ringwith deferred tw test/msg_ring: testmsg_ringto a disabled ring tests/msg_ring: refactortest_remotetests/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: 5e065b4d137a5da7d390402f854484e33bb20a5cBest regards,
Signature · 1 line
Jens Axboe