Commit 5090147c authored by Jian Yang's avatar Jian Yang Committed by David S. Miller

selftests: txtimestamp: add new command-line flags.

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: default avatarJian Yang <jianyang@google.com>
Acked-by: default avatarWillem de Bruijn <willemb@google.com>
Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 70a7ee96
......@@ -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,9 +554,10 @@ 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);
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment