diff mbox series

[liburing,1/1] examples/sendzc: test background polling

Message ID 152a9e0773920d0affd675d1e75983271bcd6732.1712535205.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series [liburing,1/1] examples/sendzc: test background polling | expand

Commit Message

Pavel Begunkov April 8, 2024, 12:14 a.m. UTC
There are some performance effects depending on whether the sock is
polled or not even when it never actually triggers. That applies to
non-zerocopy as well. Add a flag to test it.

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

Comments

Jens Axboe April 9, 2024, 3:46 a.m. UTC | #1
On Mon, 08 Apr 2024 01:14:00 +0100, Pavel Begunkov wrote:
> There are some performance effects depending on whether the sock is
> polled or not even when it never actually triggers. That applies to
> non-zerocopy as well. Add a flag to test it.
> 
> 

Applied, thanks!

[1/1] examples/sendzc: test background polling
      commit: f1dfb94bdaf1de14281030e28dd64f4d23d615a3

Best regards,
diff mbox series

Patch

diff --git a/examples/send-zerocopy.c b/examples/send-zerocopy.c
index 7ab58d7..691a0cc 100644
--- a/examples/send-zerocopy.c
+++ b/examples/send-zerocopy.c
@@ -74,6 +74,7 @@  static int  cfg_type		= 0;
 static int  cfg_payload_len;
 static int  cfg_port		= 8000;
 static int  cfg_runtime_ms	= 4200;
+static bool cfg_rx_poll		= false;
 
 static socklen_t cfg_alen;
 static char *str_addr = NULL;
@@ -370,6 +371,17 @@  static void do_tx(struct thread_data *td, int domain, int type, int protocol)
 	if (ret)
 		t_error(1, ret, "io_uring: buffer registration");
 
+	if (cfg_rx_poll) {
+		struct io_uring_sqe *sqe;
+
+		sqe = io_uring_get_sqe(&ring);
+		io_uring_prep_poll_add(sqe, fd, POLLIN);
+
+		ret = io_uring_submit(&ring);
+		if (ret != 1)
+			t_error(1, ret, "submit poll");
+	}
+
 	pthread_barrier_wait(&barrier);
 
 	tstart = gettimeofday_ms();
@@ -504,7 +516,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:dC:T:R")) != -1) {
+	while ((c = getopt(argc, argv, "46D:p:s:t:n:z:b:l:dC:T:Ry")) != -1) {
 		switch (c) {
 		case '4':
 			if (cfg_family != PF_UNSPEC)
@@ -556,6 +568,9 @@  static void parse_opts(int argc, char **argv)
 		case 'R':
 			cfg_rx = 1;
 			break;
+		case 'y':
+			cfg_rx_poll = 1;
+			break;
 		}
 	}