Skip to contentSkip to conversation

network: add test for low latency busy poll

PATCH New Alexey Kodanev 2 participants 8 messages Sep 16, 2015 – Oct 29, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 network: add test for low latency busy poll

The test measures the performance of TCP client/server with and without busy poll feature, then it compares results.

Enabling of busy poll is done globally via sysctl knobs, values are set to recommended ones (according to Linux docs).

The feature was added in Linux 3.11.

---
 runtest/network_stress.features            |    3 +
 testcases/network/busy_poll/Makefile       |   22 +++++++
 testcases/network/busy_poll/busy_poll01.sh |   92 ++++++++++++++++++++++++++++
 3 files changed, 117 insertions(+), 0 deletions(-)
 create mode 100644 testcases/network/busy_poll/Makefile
 create mode 100755 testcases/network/busy_poll/busy_poll01.sh
runtest/network_stress.features +3 -0
index f48f0a7..a94e13b 100644
@@ -2,6 +2,9 @@
 # Stress tests for various network features
 #
 
+busy_poll01 busy_poll01.sh
+busy_poll01_ipv6 busy_poll01.sh -6
+
 tcp_fastopen tcp_fastopen_run.sh
 tcp_fastopen6 tcp_fastopen_run.sh -6
 
testcases/network/busy_poll/Makefile new file +22 -0
new file mode 100644
index 0000000..8624fdf
@@ -0,0 +1,22 @@
+# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+INSTALL_TARGETS		:= busy_poll01.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/busy_poll/busy_poll01.sh new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/4 network: add test for low latency busy poll

Hi All,

Quoted 7 lines · Alexey Kodanev

The test measures the performance of TCP client/server with and without busy poll feature, then it compares results.

Enabling of busy poll is done globally via sysctl knobs, values are set to recommended ones (according to Linux docs).

The feature was added in Linux 3.11.

Any comments regarding this patch-set?

Thanks,
Alexey

#2 lore raw

PATCH 1/4 network: add test for low latency busy poll

Hi!

Quoted 1 line

Any comments regarding this patch-set?

I looked at the code and it looks good. I haven't looked deeper into the features it tries to test though.

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH 1/4 network: add test for low latency busy poll

Hi,

Quoted 4 lines · Cyril Hrubis

Hi!

Quoted 1 line

Any comments regarding this patch-set?

I looked at the code and it looks good. I haven't looked deeper into the features it tries to test though.

Thank you Cyril.

Best regards,
Alexey

#4 lore raw

PATCH 1/4 network: add test for low latency busy poll

Hi,

Patch-set applied.

Best regards,
Alexey

#5 lore raw

PATCH 2/4 network/tcp_fastopen: add SO_BUSY_POLL sockoption

In reply to Alexey Kodanev

Introduce new parameter 'b'. That way we can control whether sockets are using this feature or not.

---
 testcases/network/tcp_fastopen/tcp_fastopen.c |   28 ++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 3 deletions(-)
testcases/network/tcp_fastopen/tcp_fastopen.c +25 -3
index 08a6019..b42c8c2 100644
@@ -44,6 +44,10 @@ static const int max_msg_len = 1500;
 #define TCP_FASTOPEN	23
 #endif
 
+#ifndef SO_BUSY_POLL
+#define SO_BUSY_POLL	46
+#endif
+
 /* TCP client requiers */
 #ifndef MSG_FASTOPEN
 #define MSG_FASTOPEN	0x20000000 /* Send data in TCP SYN */
@@ -89,6 +93,7 @@ static int client_max_requests	= 10;
 static int clients_num		= 2;
 static char *tcp_port		= "61000";
 static char *server_addr	= "localhost";
+static int busy_poll		= -1;
 /* server socket */
 static int sfd;
 
@@ -101,7 +106,7 @@ static char *rpath		= "./tfo_result";
 static int force_run;
 static int verbose;
 
