public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 6/6] test/zc: test short zc send
Date: Thu,  4 Aug 2022 15:20:25 +0100	[thread overview]
Message-ID: <6ee389d6b720356ec2a8c677a34a852c761c1627.1659622771.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Zerocopy send should hide short writes for stream sockets, test it.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/send-zerocopy.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 617e7a0..307c114 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -54,7 +54,7 @@
 
 static int seqs[NR_SLOTS];
 static char *tx_buffer, *rx_buffer;
-static struct iovec buffers_iov[2];
+static struct iovec buffers_iov[3];
 
 static inline bool tag_userdata(__u64 user_data)
 {
@@ -662,7 +662,7 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
 	for (i = 0; i < nr_reqs; i++) {
 		bool cur_fixed_buf = fixed_buf;
 		size_t cur_size = chunk_size;
-		int msg_flags = 0;
+		int msg_flags = MSG_WAITALL;
 
 		if (mix_register)
 			cur_fixed_buf = rand() & 1;
@@ -791,15 +791,26 @@ static int test_inet_send(struct io_uring *ring)
 			return 1;
 		}
 
-		for (i = 0; i < 64; i++) {
+		for (i = 0; i < 128; i++) {
 			bool fixed_buf = i & 1;
 			struct sockaddr_storage *addr_arg = (i & 2) ? &addr : NULL;
 			size_t size = (i & 4) ? 137 : 4096;
 			bool cork = i & 8;
 			bool mix_register = i & 16;
 			bool aligned = i & 32;
+			bool large_buf = i & 64;
 			int buf_idx = aligned ? 0 : 1;
 
+			if (!tcp || !large_buf)
+				continue;
+			if (large_buf) {
+				buf_idx = 2;
+				size = buffers_iov[buf_idx].iov_len;
+				if (!aligned || !tcp)
+					continue;
+			}
+			if (!buffers_iov[buf_idx].iov_base)
+				continue;
 			if (tcp && cork)
 				continue;
 			if (mix_register && (!cork || fixed_buf))
@@ -829,22 +840,33 @@ int main(int argc, char *argv[])
 {
 	struct io_uring ring;
 	int i, ret, sp[2];
-	size_t len = 8096;
+	size_t len;
 
 	if (argc > 1)
 		return T_EXIT_SKIP;
 
+	len = 1U << 25; /* 32MB, should be enough to trigger a short send */
 	tx_buffer = aligned_alloc(4096, len);
 	rx_buffer = aligned_alloc(4096, len);
+	if (tx_buffer && rx_buffer) {
+		buffers_iov[2].iov_base = tx_buffer;
+		buffers_iov[2].iov_len = len;
+	} else {
+		printf("skip large buffer tests, can't alloc\n");
+
+		len = 8192;
+		tx_buffer = aligned_alloc(4096, len);
+		rx_buffer = aligned_alloc(4096, len);
+	}
 	if (!tx_buffer || !rx_buffer) {
 		fprintf(stderr, "can't allocate buffers\n");
 		return T_EXIT_FAIL;
 	}
 
 	buffers_iov[0].iov_base = tx_buffer;
-	buffers_iov[0].iov_len = len;
+	buffers_iov[0].iov_len = 8192;
 	buffers_iov[1].iov_base = tx_buffer + BUFFER_OFFSET;
-	buffers_iov[1].iov_len = len - BUFFER_OFFSET - 13;
+	buffers_iov[1].iov_len = 8192 - BUFFER_OFFSET - 13;
 
 	ret = io_uring_queue_init(32, &ring, 0);
 	if (ret) {
-- 
2.37.0


  parent reply	other threads:[~2022-08-04 14:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 14:20 [PATCH liburing 0/6] improve zeoropy testing Pavel Begunkov
2022-08-04 14:20 ` [PATCH liburing 1/6] test/zc: improve error messages Pavel Begunkov
2022-08-04 14:20 ` [PATCH liburing 2/6] tests/zc: test tcp Pavel Begunkov
2022-08-04 14:20 ` [PATCH liburing 3/6] test/zc: allocate buffers dynamically Pavel Begunkov
2022-08-04 14:20 ` [PATCH liburing 4/6] test/zc: handle short rx Pavel Begunkov
2022-08-04 14:20 ` [PATCH liburing 5/6] test/zc: recv asynchronously Pavel Begunkov
2022-08-04 14:20 ` Pavel Begunkov [this message]
2022-08-04 22:22 ` [PATCH liburing 0/6] improve zeoropy testing Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ee389d6b720356ec2a8c677a34a852c761c1627.1659622771.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox