test reg buffers more
PATCH 2/3 test/rw: remove not used mixed_fixed flag
In reply to Pavel Begunkovmixed_fixed is not used, kill it
--- test/read-write.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-)
test/read-write.c +15 -22
@@ -56,8 +56,8 @@ static int create_file(const char *file)return ret !=FILE_SIZE ; } -static int __test_io (const char *file,struct io_uring *ring,int write,int buffered, -int sqthread,int fixed,int mixed_fixed,int nonvec, +static int __test_io (const char *file,struct io_uring *ring,int write, +int buffered,int sqthread,int fixed,int nonvec,int buf_select,int seq,int exp_len) {struct io_uring_sqe *sqe;
@@ -67,10 +67,9 @@ static int __test_io(const char *file, struct io_uring *ring, int write, int bufoff_t offset;#ifdef VERBOSE -fprintf (stdout,"%s: start %d/%d/%d/%d/%d/%d: " , __FUNCTION__, write, +fprintf (stdout,"%s: start %d/%d/%d/%d/%d: " , __FUNCTION__, write, buffered, sqthread, - fixed, mixed_fixed, - nonvec); + fixed, nonvec);#endif if (sqthread &&geteuid ()) {#ifdef VERBOSE
@@ -239,7 +238,7 @@ err:return 1 ; }static int test_io (const char *file,int write,int buffered,int sqthread, -int fixed,int mixed_fixed,int nonvec) +int fixed,int nonvec) {struct io_uring ring;int ret, ring_flags;
@@ -263,8 +262,8 @@ static int test_io(const char *file, int write, int buffered, int sqthread,return 1 ; } - ret =__test_io (file, &ring, write, buffered, sqthread, fixed, - mixed_fixed, nonvec,0 ,0 ,BS ); + ret =__test_io (file, &ring, write, buffered, sqthread, fixed, nonvec, +0 ,0 ,BS );io_uring_queue_exit (&ring);return ret;
@@ -442,7 +441,7 @@ static int test_buf_select_short(const char *filename, int nonvec)io_uring_cqe_seen (&ring, cqe); } - ret =__test_io (filename, &ring,0 ,0 ,0 ,0 ,0 , nonvec,1 ,1 , exp_len); + ret =__test_io (filename, &ring,0 ,0 ,0 ,0 , nonvec,1 ,1 , exp_len);io_uring_queue_exit (&ring);return ret;
@@ -476,7 +475,7 @@ static int test_buf_select(const char *filename, int nonvec)for (i =0 ; i <BUFFERS ; i++)memset (vecs[i].iov_base, i, vecs[i].iov_len); - ret =__test_io (filename, &ring,1 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,BS ); + ret =__test_io (filename, &ring,1 ,0 ,0 ,0 ,0 ,0 ,1 ,BS );if (ret) {fprintf (stderr,"failed writing data\n" );return 1 ;
@@ -506,7 +505,7 @@ static int test_buf_select(const char *filename, int nonvec)io_uring_cqe_seen (&ring, cqe); } - ret =__test_io (filename, &ring,0 ,0 ,0 ,0 ,0 , nonvec,1 ,1 ,BS ); + ret =__test_io (filename, &ring,0 ,0 ,0 ,0 , nonvec,1 ,1 ,BS );io_uring_queue_exit (&ring);return ret;
@@ -690,25 +689,19 @@ int main(int argc, char *argv[]) }/* if we don't have nonvec read, skip testing that */ -if (has_nonvec_read ()) - nr =64 ; -else - nr =32 ; + nr =has_nonvec_read () ?32 :16 ;for (i =0 ; i < nr; i++) {int write = (i &1 ) !=0 ;int buffered = (i &2 ) !=0 ;int sqthread = (i &4 ) !=0 ;int fixed = (i &8 ) !=0 ; -int mixed_fixed = (i &16 ) !=0 ; -int nonvec = (i &32 ) !=0 ; +int nonvec = (i &16 ) !=0 ; - ret =test_io (fname, write, buffered, sqthread, fixed, - mixed_fixed, nonvec); + ret =test_io (fname, write, buffered, sqthread, fixed, nonvec);if (ret) { -fprintf (stderr,"test_io failed %d/%d/%d/%d/%d/%d\n" , - write, buffered, sqthread, fixed, - mixed_fixed, nonvec); +fprintf (stderr,"test_io failed %d/%d/%d/%d/%d\n" , + write, buffered, sqthread, fixed, nonvec); goto err; } }
Signature · 1 line
2.24.0
PATCH 3/3 test/rw: test reg bufs with non-align sizes/offset
In reply to Pavel BegunkovBroaden registered buffers coverage with registering buffers with non-aligned random offsets and sizes. That in particular test how we're setting and advancing in-kernel bvecs.
Pass exp_len==-1 for that, so it compares against iov_len with which it was initialised. Also, direct IO requires alignment, so do it in buffered mode.
--- test/read-write.c | 71 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 6 deletions(-)
test/read-write.c +65 -6
@@ -37,6 +37,23 @@ static int create_buffers(void)return 0 ; } +static int create_nonaligned_buffers (void ) +{ +int i; + + vecs =malloc (BUFFERS *sizeof (struct iovec )); +for (i =0 ; i <BUFFERS ; i++) { +char *p =malloc (3 *BS ); + +if (!p) +return 1 ; + vecs[i].iov_base = p + (rand () %BS ); + vecs[i].iov_len =1 + (rand () %BS ); + } + +return 0 ; +} +static int create_file (const char *file) {ssize_t ret;
@@ -155,6 +172,7 @@ static int __test_io(const char *file, struct io_uring *ring, int write, } } + sqe->user_data = i;if (sqthread) sqe->flags |=IOSQE_FIXED_FILE ;if (buf_select) {
@@ -162,7 +180,6 @@ static int __test_io(const char *file, struct io_uring *ring, int write, sqe->addr =0 ; sqe->flags |=IOSQE_BUFFER_SELECT ; sqe->buf_group = buf_select; - sqe->user_data = i; }if (seq) offset +=BS ;
@@ -187,6 +204,14 @@ static int __test_io(const char *file, struct io_uring *ring, int write, warned =1 ; no_read =1 ; } + }else if (exp_len ==-1 ) { +int iov_len = vecs[cqe->user_data].iov_len; + +if (cqe->res != iov_len) { +fprintf (stderr,"cqe res %d, wanted %d\n" , + cqe->res, iov_len); + goto err; + } }else if (cqe->res != exp_len) {fprintf (stderr,"cqe res %d, wanted %d\n" , cqe->res, exp_len); goto err;
@@ -238,7 +263,7 @@ err:return 1 ; }static int test_io (const char *file,int write,int buffered,int sqthread, -int fixed,int nonvec) +int fixed,int nonvec,int exp_len) {struct io_uring ring;int ret, ring_flags;
@@ -263,7 +288,7 @@ static int test_io(const char *file, int write, int buffered, int sqthread, } ret =__test_io (file, &ring, write, buffered, sqthread, fixed, nonvec, -0 ,0 ,BS ); +0 ,0 , exp_len);io_uring_queue_exit (&ring);return ret;
@@ -593,14 +618,15 @@ static int test_write_efbig(void)struct io_uring_sqe *sqe;struct io_uring_cqe *cqe;struct io_uring ring; -struct rlimit rlim; +struct rlimit rlim, old_rlim;int i, fd, ret;loff_t off; -if (getrlimit (RLIMIT_FSIZE , &rlim) <0 ) { +if (getrlimit (RLIMIT_FSIZE , &old_rlim) <0 ) {perror ("getrlimit" );return 1 ; } + rlim = old_rlim; rlim.rlim_cur =64 *1024 ; rlim.rlim_max =64 *1024 ;if (setrlimit (RLIMIT_FSIZE , &rlim) <0 ) {
@@ -660,6 +686,11 @@ static int test_write_efbig(void)io_uring_queue_exit (&ring);close (fd);unlink (".efbig" ); + +if (setrlimit (RLIMIT_FSIZE , &old_rlim) <0 ) { +perror ("setrlimit" ); +return 1 ; + }return 0 ; err:if (fd !=-1 )
@@ -698,7 +729,8 @@ int main(int argc, char *argv[])int fixed = (i &8 ) !=0 ;int nonvec = (i &16 ) !=0 ; - ret =test_io (fname, write, buffered, sqthread, fixed, nonvec); + ret =test_io (fname, write, buffered, sqthread, fixed, nonvec, +BS );if (ret) {fprintf (stderr,"test_io failed %d/%d/%d/%d/%d\n" , write, buffered, sqthread, fixed, nonvec);
@@ -754,6 +786,33 @@ int main(int argc, char *argv[]) goto err; } +srand ((unsigned )time (NULL )); +if (create_nonaligned_buffers ()) { +fprintf (stderr,"file creation failed\n" ); + goto err; + } + +/* test fixed bufs with non-aligned len/offset */ +for (i =0 ; i < nr; i++) { +int write = (i &1 ) !=0 ; +int buffered = (i &2 ) !=0 ; +int sqthread = (i &4 ) !=0 ; +int fixed = (i &8 ) !=0 ; +int nonvec = (i &16 ) !=0 ; + +/* direct IO requires alignment, skip it */ +if (!buffered || !fixed || nonvec) +continue ; + + ret =test_io (fname, write, buffered, sqthread, fixed, nonvec, +-1 ); +if (ret) { +fprintf (stderr,"test_io failed %d/%d/%d/%d/%d\n" , + write, buffered, sqthread, fixed, nonvec); + goto err; + } + } +if (fname != argv[1 ])unlink (fname);return 0 ;
Signature · 1 line
2.24.0
cover test reg buffers more
This test registered buffers with non-zero offsets and varying IO lengths. The first 2 patches are just cleanups for the 3rd one.
Pavel Begunkov (3):
test/rw: name flags for clearness
test/rw: remove not used mixed_fixed flag test/rw: test reg bufs with non-align sizes/offset
test/read-write.c | 111 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 29 deletions(-)
Signature · 1 line
2.24.0
PATCH 1/3 test/rw: name flags for clearness
Replace obscure v1-v6 with more readable flag names.
--- test/read-write.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
test/read-write.c +11 -10
@@ -696,18 +696,19 @@ int main(int argc, char *argv[]) nr =32 ;for (i =0 ; i < nr; i++) { -int v1, v2, v3, v4, v5, v6; - - v1 = (i &1 ) !=0 ; - v2 = (i &2 ) !=0 ; - v3 = (i &4 ) !=0 ; - v4 = (i &8 ) !=0 ; - v5 = (i &16 ) !=0 ; - v6 = (i &32 ) !=0 ; - ret =test_io (fname, v1, v2, v3, v4, v5, v6); +int write = (i &1 ) !=0 ; +int buffered = (i &2 ) !=0 ; +int sqthread = (i &4 ) !=0 ; +int fixed = (i &8 ) !=0 ; +int mixed_fixed = (i &16 ) !=0 ; +int nonvec = (i &32 ) !=0 ; + + ret =test_io (fname, write, buffered, sqthread, fixed, + mixed_fixed, nonvec);if (ret) {fprintf (stderr,"test_io failed %d/%d/%d/%d/%d/%d\n" , - v1, v2, v3, v4, v5, v6); + write, buffered, sqthread, fixed, + mixed_fixed, nonvec); goto err; } }
Signature · 1 line
2.24.0
Quoted 10 lines · Pavel Begunkov
This test registered buffers with non-zero offsets and varying IO lengths. The first 2 patches are just cleanups for the 3rd one.
Pavel Begunkov (3):
test/rw: name flags for clearness
test/rw: remove not usedmixed_fixedflag test/rw: test reg bufs with non-align sizes/offsettest/read-write.c | 111 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 29 deletions(-)
Applied, thanks.
Signature · 1 line
Jens Axboe