test: fix poll-mshot-update tests
cover test: fix poll-mshot-update tests
This test did not look at the IORING_CQE_F_MORE flag, and so could start failing. Update it to do this in patch 1, and then patch 2 runs the test with more/less overflows to test these codepaths
Dylan Yudaken (2):
fixup poll-mshot-update
test: have poll-mshot-update run with both big and small cqe
test/poll-mshot-update.c | 116 ++++++++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 33 deletions(-)
base-commit: 4e6eec8bdea906fe5341c97aef96986d605004e9
Signature · 1 line
2.30.2
PATCH 1/2 fixup poll-mshot-update
this test did not notice when poll was cancelled.
update it to notice, and rearm poll
--- test/poll-mshot-update.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
test/poll-mshot-update.c +26 -0
@@ -75,6 +75,20 @@ static int arm_poll(struct io_uring *ring, int off)return 0 ; } +static int submit_arm_poll (struct io_uring *ring,int off) +{ +int ret; + + ret =arm_poll (ring, off); +if (ret) +return ret; + + ret =io_uring_submit (ring); +if (ret <0 ) +return ret; +return ret ==1 ?0 :-1 ; +} +static int reap_polls (struct io_uring *ring) {struct io_uring_cqe *cqe;
@@ -106,6 +120,18 @@ static int reap_polls(struct io_uring *ring) off = cqe->user_data;if (off ==0x12345678 ) goto seen; +if (!(cqe->flags &IORING_CQE_F_MORE )) { +/* need to re-arm poll */ + ret =submit_arm_poll (ring, off); +if (ret) +break ; +if (cqe->res <=0 ) { +/* retry this one */ + i--; + goto seen; + } + } + ret =read (p[off].fd[0 ], &c,1 );if (ret !=1 ) {if (ret ==-1 && errno ==EAGAIN )
Signature · 1 line
2.30.2
PATCH 2/2 test: have poll-mshot-update run with both big and small cqe
In reply to Dylan YudakenRun the test twice, with and without overflow to make sure more codepaths are tested.
--- test/poll-mshot-update.c | 90 +++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 33 deletions(-)
test/poll-mshot-update.c +57 -33
@@ -213,52 +213,23 @@ static int arm_polls(struct io_uring *ring)return 0 ; } -int main (int argc,char *argv[]) +static int run (int cqe) {struct io_uring ring;struct io_uring_params params = { }; -struct rlimit rlim;pthread_t thread;int i, j, ret; -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; - } - -if (rlim.rlim_cur < (2 *NFILES +5 )) { - rlim.rlim_cur = (2 *NFILES +5 ); - rlim.rlim_max = rlim.rlim_cur; -if (setrlimit (RLIMIT_NOFILE , &rlim) <0 ) { -if (errno ==EPERM ) - goto err_nofail; -perror ("setrlimit" ); - goto err_noring; - } - } -for (i =0 ; i <NFILES ; i++) {if (pipe (p[i].fd) <0 ) {perror ("pipe" ); - goto err_noring; +return 1 ; }fcntl (p[i].fd[0 ],F_SETFL ,O_NONBLOCK ); } params.flags =IORING_SETUP_CQSIZE ; - params.cq_entries =4096 ; + params.cq_entries = cqe; ret =io_uring_queue_init_params (RING_SIZE , &ring, ¶ms);if (ret) {if (ret == -EINVAL ) {
@@ -286,10 +257,63 @@ int main(int argc, char *argv[]) }io_uring_queue_exit (&ring); +for (i =0 ; i <NFILES ; i++) { +close (p[i].fd[0 ]); +close (p[i].fd[1 ]); + }return 0 ; err:io_uring_queue_exit (&ring); -err_noring: +return 1 ; +} + +int main (int argc,char *argv[]) +{ +struct rlimit rlim; +int ret; + +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; + } + +if (rlim.rlim_cur < (2 *NFILES +5 )) { + rlim.rlim_cur = (2 *NFILES +5 ); + rlim.rlim_max = rlim.rlim_cur; +if (setrlimit (RLIMIT_NOFILE , &rlim) <0 ) { +if (errno ==EPERM ) + goto err_nofail; +perror ("setrlimit" ); + goto err; + } + } + + ret =run (1024 ); +if (ret) { +fprintf (stderr,"run(1024) failed\n" ); + goto err; + } + + ret =run (8192 ); +if (ret) { +fprintf (stderr,"run(8192) failed\n" ); + goto err; + } + +return 0 ; +err:fprintf (stderr,"poll-many failed\n" );return 1 ; err_nofail:
Signature · 1 line
2.30.2
Quoted 9 lines · Dylan Yudaken
This test did not look at the
IORING_CQE_F_MOREflag, and so could start failing. Update it to do this in patch 1, and then patch 2 runs the test with more/less overflows to test these codepathsDylan Yudaken (2):
fixup poll-mshot-update
test: have poll-mshot-update run with both big and small cqe[...]
Applied, thanks!
[1/2] fixup poll-mshot-update
commit: 6451f3d9c0d06537a87d2adbe88c7f83aa0de787
[2/2] test: have poll-mshot-update run with both big and small cqe
commit: 3609e11ccce8a9bc1ce36a3191fa8e25dd762932Best regards,
Signature · 1 line
Jens Axboe