linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: Daniel Wagner <dwagner@suse.de>
Cc: Clark Williams <williams@redhat.com>, linux-rt-users@vger.kernel.org
Subject: Re: [rt-tests v2 12/18] queuelat: Streamline usage and man page
Date: Fri, 23 Oct 2020 14:40:27 -0400 (EDT)	[thread overview]
Message-ID: <10cde065-80c5-b5b-25b8-faaa6bfa8ed3@redhat.com> (raw)
In-Reply-To: <20201007085653.11961-13-dwagner@suse.de>



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/queuelat/queuelat.8 | 41 +++++++----------
>  src/queuelat/queuelat.c | 99 +++++++++++++++++++----------------------
>  2 files changed, 62 insertions(+), 78 deletions(-)
> 
> diff --git a/src/queuelat/queuelat.8 b/src/queuelat/queuelat.8
> index f67a0bb7556e..2f99e703c990 100644
> --- a/src/queuelat/queuelat.8
> +++ b/src/queuelat/queuelat.8
> @@ -15,9 +15,8 @@
>  .SH NAME
>  queuelat \- Queue latency test program
>  .SH SYNOPSIS
> -.B queuelat
> -.RI "[\-h] [\-m " max-queue-len "] [\-c " cycles-per-packet "] [\-p " mpps "] [\-f " tsc-freq "] [\-t " timeout "] \
> -
> +.LP
> +queuelat [-c|--cycles N] [-f|--freq F] [-h|--help] [-m|--max-len LEN] [-p|--packets F] [-q|--queue-len N] [-t|--timeout TIME]
>  .SH DESCRIPTION
>  queuelat simulates a network queue checking for latency
>  violations in packet processing.
> @@ -25,36 +24,26 @@ violations in packet processing.
>  .SH OPTIONS
>  A summary of options is included below.
>  .TP
> -.B \-h
> -Show help
> -.br
> +.B \-c, \-\-cycles=N
> +Estimated number of cycles it takes to process one packet. This value should come from the envisioned packet forwarding application being simulated.
>  .TP
> -.B \-m max-queue-len
> -Maximum allowed latency, in nanoseconds. If latency to process
> -.br
> -any packet exceeds this value, the program quits,
> -writing
> -.br
> -a message to the trace buffer.
> +.B \-f, \-\-freq=F
> +TSC frequency in MHz.
>  .TP
> -.B \-c cycles-per-packet
> -Estimated number of cycles it takes to process one packet.
> -.br
> -This value should come from the envisioned packet
> -.br
> -forwarding application being simulated.
> +.B \-h, \-\-help
> +Show help
>  .TP
> -.B \-p mpps
> +.B \-m, \-\-max-len=N
> +Maximum allowed latency, in nanoseconds. If latency to process any packet exceeds this value, the program quits, writing a message to the trace buffer.
> +.TP
> +.B \-p, \-\-packets=F
>  Million packets per second that arrive for processing.
>  .TP
> -.B \-f tsc-freq-mhz
> -TSC frequency in MHz.
> +.B \-q, \-\-queue-len=N
> +Minimum queue length to print in the trace
>  .TP
> -.B \-t timeout
> +.B \-t, \-\-timeout=TIME
>  Timeout in seconds to quit the program.
> -.TP
> -.B \-q min_queue_len_to_print_trace
> -Minimum queue length to print in the trace
>  
>  .SH AUTHOR
>  queuelat was written by Marcelo Tosatti <mtosatti@redhat.com>
> diff --git a/src/queuelat/queuelat.c b/src/queuelat/queuelat.c
> index 2b9118d8a8a5..661e48db88ac 100644
> --- a/src/queuelat/queuelat.c
> +++ b/src/queuelat/queuelat.c
> @@ -16,6 +16,7 @@
>  #include <unistd.h>
>  #include <signal.h>
>  #include <time.h>
> +#include <getopt.h>
>  
>  #include "rt-utils.h"
>  
> @@ -560,17 +561,20 @@ int calculate_nr_packets_drain_per_block(void)
>  	return nr_packets_drain_per_block;
>  }
>  
> -
> -void print_help(void)
> +static void print_help(int error)
>  {
> -	printf("usage: queuelat [options]\n");
> -	printf("-h show this help menu\n");
> -	printf("-m max-queue-len (maximum latency allowed, in nanoseconds) (int)\n");
> -	printf("-c cycles-per-packet (number of cycles to process one packet (int)\n");
> -	printf("-p million-packet-per-sec (million packets per second) (float)\n");
> -	printf("-f tsc-freq-mhz (TSC frequency in MHz) (float)\n");
> -	printf("-t timeout (timeout, in seconds) (int)\n");
> -	printf("-q min_queue_len_to_print_trace (int)\n");
> +	printf("queuelat V %1.2f\n", VERSION);
> +	printf("Usage:\n"
> +	       "queuelat <options>\n\n"
> +	       "-c N     --cycles N        number of cycles to process one packet (int)\n"
> +	       "-f F     --freq F          TSC frequency in MHz (float)\n"
> +	       "-h       --help            show this help menu\n"
> +	       "-m LEN   --max-len LEN     maximum latency allowed, in nanoseconds (int)\n"
> +	       "-p F     --packets F       million packets per second (float)\n"
> +	       "-q N     --queue-len N     minimum queue len to print trace (int)\n"
> +	       "-t TIME  --timeout TIME    timeout, in seconds (int)\n"
> +	       );
> +	exit(error);
>  }
>  
>  int main(int argc, char **argv)
> @@ -584,61 +588,59 @@ int main(int argc, char **argv)
>  	char *tvalue = NULL;
>  	char *qvalue = NULL;
>  	int index;
> -	int c;
> -
> -	install_signals();
>  
>  	opterr = 0;
>  
> -	while ((c = getopt (argc, argv, "m:c:p:f:t:q:h")) != -1)
> -		switch (c)
> -		{
> -		case 'm':
> -			mvalue = optarg;
> +	for (;;) {
> +		static struct option options[] = {
> +			{"cycles",	required_argument,	NULL, 'c'},
> +			{"freq",	required_argument,	NULL, 'f'},
> +			{"help",	no_argument,		NULL, 'h'},
> +			{"max-len",	required_argument,	NULL, 'm'},
> +			{"packets",	required_argument,	NULL, 'p'},
> +			{"queue-len",	required_argument,	NULL, 'q'},
> +			{"timeout",	required_argument,	NULL, 't'},
> +			{NULL, 0, NULL, 0}
> +		};
> +		int c = getopt_long(argc, argv, "c:f:hm:p:q:t:", options, NULL);
> +		if (c == -1)
>  			break;
> +		switch (c) {
>  		case 'c':
>  			cvalue = optarg;
>  			break;
> -		case 'p':
> -			pvalue = optarg;
> -			break;
>  		case 'f':
>  			fvalue = optarg;
>  			break;
> -		case 't':
> -			tvalue = optarg;
> +		case '?':
> +		case 'h':
> +			print_help(0);
> +			break;
> +		case 'm':
> +			mvalue = optarg;
> +			break;
> +		case 'p':
> +			pvalue = optarg;
>  			break;
>  		case 'q':
>  			qvalue = optarg;
>  			break;
> -		case 'h':
> -			print_help();
> -			return 0;
> -		case '?':
> -			if (optopt == 'm' || optopt == 'c' || optopt == 'p' ||
> -			    optopt == 'f' || optopt == 't' || optopt == 'q') {
> -				printf ("Option -%c requires an argument.\n", optopt);
> -			} else if (isprint (optopt)) {
> -				printf ("Unknown option `-%c'.\n", optopt);
> -				print_help();
> -				return 1;
> -			} else {
> -				printf ( "Unknown option character `\\x%x'.\n", optopt);
> -				print_help();
> -				return 1;
> -			}
> +		case 't':
> +			tvalue = optarg;
>  			break;
>  		default:
> -			abort ();
> +			print_help(1);
> +			break;
>  		}
> +	}
>  
> -	if (mvalue == NULL || cvalue == NULL || pvalue == NULL ||
> -	    fvalue == NULL) {
> -		printf("options -m, -c, -p and -f are required.\n");
> -		printf("usage: %s -m maxlatency -c cycles_per_packet -p mpps(million-packet-per-sec) -f tsc_freq_mhz [-t timeout (in secs)] [-q min_queue_len_to_print_trace]\n", argv[0]);
> -		return 1;
> +	if (mvalue == NULL || cvalue == NULL || pvalue == NULL || fvalue == NULL) {
> +		printf("options -m, -c, -p and -f are required\n");
> +		exit(1);
>  	}
>  
> +	install_signals();
> +
>  	maxlatency = atoi(mvalue);
>          cycles_per_packet = atoi(cvalue);
>          mpps = atof(pvalue);
> @@ -654,13 +656,6 @@ int main(int argc, char **argv)
>  		min_queue_size_to_print = atoi(qvalue);
>  	}
>  
> -	if (optind != argc) {
> -		for (index = optind; index < argc; index++) {
> -			printf ("Error, non-option argument %s\n", argv[index]);
> -		}
> -		return 1;
> -	}
> -
>  	convert_to_ghz(tsc_freq_mhz);
>  
>  	max_queue_len_f = maxlatency / (cycles_per_packet*cycles_to_ns);
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

  reply	other threads:[~2020-10-23 18:40 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 01/18] rt-util: Move parse_cpumask from cyclictest Daniel Wagner
2020-10-23 15:46   ` John Kacur
2020-10-26 18:34     ` Daniel Wagner
2020-10-29 15:45       ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 02/18] cyclictest: Use numa library helpers in get_available_cpus() Daniel Wagner
2020-10-23 15:55   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 03/18] cyclicdeadline: Streamline usage output and man page Daniel Wagner
2020-10-23 16:01   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 04/18] cyclicdeadline: Add long command line options Daniel Wagner
2020-10-23 16:07   ` John Kacur
2020-10-27  8:07     ` Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 05/18] deadline_test: Streamline usage output and man page Daniel Wagner
2020-10-23 16:10   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 06/18] oslat: " Daniel Wagner
2020-10-23 17:19   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 07/18] oslat: Use string parser utilies Daniel Wagner
2020-10-23 17:25   ` John Kacur
2020-10-27  8:09     ` Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 08/18] pip_stress: Add command line parser Daniel Wagner
2020-10-23 17:33   ` John Kacur
2020-10-27  8:09     ` Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 09/18] pi_stress: Streamline usage output and man page Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 10/18] pmqtest: " Daniel Wagner
2020-10-23 18:18   ` John Kacur
2020-10-23 18:23   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 11/18] ptsematest: " Daniel Wagner
2020-10-23 18:25   ` John Kacur
2021-02-10 16:08   ` Peter Xu
2021-02-10 16:25     ` Peter Xu
2021-02-10 16:30       ` Daniel Wagner
2021-02-10 16:33         ` Peter Xu
2021-02-10 16:35         ` Daniel Wagner
2021-02-10 17:00           ` Peter Xu
2021-02-10 17:24             ` Daniel Wagner
2020-10-07  8:56 ` [rt-tests v2 12/18] queuelat: Streamline usage " Daniel Wagner
2020-10-23 18:40   ` John Kacur [this message]
2020-10-07  8:56 ` [rt-tests v2 13/18] rt-migrate-test: " Daniel Wagner
2020-10-23 18:47   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 14/18] signaltest: " Daniel Wagner
2020-10-23 18:50   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 15/18] sigwaittest: " Daniel Wagner
2020-10-23 18:51   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 16/18] ssdd: " Daniel Wagner
2020-10-23 18:57   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 17/18] svsematest: " Daniel Wagner
2020-10-23 18:59   ` John Kacur
2020-10-07  8:56 ` [rt-tests v2 18/18] hackbench: " Daniel Wagner
2020-10-23 19:03   ` John Kacur

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=10cde065-80c5-b5b-25b8-faaa6bfa8ed3@redhat.com \
    --to=jkacur@redhat.com \
    --cc=dwagner@suse.de \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.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).