netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jian Yang <jianyang.kernel@gmail.com>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: Soheil Hassas Yeganeh <soheil@google.com>,
	Willem de Bruijn <willemb@google.com>,
	Jian Yang <jianyang@google.com>
Subject: [PATCH net-next 3/5] selftests: txtimestamp: add new command-line flags.
Date: Tue, 17 Mar 2020 12:25:07 -0700	[thread overview]
Message-ID: <20200317192509.150725-4-jianyang.kernel@gmail.com> (raw)
In-Reply-To: <20200317192509.150725-1-jianyang.kernel@gmail.com>

From: Jian Yang <jianyang@google.com>

A longer sleep duration between sendmsg()s makes more cachelines to be
evicted and results in higher latency. Making the duration configurable.

Add the following new flags:
-S: Configurable sleep duration.
-b: Busy loop instead of poll().

Remove the following flag:
-D: No delay between packets: subsumed by -S.

Signed-off-by: Jian Yang <jianyang@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
---
 .../networking/timestamping/txtimestamp.c     | 24 ++++++++++++-------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/networking/timestamping/txtimestamp.c b/tools/testing/selftests/networking/timestamping/txtimestamp.c
index a9b8c41a3009..ee060ae3d44f 100644
--- a/tools/testing/selftests/networking/timestamping/txtimestamp.c
+++ b/tools/testing/selftests/networking/timestamping/txtimestamp.c
@@ -65,8 +65,9 @@ static int cfg_delay_snd;
 static int cfg_delay_ack;
 static bool cfg_show_payload;
 static bool cfg_do_pktinfo;
+static bool cfg_busy_poll;
+static int cfg_sleep_usec = 50 * 1000;
 static bool cfg_loop_nodata;
-static bool cfg_no_delay;
 static bool cfg_use_cmsg;
 static bool cfg_use_pf_packet;
 static bool cfg_do_listen;
@@ -553,10 +554,11 @@ static void do_test(int family, unsigned int report_opt)
 			error(1, errno, "send");
 
 		/* wait for all errors to be queued, else ACKs arrive OOO */
-		if (!cfg_no_delay)
-			usleep(50 * NSEC_PER_USEC);
+		if (cfg_sleep_usec)
+			usleep(cfg_sleep_usec);
 
-		__poll(fd);
+		if (!cfg_busy_poll)
+			__poll(fd);
 
 		while (!recv_errmsg(fd)) {}
 	}
@@ -575,9 +577,9 @@ static void __attribute__((noreturn)) usage(const char *filepath)
 			"  -4:   only IPv4\n"
 			"  -6:   only IPv6\n"
 			"  -h:   show this message\n"
+			"  -b:   busy poll to read from error queue\n"
 			"  -c N: number of packets for each test\n"
 			"  -C:   use cmsg to set tstamp recording options\n"
-			"  -D:   no delay between packets\n"
 			"  -F:   poll() waits forever for an event\n"
 			"  -I:   request PKTINFO\n"
 			"  -l N: send N bytes at a time\n"
@@ -588,6 +590,7 @@ static void __attribute__((noreturn)) usage(const char *filepath)
 			"  -P:   use PF_PACKET\n"
 			"  -r:   use raw\n"
 			"  -R:   use raw (IP_HDRINCL)\n"
+			"  -S N: usec to sleep before reading error queue\n"
 			"  -u:   use udp\n"
 			"  -v:   validate SND delay (usec)\n"
 			"  -V:   validate ACK delay (usec)\n"
@@ -601,7 +604,7 @@ static void parse_opt(int argc, char **argv)
 	int proto_count = 0;
 	int c;
 
-	while ((c = getopt(argc, argv, "46c:CDFhIl:LnNp:PrRuv:V:x")) != -1) {
+	while ((c = getopt(argc, argv, "46bc:CFhIl:LnNp:PrRS:uv:V:x")) != -1) {
 		switch (c) {
 		case '4':
 			do_ipv6 = 0;
@@ -609,15 +612,15 @@ static void parse_opt(int argc, char **argv)
 		case '6':
 			do_ipv4 = 0;
 			break;
+		case 'b':
+			cfg_busy_poll = true;
+			break;
 		case 'c':
 			cfg_num_pkts = strtoul(optarg, NULL, 10);
 			break;
 		case 'C':
 			cfg_use_cmsg = true;
 			break;
-		case 'D':
-			cfg_no_delay = true;
-			break;
 		case 'F':
 			cfg_poll_timeout = -1;
 			break;
@@ -655,6 +658,9 @@ static void parse_opt(int argc, char **argv)
 			cfg_proto = SOCK_RAW;
 			cfg_ipproto = IPPROTO_RAW;
 			break;
+		case 'S':
+			cfg_sleep_usec = strtoul(optarg, NULL, 10);
+			break;
 		case 'u':
 			proto_count++;
 			cfg_proto = SOCK_DGRAM;
-- 
2.25.1.481.gfbce0eb801-goog


  parent reply	other threads:[~2020-03-17 19:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17 19:25 [PATCH net-next 0/5] selftests: expand txtimestamp with new features Jian Yang
2020-03-17 19:25 ` [PATCH net-next 1/5] selftests: txtimestamp: allow individual txtimestamp tests Jian Yang
2020-03-17 19:25 ` [PATCH net-next 2/5] selftests: txtimestamp: allow printing latencies in nsec Jian Yang
2020-03-17 19:25 ` Jian Yang [this message]
2020-03-17 19:25 ` [PATCH net-next 4/5] selftests: txtimestamp: add support for epoll() Jian Yang
2020-03-17 19:25 ` [PATCH net-next 5/5] selftests: txtimestamp: print statistics for timestamp events Jian Yang
2020-03-17 20:33 ` [PATCH net-next 0/5] selftests: expand txtimestamp with new features Jakub Kicinski
2020-03-17 20:39   ` Willem de Bruijn
2020-03-17 21:54     ` Jakub Kicinski
2020-03-22  3:13     ` David Miller
2020-03-22  3:13 ` David Miller

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=20200317192509.150725-4-jianyang.kernel@gmail.com \
    --to=jianyang.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jianyang@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=soheil@google.com \
    --cc=willemb@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).