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 v2 1/5] examples/send-zc: add defer taskrun support
Date: Sun,  5 Mar 2023 05:13:04 +0000	[thread overview]
Message-ID: <ba9e53c44f2342a02d7d5f8070eff13bbdf2d4e0.1677993039.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Signed-off-by: Pavel Begunkov <[email protected]>
---
 examples/send-zerocopy.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/examples/send-zerocopy.c b/examples/send-zerocopy.c
index 2844491..d60335c 100644
--- a/examples/send-zerocopy.c
+++ b/examples/send-zerocopy.c
@@ -48,6 +48,7 @@ static bool cfg_zc = 1;
 static int  cfg_nr_reqs = 8;
 static bool cfg_fixed_buf = 1;
 static bool cfg_hugetlb = 0;
+static bool cfg_defer_taskrun = 0;
 
 static int  cfg_family		= PF_UNSPEC;
 static int  cfg_payload_len;
@@ -151,6 +152,7 @@ static inline struct io_uring_cqe *wait_cqe_fast(struct io_uring *ring)
 
 static void do_tx(int domain, int type, int protocol)
 {
+	const int notif_slack = 128;
 	unsigned long packets = 0;
 	unsigned long bytes = 0;
 	struct io_uring ring;
@@ -158,10 +160,14 @@ static void do_tx(int domain, int type, int protocol)
 	uint64_t tstop;
 	int i, fd, ret;
 	int compl_cqes = 0;
+	int ring_flags = IORING_SETUP_COOP_TASKRUN | IORING_SETUP_SINGLE_ISSUER;
+
+	if (cfg_defer_taskrun)
+		ring_flags |= IORING_SETUP_DEFER_TASKRUN;
 
 	fd = do_setup_tx(domain, type, protocol);
 
-	ret = io_uring_queue_init(512, &ring, IORING_SETUP_COOP_TASKRUN);
+	ret = io_uring_queue_init(512, &ring, ring_flags);
 	if (ret)
 		t_error(1, ret, "io_uring: queue init");
 
@@ -211,7 +217,11 @@ static void do_tx(int domain, int type, int protocol)
 			}
 		}
 
-		ret = io_uring_submit(&ring);
+		if (cfg_defer_taskrun && compl_cqes >= notif_slack)
+			ret = io_uring_submit_and_get_events(&ring);
+		else
+			ret = io_uring_submit(&ring);
+
 		if (ret != cfg_nr_reqs)
 			t_error(1, ret, "submit");
 
@@ -292,7 +302,7 @@ static void parse_opts(int argc, char **argv)
 
 	cfg_payload_len = max_payload_len;
 
-	while ((c = getopt(argc, argv, "46D:p:s:t:n:z:b:l:")) != -1) {
+	while ((c = getopt(argc, argv, "46D:p:s:t:n:z:b:l:d")) != -1) {
 		switch (c) {
 		case '4':
 			if (cfg_family != PF_UNSPEC)
@@ -330,6 +340,9 @@ static void parse_opts(int argc, char **argv)
 		case 'l':
 			cfg_hugetlb = strtoul(optarg, NULL, 0);
 			break;
+		case 'd':
+			cfg_defer_taskrun = 1;
+			break;
 		}
 	}
 
-- 
2.39.1


  reply	other threads:[~2023-03-05  5:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-05  5:13 [PATCH liburing v2 0/5] sendzc test improvements Pavel Begunkov
2023-03-05  5:13 ` Pavel Begunkov [this message]
2023-03-05  5:13 ` [PATCH liburing v2 2/5] examples/send-zc: add affinity / CPU pinning Pavel Begunkov
2023-03-05  5:13 ` [PATCH liburing v2 3/5] examples/send-zc: add multithreading Pavel Begunkov
2023-03-05  5:13 ` [PATCH liburing v2 4/5] examples/send-zc: add the receive part Pavel Begunkov
2023-03-05  5:13 ` [PATCH liburing v2 5/5] examples/send-zc: kill sock bufs configuration Pavel Begunkov
2023-03-05 14:35 ` [PATCH liburing v2 0/5] sendzc test improvements 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=ba9e53c44f2342a02d7d5f8070eff13bbdf2d4e0.1677993039.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