public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [PATCH liburing v2 1/5] examples/send-zc: warn about data reordering
Date: Fri,  2 May 2025 17:53:58 +0100	[thread overview]
Message-ID: <c0612ea07d8678a2247e24d268a8929c2ad470ef.1746204705.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1746204705.git.asml.silence@gmail.com>

Data can be reordered if there are multiple outstanding write requests
for the same stream / TCP socket. That's fine for a benchmark, but warn
about it.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 examples/send-zerocopy.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/examples/send-zerocopy.c b/examples/send-zerocopy.c
index a50896c6..c83ef4d9 100644
--- a/examples/send-zerocopy.c
+++ b/examples/send-zerocopy.c
@@ -501,6 +501,7 @@ static void usage(const char *filepath)
 
 static void parse_opts(int argc, char **argv)
 {
+	const char *cfg_test;
 	const int max_payload_len = IP_MAXPACKET -
 				    sizeof(struct ipv6hdr) -
 				    sizeof(struct tcphdr) -
@@ -573,10 +574,22 @@ static void parse_opts(int argc, char **argv)
 		}
 	}
 
+	cfg_test = argv[argc - 1];
+	if (!strcmp(cfg_test, "tcp"))
+		cfg_type = SOCK_STREAM;
+	else if (!strcmp(cfg_test, "udp"))
+		cfg_type = SOCK_DGRAM;
+	else
+		t_error(1, 0, "unknown cfg_test %s", cfg_test);
+
 	if (cfg_nr_reqs > MAX_SUBMIT_NR)
 		t_error(1, 0, "-n: submit batch nr exceeds max (%d)", MAX_SUBMIT_NR);
 	if (cfg_payload_len > max_payload_len)
 		t_error(1, 0, "-s: payload exceeds max (%d)", max_payload_len);
+	if (!cfg_nr_reqs)
+		t_error(1, 0, "-n: submit batch can't be zero");
+	if (cfg_nr_reqs > 1 && cfg_type == SOCK_STREAM)
+		printf("warning: submit batching >1 with TCP sockets will cause data reordering");
 
 	str_addr = daddr;
 
@@ -589,7 +602,6 @@ int main(int argc, char **argv)
 	unsigned long long tsum = 0;
 	unsigned long long packets = 0, bytes = 0;
 	struct thread_data *td;
-	const char *cfg_test;
 	unsigned int i;
 	void *res;
 
@@ -607,14 +619,6 @@ int main(int argc, char **argv)
 		}
 	}
 
-	cfg_test = argv[argc - 1];
-	if (!strcmp(cfg_test, "tcp"))
-		cfg_type = SOCK_STREAM;
-	else if (!strcmp(cfg_test, "udp"))
-		cfg_type = SOCK_DGRAM;
-	else
-		t_error(1, 0, "unknown cfg_test %s", cfg_test);
-
 	pthread_barrier_init(&barrier, NULL, cfg_nr_threads);
 
 	for (i = 0; i < IP_MAXPACKET; i++)
-- 
2.48.1


  reply	other threads:[~2025-05-02 16:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02 16:53 [PATCH liburing v2 0/5] enchance zc benchmarks Pavel Begunkov
2025-05-02 16:53 ` Pavel Begunkov [this message]
2025-05-02 16:53 ` [PATCH liburing v2 2/5] examples/send-zc: option to bind socket to device Pavel Begunkov
2025-05-02 16:54 ` [PATCH liburing v2 3/5] examples/send-zc: optionally fill data with a pattern Pavel Begunkov
2025-05-02 16:54 ` [PATCH liburing v2 4/5] examples/send-zc: record time on disconnect Pavel Begunkov
2025-05-02 16:54 ` [PATCH liburing v2 5/5] examples/zcrx: be more verbose on verification failure Pavel Begunkov
2025-05-04 16:53 ` [PATCH liburing v2 0/5] enchance zc benchmarks 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=c0612ea07d8678a2247e24d268a8929c2ad470ef.1746204705.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    /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