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 1/4] tests/zc: move send size calc into do_test_inet_send
Date: Mon,  5 Sep 2022 15:21:03 +0100	[thread overview]
Message-ID: <e9e818b93fd3c0f969ebf1c4a0869edaadb161dd.1662387423.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

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

diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 8714b6f..0a8531e 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -238,7 +238,7 @@ static int prepare_ip(struct sockaddr_storage *addr, int *sock_client, int *sock
 
 static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_server,
 			     bool fixed_buf, struct sockaddr_storage *addr,
-			     size_t send_size, bool cork, bool mix_register,
+			     bool small_send, bool cork, bool mix_register,
 			     int buf_idx, bool force_async)
 {
 	const unsigned zc_flags = 0;
@@ -246,13 +246,13 @@ static int do_test_inet_send(struct io_uring *ring, int sock_client, int sock_se
 	struct io_uring_cqe *cqe;
 	int nr_reqs = cork ? 5 : 1;
 	int i, ret, nr_cqes;
+	size_t send_size = small_send ? 137 : buffers_iov[buf_idx].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;
 	pid_t p;
 	int wstatus;
 
-	assert(send_size <= buffers_iov[buf_idx].iov_len);
 	memset(rx_buffer, 0, send_size);
 
 	for (i = 0; i < nr_reqs; i++) {
@@ -394,7 +394,7 @@ static int test_inet_send(struct io_uring *ring)
 		for (i = 0; i < 256; i++) {
 			bool fixed_buf = i & 1;
 			struct sockaddr_storage *addr_arg = (i & 2) ? &addr : NULL;
-			size_t size = (i & 4) ? 137 : 4096;
+			bool small_send = i & 4;
 			bool cork = i & 8;
 			bool mix_register = i & 16;
 			bool aligned = i & 32;
@@ -406,8 +406,7 @@ static int test_inet_send(struct io_uring *ring)
 				continue;
 			if (large_buf) {
 				buf_idx = 2;
-				size = buffers_iov[buf_idx].iov_len;
-				if (!aligned || !tcp)
+				if (!aligned || !tcp || small_send)
 					continue;
 			}
 			if (!buffers_iov[buf_idx].iov_base)
@@ -420,7 +419,7 @@ static int test_inet_send(struct io_uring *ring)
 				continue;
 
 			ret = do_test_inet_send(ring, sock_client, sock_server, fixed_buf,
-						addr_arg, size, cork, mix_register,
+						addr_arg, small_send, cork, mix_register,
 						buf_idx, force_async);
 			if (ret) {
 				fprintf(stderr, "send failed fixed buf %i, conn %i, addr %i, "
@@ -535,8 +534,8 @@ int main(int argc, char *argv[])
 		return T_EXIT_FAIL;
 	}
 
-	buffers_iov[0].iov_base = tx_buffer;
-	buffers_iov[0].iov_len = 8192;
+	buffers_iov[0].iov_base = tx_buffer + 4096;
+	buffers_iov[0].iov_len = 4096;
 	buffers_iov[1].iov_base = tx_buffer + BUFFER_OFFSET;
 	buffers_iov[1].iov_len = 8192 - BUFFER_OFFSET - 13;
 
-- 
2.37.2


  reply	other threads:[~2022-09-05 14:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 14:21 [PATCH liburing 0/4] zc tests improvements Pavel Begunkov
2022-09-05 14:21 ` Pavel Begunkov [this message]
2022-09-05 14:21 ` [PATCH liburing 2/4] tests/zc: use io_uring for rx Pavel Begunkov
2022-09-05 14:21 ` [PATCH liburing 3/4] tests/zc: fix udp testing Pavel Begunkov
2022-09-05 14:21 ` [PATCH liburing 4/4] tests/zc: name buffer flavours Pavel Begunkov
2022-09-05 15:00   ` Dylan Yudaken
2022-09-05 15:17     ` Pavel Begunkov

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=e9e818b93fd3c0f969ebf1c4a0869edaadb161dd.1662387423.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