All of lore.kernel.org
 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 18/18] hackbench: Streamline usage and man page
Date: Fri, 23 Oct 2020 15:03:46 -0400 (EDT)	[thread overview]
Message-ID: <2d173492-e397-b099-e466-3571d56cb4e5@redhat.com> (raw)
In-Reply-To: <20201007085653.11961-19-dwagner@suse.de>



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/hackbench/hackbench.8 |  70 ++++++++++++++------------
>  src/hackbench/hackbench.c | 102 ++++++++++++++++++--------------------
>  2 files changed, 86 insertions(+), 86 deletions(-)
> 
> diff --git a/src/hackbench/hackbench.8 b/src/hackbench/hackbench.8
> index aaf572359704..4c2c8ad9cb1a 100644
> --- a/src/hackbench/hackbench.8
> +++ b/src/hackbench/hackbench.8
> @@ -1,13 +1,17 @@
> -.TH "hackbench" "8" "February  23, 2010" "" ""
> +.TH "hackbench" "8" "September  19, 2020" "" ""
>  .SH "NAME"
>  hackbench \- scheduler benchmark/stress test
>  .SH "SYNOPSIS"
>  .B hackbench
> -.RI "[\-p|\-\-pipe] [\-s|\-\-datasize " <bytes> "] " 
> -.RI "[\-l|\-\-loops " <num\-loops> "] "
> -.RI "[\-g|\-\-groups "<num\-groups> "] "
> -.RI "[\-f|\-\-fds <num\-fds>] "
> -.RI "[\-T|\-\-threads] [\-P|\-\-process] [\-F|\-\-fifo] [\-\-help]"
> +.RI "[\-f|\-\-fds NUM] "
> +.RI "[\-F|\-\-fifo] "
> +.RI "[\-g|\-\-groups NUM] "
> +.RI "[\-h|\-\-help] "
> +.RI "[\-l|\-\-loops LOOPS] "
> +.RI "[\-p|\-\-pipe] "
> +.RI "[\-s|\-\-datasize SIZE] "
> +.RI "[\-T|\-\-threads]"
> +.RI "[\-P|\-\-process]"
>  
>  .SH "DESCRIPTION"
>  Hackbench is both a benchmark and a stress test for the Linux kernel
> @@ -19,45 +23,45 @@ each pair to send data back and forth.
>  .SH "OPTIONS"
>  These programs follow the usual GNU command line syntax, with long
>  options starting with two dashes ("\-\-").
> -.br 
> +.br
>  A summary of options is included below.
> -.TP 
> +.TP
> +.B \-f, \-\-fds=NUM
> +Defines how many file descriptors each child should use.
> +Note that the effective number will be twice the amount you set here,
> +as the sender and receiver children will each open the given amount of
> +file descriptors.
> +.TP
> +.B \-F,\-\-fifo
> +Change the main thread to SCHED_FIFO after creating workers.
> +This allows the management thread to run after many workers are created.
> +.TP
> +.B \-g, \-\-groups=NUM
> +Defines how many groups of senders and receivers should be started
> +.TP
> +.B \-h, \-\-help
> +.TP
> +.B \-l, \-\-loops=LOOPS
> +How many messages each sender/receiver pair should send
> +.TP
>  .B \-p, \-\-pipe
>  Sends the data via a pipe instead of the socket (default)
> -.TP 
> -.B \-s, \-\-datasize=<size in bytes>
> +.TP
> +.B \-s, \-\-datasize=SIZE
>  Sets the amount of data to send in each message
> -.TP 
> -.B \-l, \-\-loops=<number of loops>
> -How many messages each sender/receiver pair should send
> -.TP 
> -.B \-g, \-\-groups=<number of groups>
> -Defines how many groups of senders and receivers should be started
> -.TP 
> -.B \-f, \-\-fds=<number of file descriptors>
> -Defines how many file descriptors each child should use. 
> -Note that the effective number will be twice the amount you set here,
> -as the sender and receiver children will each open the given amount of 
> -file descriptors.
> -.TP 
> +.TP
>  .B \-T, \-\-threads
>  Each sender/receiver child will be a POSIX thread of the parent.
> -.TP 
> +.TP
>  .B \-P, \-\-process
>  Hackbench will use fork() on all children (default behaviour)
> -.TP
> -.B \-F,\-\-fifo
> -Change the main thread to SCHED_FIFO after creating workers.
> -This allows the management thread to run after many workers are created.
> -.TP 
> -.B \-\-help
> -.br 
> +.br
>  Shows a simple help screen
>  .SH "EXAMPLES"
> -.LP 
> +.LP
>  Running hackbench without any options will give default behaviour,
>  using fork() and sending data between senders and receivers via sockets.
> -.LP 
> +.LP
>  user@host: ~ $ hackbench
>  .br 
>  Running in process mode with 10 groups using 40 file descriptors each (== 400 tasks)
> diff --git a/src/hackbench/hackbench.c b/src/hackbench/hackbench.c
> index 2cddff654df6..268c23233004 100644
> --- a/src/hackbench/hackbench.c
> +++ b/src/hackbench/hackbench.c
> @@ -88,12 +88,22 @@ static void barf(const char *msg)
>  	exit(1);
>  }
>  
> -static void print_usage_exit()
> +static void print_usage_exit(int error)
>  {
> -	printf("Usage: hackbench [-p|--pipe] [-s|--datasize <bytes>] [-l|--loops <num loops>]\n"
> -	       "\t\t [-g|--groups <num groups] [-f|--fds <num fds>]\n"
> -	       "\t\t [-T|--threads] [-P|--process] [-F|--fifo] [--help]\n");
> -	exit(1);
> +	printf("hackbench V %1.2f\n", VERSION);
> +	printf("Usage:\n"
> +	       "hackbench <options>\n\n"
> +	       "-f       --fds=NUM         number of fds\n"
> +	       "-F       --fifo            use SCHED_FIFO for main thread\n"
> +	       "-g       --groups=NUM      number of groups to be used\n"
> +	       "-h       --help            print this message\n"
> +	       "-l       --loops=LOOPS     how many message should be send\n"
> +	       "-p       --pipe            send data via a pipe\n"
> +	       "-s       --datasize=SIZE   message size\n"
> +	       "-T       --threads         use POSIX threads\n"
> +	       "-P       --process         use fork (default)\n"
> +	       );
> +	exit(error);
>  }
>  
>  static void fdpair(int fds[2])
> @@ -342,86 +352,72 @@ static unsigned int group(childinfo_t *child,
>  	return num_fds * 2;
>  }
>  
> -static void process_options (int argc, char *argv[])
> +static void process_options(int argc, char *argv[])
>  {
> -	int error = 0;
> -
> -	while( 1 ) {
> +	for(;;) {
>  		int optind = 0;
>  
>  		static struct option longopts[] = {
> -			{"pipe",      no_argument,	 NULL, 'p'},
> -			{"datasize",  required_argument, NULL, 's'},
> -			{"loops",     required_argument, NULL, 'l'},
> -			{"groups",    required_argument, NULL, 'g'},
> -			{"fds",	      required_argument, NULL, 'f'},
> -			{"threads",   no_argument,	 NULL, 'T'},
> -			{"processes", no_argument,	 NULL, 'P'},
> -			{"fifo",      no_argument,       NULL, 'F'},
> -			{"help",      no_argument,	 NULL, 'h'},
> +			{"fds",		required_argument,	NULL, 'f'},
> +			{"fifo",	no_argument,		NULL, 'F'},
> +			{"groups",	required_argument,	NULL, 'g'},
> +			{"help",	no_argument,		NULL, 'h'},
> +			{"loops",	required_argument,	NULL, 'l'},
> +			{"pipe",	no_argument,		NULL, 'p'},
> +			{"datasize",	required_argument,	NULL, 's'},
> +			{"threads",	no_argument,		NULL, 'T'},
> +			{"processes",	no_argument,		NULL, 'P'},
>  			{NULL, 0, NULL, 0}
>  		};
>  
> -		int c = getopt_long(argc, argv, "ps:l:g:f:TPFh",
> +		int c = getopt_long(argc, argv, "f:Fg:hl:ps:TP",
>  				    longopts, &optind);
>  		if (c == -1) {
>  			break;
>  		}
>  		switch (c) {
> -		case 'p':
> -			use_pipes = 1;
> +		case 'f':
> +			if (!(argv[optind] && (num_fds = atoi(optarg)) > 0)) {
> +				fprintf(stderr, "%s: --fds|-f requires an integer > 0\n", argv[0]);
> +				print_usage_exit(1);
> +			}
>  			break;
> -
> -		case 's':
> -			if (!(argv[optind] && (datasize = atoi(optarg)) > 0)) {
> -				fprintf(stderr, "%s: --datasize|-s requires an integer > 0\n", argv[0]);
> -				error = 1;
> +		case 'F':
> +			fifo = 1;
> +			break;
> +		case 'g':
> +			if (!(argv[optind] && (num_groups = atoi(optarg)) > 0)) {
> +				fprintf(stderr, "%s: --groups|-g requires an integer > 0\n", argv[0]);
> +				print_usage_exit(1);
>  			}
>  			break;
> -
> +		case 'h':
> +			print_usage_exit(0);
>  		case 'l':
>  			if (!(argv[optind] && (loops = atoi(optarg)) > 0)) {
>  				fprintf(stderr, "%s: --loops|-l requires an integer > 0\n", argv[0]);
> -				error = 1;
> +				print_usage_exit(1);
>  			}
>  			break;
> -
> -		case 'g':
> -			if (!(argv[optind] && (num_groups = atoi(optarg)) > 0)) {
> -				fprintf(stderr, "%s: --groups|-g requires an integer > 0\n", argv[0]);
> -				error = 1;
> -			}
> +		case 'p':
> +			use_pipes = 1;
>  			break;
> -
> -		case 'f':
> -			if (!(argv[optind] && (num_fds = atoi(optarg)) > 0)) {
> -				fprintf(stderr, "%s: --fds|-f requires an integer > 0\n", argv[0]);
> -				error = 1;
> +		case 's':
> +			if (!(argv[optind] && (datasize = atoi(optarg)) > 0)) {
> +				fprintf(stderr, "%s: --datasize|-s requires an integer > 0\n", argv[0]);
> +				print_usage_exit(1);
>  			}
>  			break;
> -
>  		case 'T':
>  			process_mode = THREAD_MODE;
>  			break;
>  		case 'P':
>  			process_mode = PROCESS_MODE;
>  			break;
> -
> -		case 'F':
> -			fifo = 1;
> -			break;
> -
> -		case 'h':
> -			print_usage_exit();
> -
>  		default:
> -			error = 1;
> +			print_usage_exit(1);
>  		}
>  	}
> -
> -	if( error ) {
> -		exit(1);
> -	}
>  }
>  
>  void sigcatcher(int sig) {
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

      reply	other threads:[~2020-10-23 19:03 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
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 [this message]

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=2d173492-e397-b099-e466-3571d56cb4e5@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.