* [PATCH liburing 0/4] add more net tests
@ 2022-09-29 0:03 Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 1/4] tests: improve zc cflags handling Pavel Begunkov
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Pavel Begunkov @ 2022-09-29 0:03 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
NOT FOR THIS LIBURING RELEASE
We need more testing for send/recv. This series extends zerocopy tests
to non-zerocopy opcodes to cover 1) non-zc send() with address and
2) retrying sendmsg[zc]() with large iovecs to make sure we fixing
up fast_iov right on short send.
Pavel Begunkov (4):
tests: improve zc cflags handling
tests/zc: pass params in a struct
tests: add non-zc tests in send-zerocopy.c
tests: add tests for retries with long iovec
test/send-zerocopy.c | 182 ++++++++++++++++++++++++++++++-------------
1 file changed, 127 insertions(+), 55 deletions(-)
--
2.37.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH liburing 1/4] tests: improve zc cflags handling
2022-09-29 0:03 [PATCH liburing 0/4] add more net tests Pavel Begunkov
@ 2022-09-29 0:03 ` Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 2/4] tests/zc: pass params in a struct Pavel Begunkov
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2022-09-29 0:03 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Add a couple of tweaks, count nr_cqes on in the loop, so it's easier to
adapt for other test cases.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/send-zerocopy.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 31d66e3..e58b11c 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -283,9 +283,9 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
if (mix_register)
real_fixed_buf = rand() & 1;
- if (cork && i != nr_reqs - 1)
+ if (i != nr_reqs - 1)
msg_flags |= MSG_MORE;
- if (i == nr_reqs - 1)
+ else
cur_size = chunk_size_last;
sqe = io_uring_get_sqe(ring);
@@ -330,7 +330,7 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
return 1;
}
- nr_cqes = 2 * nr_reqs + 1;
+ nr_cqes = nr_reqs + 1;
for (i = 0; i < nr_cqes; i++) {
int expected = chunk_size;
@@ -347,13 +347,19 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
io_uring_cqe_seen(ring, cqe);
continue;
}
-
+ if ((cqe->flags & IORING_CQE_F_MORE) && (cqe->flags & IORING_CQE_F_NOTIF)) {
+ fprintf(stderr, "unexpected cflags %i res %i\n",
+ cqe->flags, cqe->res);
+ return 1;
+ }
if (cqe->user_data >= nr_reqs) {
fprintf(stderr, "invalid user_data %lu\n",
(unsigned long)cqe->user_data);
return 1;
}
if (!(cqe->flags & IORING_CQE_F_NOTIF)) {
+ if (cqe->flags & IORING_CQE_F_MORE)
+ nr_cqes++;
if (cqe->user_data == nr_reqs - 1)
expected = chunk_size_last;
if (cqe->res != expected) {
@@ -362,12 +368,6 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
return 1;
}
}
- if ((cqe->flags & IORING_CQE_F_MORE) ==
- (cqe->flags & IORING_CQE_F_NOTIF)) {
- fprintf(stderr, "unexpected cflags %i res %i\n",
- cqe->flags, cqe->res);
- return 1;
- }
io_uring_cqe_seen(ring, cqe);
}
--
2.37.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH liburing 2/4] tests/zc: pass params in a struct
2022-09-29 0:03 [PATCH liburing 0/4] add more net tests Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 1/4] tests: improve zc cflags handling Pavel Begunkov
@ 2022-09-29 0:03 ` Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 3/4] tests: add non-zc tests in send-zerocopy.c Pavel Begunkov
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2022-09-29 0:03 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/send-zerocopy.c | 81 ++++++++++++++++++++++++--------------------
1 file changed, 45 insertions(+), 36 deletions(-)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index e58b11c..cdf71ea 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -249,25 +249,34 @@ static int prepare_ip(struct sockaddr_storage *addr, int *sock_client, int *sock
return 0;
}
+struct send_conf {
+ bool fixed_buf;
+ bool mix_register;
+ bool cork;
+ bool force_async;
+ bool use_sendmsg;
+ bool tcp;
+ int buf_index;
+ struct sockaddr_storage *addr;
+};
+
static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_server,
- bool fixed_buf, struct sockaddr_storage *addr,
- bool cork, bool mix_register,
- int buf_idx, bool force_async, bool use_sendmsg)
+ struct send_conf *conf)
{
struct iovec iov[CORK_REQS];
struct msghdr msghdr[CORK_REQS];
const unsigned zc_flags = 0;
struct io_uring_sqe *sqe;
struct io_uring_cqe *cqe;
- int nr_reqs = cork ? CORK_REQS : 1;
+ int nr_reqs = conf->cork ? CORK_REQS : 1;
int i, ret, nr_cqes, addr_len = 0;
- size_t send_size = buffers_iov[buf_idx].iov_len;
+ size_t send_size = buffers_iov[conf->buf_index].iov_len;
size_t chunk_size = send_size / nr_reqs;
size_t chunk_size_last = send_size - chunk_size * (nr_reqs - 1);
- char *buf = buffers_iov[buf_idx].iov_base;
+ char *buf = buffers_iov[conf->buf_index].iov_base;
- if (addr) {
- sa_family_t fam = ((struct sockaddr_in *)addr)->sin_family;
+ if (conf->addr) {
+ sa_family_t fam = ((struct sockaddr_in *)conf->addr)->sin_family;
addr_len = (fam == AF_INET) ? sizeof(struct sockaddr_in) :
sizeof(struct sockaddr_in6);
@@ -276,11 +285,11 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
memset(rx_buffer, 0, send_size);
for (i = 0; i < nr_reqs; i++) {
- bool real_fixed_buf = fixed_buf;
+ bool real_fixed_buf = conf->fixed_buf;
size_t cur_size = chunk_size;
int msg_flags = MSG_WAITALL;
- if (mix_register)
+ if (conf->mix_register)
real_fixed_buf = rand() & 1;
if (i != nr_reqs - 1)
@@ -290,15 +299,15 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
sqe = io_uring_get_sqe(ring);
- if (!use_sendmsg) {
+ if (!conf->use_sendmsg) {
io_uring_prep_send_zc(sqe, sock_client, buf + i * chunk_size,
cur_size, msg_flags, zc_flags);
if (real_fixed_buf) {
sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
- sqe->buf_index = buf_idx;
+ sqe->buf_index = conf->buf_index;
}
- if (addr)
- io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)addr,
+ if (conf->addr)
+ io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)conf->addr,
addr_len);
} else {
io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags);
@@ -308,13 +317,13 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
iov[i].iov_base = buf + i * chunk_size;
msghdr[i].msg_iov = &iov[i];
msghdr[i].msg_iovlen = 1;
- if (addr) {
- msghdr[i].msg_name = addr;
+ if (conf->addr) {
+ msghdr[i].msg_name = conf->addr;
msghdr[i].msg_namelen = addr_len;
}
}
sqe->user_data = i;
- if (force_async)
+ if (conf->force_async)
sqe->flags |= IOSQE_ASYNC;
if (i != nr_reqs - 1)
sqe->flags |= IOSQE_IO_LINK;
@@ -383,6 +392,7 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
static int test_inet_send(struct io_uring *ring)
{
+ struct send_conf conf;
struct sockaddr_storage addr;
int sock_client = -1, sock_server = -1;
int ret, j, i;
@@ -404,35 +414,34 @@ static int test_inet_send(struct io_uring *ring)
}
for (i = 0; i < 256; i++) {
- int buf_flavour = i & 3;
- bool fixed_buf = i & 4;
- struct sockaddr_storage *addr_arg = (i & 8) ? &addr : NULL;
- bool cork = i & 16;
- bool mix_register = i & 32;
- bool force_async = i & 64;
- bool use_sendmsg = i & 128;
-
- if (buf_flavour == BUF_T_LARGE && !tcp)
+ conf.buf_index = i & 3;
+ conf.fixed_buf = i & 4;
+ conf.addr = (i & 8) ? &addr : NULL;
+ conf.cork = i & 16;
+ conf.mix_register = i & 32;
+ conf.force_async = i & 64;
+ conf.use_sendmsg = i & 128;
+ conf.tcp = tcp;
+
+ if (conf.buf_index == BUF_T_LARGE && !tcp)
continue;
- if (!buffers_iov[buf_flavour].iov_base)
+ if (!buffers_iov[conf.buf_index].iov_base)
continue;
- if (tcp && (cork || addr_arg))
+ if (tcp && (conf.cork || conf.addr))
continue;
- if (mix_register && (!cork || fixed_buf))
+ if (conf.mix_register && (!conf.cork || conf.fixed_buf))
continue;
- if (!client_connect && addr_arg == NULL)
+ if (!client_connect && conf.addr == NULL)
continue;
- if (use_sendmsg && (mix_register || fixed_buf || !has_sendmsg))
+ if (conf.use_sendmsg && (conf.mix_register || conf.fixed_buf || !has_sendmsg))
continue;
- ret = do_test_inet_send(ring, sock_client, sock_server, fixed_buf,
- addr_arg, cork, mix_register,
- buf_flavour, force_async, use_sendmsg);
+ ret = do_test_inet_send(ring, sock_client, sock_server, &conf);
if (ret) {
fprintf(stderr, "send failed fixed buf %i, conn %i, addr %i, "
"cork %i\n",
- fixed_buf, client_connect, !!addr_arg,
- cork);
+ conf.fixed_buf, client_connect, !!conf.addr,
+ conf.cork);
return 1;
}
}
--
2.37.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH liburing 3/4] tests: add non-zc tests in send-zerocopy.c
2022-09-29 0:03 [PATCH liburing 0/4] add more net tests Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 1/4] tests: improve zc cflags handling Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 2/4] tests/zc: pass params in a struct Pavel Begunkov
@ 2022-09-29 0:03 ` Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 4/4] tests: add tests for retries with long iovec Pavel Begunkov
2022-09-29 12:54 ` [PATCH liburing 0/4] add more net tests Pavel Begunkov
4 siblings, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2022-09-29 0:03 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
We don't have good tests for normal non-zerocopy paths. Add them to
test_inet_send(), which covers lots of different cases. We can move
it into send_recv.c or so later.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/send-zerocopy.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index cdf71ea..b51f421 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -256,6 +256,7 @@ struct send_conf {
bool force_async;
bool use_sendmsg;
bool tcp;
+ bool zc;
int buf_index;
struct sockaddr_storage *addr;
};
@@ -300,8 +301,14 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
sqe = io_uring_get_sqe(ring);
if (!conf->use_sendmsg) {
- io_uring_prep_send_zc(sqe, sock_client, buf + i * chunk_size,
- cur_size, msg_flags, zc_flags);
+ if (conf->zc) {
+ io_uring_prep_send_zc(sqe, sock_client, buf + i * chunk_size,
+ cur_size, msg_flags, zc_flags);
+ } else {
+ io_uring_prep_send(sqe, sock_client, buf + i * chunk_size,
+ cur_size, msg_flags);
+ }
+
if (real_fixed_buf) {
sqe->ioprio |= IORING_RECVSEND_FIXED_BUF;
sqe->buf_index = conf->buf_index;
@@ -310,7 +317,10 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)conf->addr,
addr_len);
} else {
- io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags);
+ if (conf->zc)
+ io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags);
+ else
+ io_uring_prep_sendmsg(sqe, sock_client, &msghdr[i], msg_flags);
memset(&msghdr[i], 0, sizeof(msghdr[i]));
iov[i].iov_len = cur_size;
@@ -413,7 +423,7 @@ static int test_inet_send(struct io_uring *ring)
return 1;
}
- for (i = 0; i < 256; i++) {
+ for (i = 0; i < 512; i++) {
conf.buf_index = i & 3;
conf.fixed_buf = i & 4;
conf.addr = (i & 8) ? &addr : NULL;
@@ -421,8 +431,19 @@ static int test_inet_send(struct io_uring *ring)
conf.mix_register = i & 32;
conf.force_async = i & 64;
conf.use_sendmsg = i & 128;
+ conf.zc = i & 256;
conf.tcp = tcp;
+ if (!conf.zc) {
+ if (conf.mix_register || conf.fixed_buf)
+ continue;
+ /*
+ * Non zerocopy send w/ addr was added together with sendmsg_zc,
+ * skip if we the kernel doesn't support it.
+ */
+ if (conf.addr && !has_sendmsg)
+ continue;
+ }
if (conf.buf_index == BUF_T_LARGE && !tcp)
continue;
if (!buffers_iov[conf.buf_index].iov_base)
--
2.37.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH liburing 4/4] tests: add tests for retries with long iovec
2022-09-29 0:03 [PATCH liburing 0/4] add more net tests Pavel Begunkov
` (2 preceding siblings ...)
2022-09-29 0:03 ` [PATCH liburing 3/4] tests: add non-zc tests in send-zerocopy.c Pavel Begunkov
@ 2022-09-29 0:03 ` Pavel Begunkov
2022-09-29 12:54 ` [PATCH liburing 0/4] add more net tests Pavel Begunkov
4 siblings, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2022-09-29 0:03 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/send-zerocopy.c | 58 ++++++++++++++++++++++++++++++++++++++------
1 file changed, 50 insertions(+), 8 deletions(-)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index b51f421..adf730d 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -44,6 +44,7 @@
#define HOST "127.0.0.1"
#define HOSTV6 "::1"
+#define MAX_IOV 32
#define CORK_REQS 5
#define RX_TAG 10000
#define BUFFER_OFFSET 41
@@ -257,6 +258,8 @@ struct send_conf {
bool use_sendmsg;
bool tcp;
bool zc;
+ bool iovec;
+ bool long_iovec;
int buf_index;
struct sockaddr_storage *addr;
};
@@ -264,7 +267,7 @@ struct send_conf {
static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_server,
struct send_conf *conf)
{
- struct iovec iov[CORK_REQS];
+ struct iovec iov[MAX_IOV];
struct msghdr msghdr[CORK_REQS];
const unsigned zc_flags = 0;
struct io_uring_sqe *sqe;
@@ -276,6 +279,8 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
size_t chunk_size_last = send_size - chunk_size * (nr_reqs - 1);
char *buf = buffers_iov[conf->buf_index].iov_base;
+ assert(MAX_IOV >= CORK_REQS);
+
if (conf->addr) {
sa_family_t fam = ((struct sockaddr_in *)conf->addr)->sin_family;
@@ -317,16 +322,46 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)conf->addr,
addr_len);
} else {
+ struct iovec *io;
+ int iov_len;
+
if (conf->zc)
io_uring_prep_sendmsg_zc(sqe, sock_client, &msghdr[i], msg_flags);
else
io_uring_prep_sendmsg(sqe, sock_client, &msghdr[i], msg_flags);
+ if (!conf->iovec) {
+ io = &iov[i];
+ iov_len = 1;
+ iov[i].iov_len = cur_size;
+ iov[i].iov_base = buf + i * chunk_size;
+ } else {
+ char *it = buf;
+ int j;
+
+ assert(nr_reqs == 1);
+ iov_len = conf->long_iovec ? MAX_IOV : 4;
+ io = iov;
+
+ for (j = 0; j < iov_len; j++)
+ io[j].iov_len = 1;
+ /* first want to be easily advanced */
+ io[0].iov_base = it;
+ it += io[0].iov_len;
+ /* this should cause retry */
+ io[1].iov_len = chunk_size - iov_len + 1;
+ io[1].iov_base = it;
+ it += io[1].iov_len;
+ /* fill the rest */
+ for (j = 2; j < iov_len; j++) {
+ io[j].iov_base = it;
+ it += io[j].iov_len;
+ }
+ }
+
memset(&msghdr[i], 0, sizeof(msghdr[i]));
- iov[i].iov_len = cur_size;
- iov[i].iov_base = buf + i * chunk_size;
- msghdr[i].msg_iov = &iov[i];
- msghdr[i].msg_iovlen = 1;
+ msghdr[i].msg_iov = io;
+ msghdr[i].msg_iovlen = iov_len;
if (conf->addr) {
msghdr[i].msg_name = conf->addr;
msghdr[i].msg_namelen = addr_len;
@@ -423,7 +458,9 @@ static int test_inet_send(struct io_uring *ring)
return 1;
}
- for (i = 0; i < 512; i++) {
+ for (i = 0; i < 2048; i++) {
+ bool regbuf;
+
conf.buf_index = i & 3;
conf.fixed_buf = i & 4;
conf.addr = (i & 8) ? &addr : NULL;
@@ -432,10 +469,15 @@ static int test_inet_send(struct io_uring *ring)
conf.force_async = i & 64;
conf.use_sendmsg = i & 128;
conf.zc = i & 256;
+ conf.iovec = i & 512;
+ conf.long_iovec = i & 1024;
conf.tcp = tcp;
+ regbuf = conf.mix_register || conf.fixed_buf;
+ if (conf.iovec && (!conf.use_sendmsg || regbuf || conf.cork))
+ continue;
if (!conf.zc) {
- if (conf.mix_register || conf.fixed_buf)
+ if (regbuf)
continue;
/*
* Non zerocopy send w/ addr was added together with sendmsg_zc,
@@ -454,7 +496,7 @@ static int test_inet_send(struct io_uring *ring)
continue;
if (!client_connect && conf.addr == NULL)
continue;
- if (conf.use_sendmsg && (conf.mix_register || conf.fixed_buf || !has_sendmsg))
+ if (conf.use_sendmsg && (regbuf || !has_sendmsg))
continue;
ret = do_test_inet_send(ring, sock_client, sock_server, &conf);
--
2.37.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH liburing 0/4] add more net tests
2022-09-29 0:03 [PATCH liburing 0/4] add more net tests Pavel Begunkov
` (3 preceding siblings ...)
2022-09-29 0:03 ` [PATCH liburing 4/4] tests: add tests for retries with long iovec Pavel Begunkov
@ 2022-09-29 12:54 ` Pavel Begunkov
4 siblings, 0 replies; 6+ messages in thread
From: Pavel Begunkov @ 2022-09-29 12:54 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe
On 9/29/22 01:03, Pavel Begunkov wrote:
> NOT FOR THIS LIBURING RELEASE
I'll resend it with a few improvements later
>
> We need more testing for send/recv. This series extends zerocopy tests
> to non-zerocopy opcodes to cover 1) non-zc send() with address and
> 2) retrying sendmsg[zc]() with large iovecs to make sure we fixing
> up fast_iov right on short send.
>
> Pavel Begunkov (4):
> tests: improve zc cflags handling
> tests/zc: pass params in a struct
> tests: add non-zc tests in send-zerocopy.c
> tests: add tests for retries with long iovec
>
> test/send-zerocopy.c | 182 ++++++++++++++++++++++++++++++-------------
> 1 file changed, 127 insertions(+), 55 deletions(-)
>
--
Pavel Begunkov
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-09-29 12:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 0:03 [PATCH liburing 0/4] add more net tests Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 1/4] tests: improve zc cflags handling Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 2/4] tests/zc: pass params in a struct Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 3/4] tests: add non-zc tests in send-zerocopy.c Pavel Begunkov
2022-09-29 0:03 ` [PATCH liburing 4/4] tests: add tests for retries with long iovec Pavel Begunkov
2022-09-29 12:54 ` [PATCH liburing 0/4] add more net tests Pavel Begunkov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.