-static char *narg, *Narg, *qarg, *rarg, *Rarg, *aarg, *Targ;
+static char *narg, *Narg, *qarg, *rarg, *Rarg, *aarg, *Targ, *barg;
 
 static const option_t options[] = {
 	/* server params */
@@ -119,6 +124,7 @@ static const option_t options[] = {
 
 	/* common */
 	{"g:", NULL, &tcp_port},
+	{"b:", NULL, &barg},
 	{"F", &force_run, NULL},
 	{"l", &tcp_mode, NULL},
 	{"o", &fastopen_api, NULL},
@@ -135,6 +141,7 @@ static void help(void)
 	printf("  -O      TFO support is off, default is on\n");
 	printf("  -l      Become TCP Client, default is TCP server\n");
 	printf("  -g x    x - server port, default is %s\n", tcp_port);
+	printf("  -b x    x - low latency busy poll timeout\n");
 
 	printf("\n          Client:\n");
 	printf("  -H x    x - server name or ip address, default is '%s'\n",
@@ -269,11 +276,16 @@ static int client_connect_send(const char *msg, int size)
 {
 	int cfd = socket(remote_addrinfo->ai_family, SOCK_STREAM, 0);
 	const int flag = 1;
-	setsockopt(cfd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
 
 	if (cfd == -1)
 		return cfd;
 
+	setsockopt(cfd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
+	if (busy_poll >= 0) {
+		setsockopt(cfd, SOL_SOCKET, SO_BUSY_POLL,
+			   &busy_poll, sizeof(busy_poll));
+	}
+
 	if (fastopen_api == TFO_ENABLED) {
 		/* Replaces connect() + send()/write() */
 		if (sendto(cfd, msg, size, MSG_FASTOPEN | MSG_NOSIGNAL,
@@ -500,6 +512,11 @@ void *server_fn(void *cfd)
 	char recv_msg[max_msg_len];
 
 	setsockopt(client_fd, SOL_SOCKET, SO_LINGER, &clo, sizeof(clo));
+	if (busy_poll >= 0) {
+		setsockopt(client_fd, SOL_SOCKET, SO_BUSY_POLL,
+			   &busy_poll, sizeof(busy_poll));
+	}
+
 	ssize_t recv_len;
 
 	while (1) {
@@ -689,7 +706,6 @@ static void check_opt_l(const char *name, char *arg, long *val, long lim)
 
 static void setup(int argc, char *argv[])
 {
-	
 	tst_parse_opts(argc, argv, options, help);
 
 	/* if client_num is not set, use num of processors */
@@ -702,6 +718,7 @@ static void setup(int argc, char *argv[])
 	check_opt("N", Narg, &server_msg_size, 1);
 	check_opt("q", qarg, &tfo_queue_size, 1);
 	check_opt_l("T", Targ, &wait_timeout, 0L);
+	check_opt("b", barg, &busy_poll, 0);
 
 	if (!force_run)
 		tst_require_root();
@@ -711,6 +728,11 @@ static void setup(int argc, char *argv[])
 			"Test must be run with kernel 3.7 or newer");
 	}
 
+	if (!force_run && busy_poll >= 0 && tst_kvercmp(3, 11, 0) < 0) {
+		tst_brkm(TCONF, NULL,
+			"Test must be run with kernel 3.11 or newer");
+	}
+
 	/* check tcp fast open knob */
 	if (!force_run && access(tfo_cfg, F_OK) == -1)
 		tst_brkm(TCONF, NULL, "Failed to find '%s'", tfo_cfg);
Signature · 1 line
1.7.1
#6 lore raw

PATCH 3/4 lib/test_net.sh: allow any additional options to tst_netload

In reply to Alexey Kodanev
---
 testcases/lib/test_net.sh |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
testcases/lib/test_net.sh +10 -4
index b42337a..bd6f0d6 100644
@@ -251,17 +251,22 @@ tst_restore_ipaddr()
 	return $ret
 }
 
-# tst_netload ADDR [FILE] [TYPE]
+# tst_netload ADDR [FILE] [TYPE] [OPTS]
 # Run network load test
 # ADDR: IP address
 # FILE: file with result time
 # TYPE: PING or TFO (TCP traffic)
+# OPTS: additional options
 tst_netload()
 {
 	local ip_addr="$1"
 	local rfile=${2:-"netload.res"}
 	local type=${3:-"TFO"}
+	local addopts=${@:4}
 	local ret=0
+	clients_num=${clients_num:-"2"}
+	client_requests=${client_requests:-"500000"}
+	max_requests=${max_requests:-"3"}
 
 	case "$type" in
 	PING)
@@ -280,7 +285,8 @@ tst_netload()
 		[ $? -ne 0 ] && tst_brkm TBROK "failed to get unused port"
 
 		tst_resm TINFO "run tcp_fastopen with '$ip_addr', port '$port'"
-		tst_rhost_run -s -b -c "tcp_fastopen -R $max_requests -g $port"
+		tst_rhost_run -s -b -c "tcp_fastopen -R $max_requests \
+			-g $port $addopts"
 
 		# check that tcp_fastopen on rhost in 'Listening' state
 		local sec_waited=
@@ -294,8 +300,8 @@ tst_netload()
 		done
 
 		# run local tcp client
-		tcp_fastopen -a $clients_num -r $client_requests -l \
-			-H $ip_addr -g $port -d $rfile > /dev/null || ret=1
+		tcp_fastopen -a $clients_num -r $client_requests -l -H $ip_addr\
+			 -g $port -d $rfile $addopts > /dev/null || ret=1
 
 		if [ $ret -eq 0 -a ! -f $rfile ]; then
 			tst_brkm TBROK "can't read $rfile"
Signature · 1 line
1.7.1
#7 lore raw

PATCH 4/4 network: add test for busy poll with setting it per socket

In reply to Alexey Kodanev

Test is very similar to busy_poll01. The difference is in setting busy read value and enabling low latency busy poll feature. 'busy_read' is set per socket inside network load tool via SO_BUSY_POLL option.

---
 runtest/network_stress.features            |    3 +
 testcases/network/busy_poll/Makefile       |    3 +-
 testcases/network/busy_poll/busy_poll02.sh |   78 ++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+), 1 deletions(-)
 create mode 100755 testcases/network/busy_poll/busy_poll02.sh
runtest/network_stress.features +3 -0
index a94e13b..668f3da 100644
@@ -5,6 +5,9 @@
 busy_poll01 busy_poll01.sh
 busy_poll01_ipv6 busy_poll01.sh -6
 
+busy_poll02 busy_poll02.sh
+busy_poll02_ipv6 busy_poll02.sh -6
+
 tcp_fastopen tcp_fastopen_run.sh
 tcp_fastopen6 tcp_fastopen_run.sh -6
 
testcases/network/busy_poll/Makefile +2 -1
index 8624fdf..4fad061 100644
@@ -17,6 +17,7 @@ top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-INSTALL_TARGETS		:= busy_poll01.sh
+INSTALL_TARGETS		:= busy_poll01.sh \
+			   busy_poll02.sh
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/network/busy_poll/busy_poll02.sh new file +78 -0

78 lines not on this page · raw message

Signature · 1 line
1.7.1