linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [rt-tests v2 00/18] Streamline command line
@ 2020-10-07  8:56 Daniel Wagner
  2020-10-07  8:56 ` [rt-tests v2 01/18] rt-util: Move parse_cpumask from cyclictest Daniel Wagner
                   ` (17 more replies)
  0 siblings, 18 replies; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Hi,

Here the second round getting the some more consistency into the code
base. With this all the commands should at least look the same and use
an consistent option name. I've tried to make it backwards compatible,
except for oslat (--duration).

Thanks,
Daniel

changes since v1:
  - updated all existing tools

Daniel Wagner (18):
  rt-util: Move parse_cpumask from cyclictest
  cyclictest: Use numa library helpers in get_available_cpus()
  cyclicdeadline: Streamline usage output and man page
  cyclicdeadline: Add long command line options
  deadline_test: Streamline usage output and man page
  oslat: Streamline usage output and man page
  oslat: Use string parser utilies
  pip_stress: Add command line parser
  pi_stress: Streamline usage output and man page
  pmqtest: Streamline usage output and man page
  ptsematest: Streamline usage output and man page
  queuelat: Streamline usage and man page
  rt-migrate-test: Streamline usage and man page
  signaltest: Streamline usage and man page
  sigwaittest: Streamline usage and man page
  ssdd: Streamline usage and man page
  svsematest: Streamline usage and man page
  hackbench: Streamline usage and man page

 Makefile                              |  12 +--
 src/cyclictest/cyclictest.c           |  90 +++-------------
 src/hackbench/hackbench.8             |  70 +++++++------
 src/hackbench/hackbench.c             | 102 +++++++++---------
 src/include/rt-utils.h                |   3 +
 src/lib/rt-utils.c                    |  76 ++++++++++++++
 src/oslat/oslat.8                     |   2 +-
 src/oslat/oslat.c                     | 145 +++++++-------------------
 src/pi_tests/pi_stress.8              |  79 +++++++-------
 src/pi_tests/pi_stress.c              | 144 +++++++++++++------------
 src/pi_tests/pip_stress.c             |  34 +++++-
 src/pmqtest/pmqtest.8                 |   5 +-
 src/pmqtest/pmqtest.c                 |  88 ++++++++--------
 src/ptsematest/ptsematest.8           |   5 +-
 src/ptsematest/ptsematest.c           |  76 +++++++-------
 src/queuelat/queuelat.8               |  41 +++-----
 src/queuelat/queuelat.c               |  99 +++++++++---------
 src/rt-migrate-test/rt-migrate-test.8 |  41 ++++----
 src/rt-migrate-test/rt-migrate-test.c |  82 +++++++--------
 src/sched_deadline/cyclicdeadline.8   |  25 ++---
 src/sched_deadline/cyclicdeadline.c   |  67 +++++++-----
 src/sched_deadline/deadline_test.8    |  37 ++++---
 src/sched_deadline/deadline_test.c    |  47 ++++-----
 src/signaltest/signaltest.8           |  13 +--
 src/signaltest/signaltest.c           |  47 +++++----
 src/sigwaittest/sigwaittest.8         |   4 +-
 src/sigwaittest/sigwaittest.c         |  76 ++++++++------
 src/ssdd/ssdd.8                       |  35 +++----
 src/ssdd/ssdd.c                       |  50 +++++----
 src/svsematest/svsematest.8           |   6 +-
 src/svsematest/svsematest.c           |  83 ++++++++-------
 31 files changed, 854 insertions(+), 830 deletions(-)

-- 
2.28.0


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [rt-tests v2 01/18] rt-util: Move parse_cpumask from cyclictest
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 15:46   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 02/18] cyclictest: Use numa library helpers in get_available_cpus() Daniel Wagner
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

In order to be reuse the cpumask parsing code, move it to libary.
Several tools implement their own version of this. Let's use one
global one instead.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 Makefile                    | 12 +++---
 src/cyclictest/cyclictest.c | 68 +++++++--------------------------
 src/include/rt-utils.h      |  3 ++
 src/lib/rt-utils.c          | 76 +++++++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+), 61 deletions(-)

diff --git a/Makefile b/Makefile
index c3ebbd7b2a2e..3627084437c1 100644
--- a/Makefile
+++ b/Makefile
@@ -20,9 +20,14 @@ sources = cyclictest.c \
 	  ssdd.c \
 	  oslat.c
 
+# You have to have libnuma installed, which is fine to do even if you are
+# running on non-numa machines
+CFLAGS += -DNUMA
+NUMA_LIBS = -lnuma
+
 TARGETS = $(sources:.c=)
 LIBS	= -lrt -lpthread
-RTTESTLIB = -lrttest -L$(OBJDIR)
+RTTESTLIB = -lrttest -L$(OBJDIR) $(NUMA_LIBS)
 EXTRA_LIBS ?= -ldl	# for get_cpu
 DESTDIR	?=
 prefix  ?= /usr/local
@@ -79,11 +84,6 @@ ostype := $(lastword $(subst -, ,$(dumpmachine)))
 machinetype := $(shell echo $(dumpmachine)| \
     sed -e 's/-.*//' -e 's/i.86/i386/' -e 's/mips.*/mips/' -e 's/ppc.*/powerpc/')
 
-# You have to have libnuma installed, which is fine to do even if you are
-# running on non-numa machines
-CFLAGS += -DNUMA
-NUMA_LIBS = -lnuma
-
 include src/arch/android/Makefile
 
 VPATH	= src/cyclictest:
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index b41d42f13f24..02cb92813fb7 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -908,11 +908,6 @@ static int clocksources[] = {
 	CLOCK_REALTIME,
 };
 
-static unsigned int is_cpumask_zero(const struct bitmask *mask)
-{
-	return (rt_numa_bitmask_count(mask) == 0);
-}
-
 /* Get available cpus according to getaffinity or according to the
  * intersection of getaffinity and the user specified affinity
  * in the case of AFFINITY_SPECIFIED, the function has to be called
@@ -997,52 +992,6 @@ static int cpu_for_thread_ua(int thread_num, int max_cpus)
 	return 0;
 }
 
-
-/* After this function is called, affinity_mask is the intersection of the user
- * supplied affinity mask and the affinity mask from the run time environment */
-static void use_current_cpuset(const int max_cpus)
-{
-	int i;
-	pid_t pid;
-	struct bitmask *curmask;
-
-	pid = getpid();
-
-	curmask = numa_allocate_cpumask();
-	numa_sched_getaffinity(pid, curmask);
-
-	/* Clear bits that are not set in both the cpuset from the environment,
-	 * and in the user specified affinity for cyclictest */
-	for (i=0; i < max_cpus; i++) {
-		if ((!rt_numa_bitmask_isbitset(affinity_mask, i)) || (!rt_numa_bitmask_isbitset(curmask, i))) {
-			numa_bitmask_clearbit(affinity_mask, i);
-		}
-	}
-
-	numa_bitmask_free(curmask);
-}
-
-static void parse_cpumask(const char *option, const int max_cpus)
-{
-	affinity_mask = rt_numa_parse_cpustring(option, max_cpus);
-	if (affinity_mask) {
-		if (is_cpumask_zero(affinity_mask)) {
-			rt_bitmask_free(affinity_mask);
-			affinity_mask = NULL;
-		} else {
-			use_current_cpuset(max_cpus);
-		}
-
-	}
-	if (!affinity_mask)
-		display_help(1);
-
-	if (verbose) {
-		printf("%s: Using %u cpus.\n", __func__,
-			rt_numa_bitmask_count(affinity_mask));
-	}
-}
-
 static void handlepolicy(char *polname)
 {
 	if (strncasecmp(polname, "other", 5) == 0)
@@ -1176,15 +1125,24 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			if (smp)
 				break;
 			numa_initialize();
-			if (optarg != NULL) {
-				parse_cpumask(optarg, max_cpus);
+			if (optarg) {
+				parse_cpumask(optarg, max_cpus, &affinity_mask);
 				setaffinity = AFFINITY_SPECIFIED;
-			} else if (optind<argc && (atoi(argv[optind]) || argv[optind][0] == '0' || argv[optind][0] == '!')) {
-				parse_cpumask(argv[optind], max_cpus);
+			} else if (optind < argc &&
+				   (atoi(argv[optind]) ||
+				    argv[optind][0] == '0' ||
+				    argv[optind][0] == '!')) {
+				parse_cpumask(argv[optind], max_cpus, &affinity_mask);
 				setaffinity = AFFINITY_SPECIFIED;
 			} else {
 				setaffinity = AFFINITY_USEALL;
 			}
+
+			if (setaffinity == AFFINITY_SPECIFIED && !affinity_mask)
+				display_help(1);
+			if (verbose)
+				printf("Using %u cpus.\n",
+					numa_bitmask_weight(affinity_mask));
 			break;
 		case 'A':
 		case OPT_ALIGNED:
diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
index 4ed1cbc53ece..3b97655a20f2 100644
--- a/src/include/rt-utils.h
+++ b/src/include/rt-utils.h
@@ -3,6 +3,7 @@
 #define __RT_UTILS_H
 
 #include <stdint.h>
+#include <numa.h>
 
 #define _STR(x) #x
 #define STR(x) _STR(x)
@@ -28,6 +29,8 @@ uint32_t string_to_policy(const char *str);
 pid_t gettid(void);
 
 int parse_time_string(char *val);
+int parse_mem_string(char *str, uint64_t *val);
+int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask);
 
 void enable_trace_mark(void);
 void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
index f786588706cd..302b91388df5 100644
--- a/src/lib/rt-utils.c
+++ b/src/lib/rt-utils.c
@@ -362,6 +362,82 @@ int parse_time_string(char *val)
 	return t;
 }
 
+int parse_mem_string(char *str, uint64_t *val)
+{
+	char *endptr;
+	int v = strtol(str, &endptr, 10);
+
+	if (!*endptr)
+		return v;
+
+	switch (*endptr) {
+	case 'g':
+	case 'G':
+		v *= 1024;
+	case 'm':
+	case 'M':
+		v *= 1024;
+	case 'k':
+	case 'K':
+		v *= 1024;
+	case 'b':
+	case 'B':
+		break;
+	default:
+		return -1;
+	}
+
+	*val = v;
+
+	return 0;
+}
+
+/*
+ * After this function is called, affinity_mask is the intersection of
+ * the user supplied affinity mask and the affinity mask from the run
+ * time environment
+ */
+static void use_current_cpuset(int max_cpus, struct bitmask *cpumask)
+{
+	struct bitmask *curmask;
+	int i;
+
+	curmask = numa_allocate_cpumask();
+	numa_sched_getaffinity(getpid(), curmask);
+
+	/*
+	 * Clear bits that are not set in both the cpuset from the
+	 * environment, and in the user specified affinity.
+	 */
+	for (i = 0; i < max_cpus; i++) {
+		if ((!numa_bitmask_isbitset(cpumask, i)) ||
+		    (!numa_bitmask_isbitset(curmask, i)))
+			numa_bitmask_clearbit(cpumask, i);
+	}
+
+	numa_bitmask_free(curmask);
+}
+
+int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask)
+{
+	struct bitmask *mask;
+
+	mask = numa_parse_cpustring_all(str);
+	if (!mask)
+		return -ENOMEM;
+
+	if (numa_bitmask_weight(mask) == 0) {
+		numa_bitmask_free(mask);
+		*cpumask = NULL;
+		return 0;
+	}
+
+	use_current_cpuset(max_cpus, mask);
+	*cpumask = mask;
+
+	return 0;
+}
+
 void open_tracemark_fd(void)
 {
 	char path[MAX_PATH];
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 02/18] cyclictest: Use numa library helpers in get_available_cpus()
  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-07  8:56 ` 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
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

The numa library has support for counting the bits in the affinity
mask and how many CPUs are available and usable by the tasks. Let's
use those helpers.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/cyclictest/cyclictest.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 02cb92813fb7..d7477c686435 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -915,26 +915,10 @@ static int clocksources[] = {
  */
 static int get_available_cpus(void)
 {
-	int num_cpus = 0;
-	int res;
-	pthread_t thread;
-	cpu_set_t cpuset;
-
-
-	if (affinity_mask != NULL) {
-		num_cpus = rt_numa_bitmask_count(affinity_mask);
-	} else {
-		CPU_ZERO(&cpuset);
-		thread = pthread_self();
-		res = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
-		if (res != 0) {
-			fatal("pthread_getaffinity_np failed: %s\n", strerror(res));
-		}
-		num_cpus = CPU_COUNT(&cpuset);
-	}
-
-	return num_cpus;
+	if (affinity_mask)
+		return numa_bitmask_weight(affinity_mask);
 
+	return numa_num_task_cpus();
 }
 
 /* cpu_for_thread AFFINITY_SPECIFIED */
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 03/18] cyclicdeadline: Streamline usage output and man page
  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-07  8:56 ` [rt-tests v2 02/18] cyclictest: Use numa library helpers in get_available_cpus() Daniel Wagner
@ 2020-10-07  8:56 ` 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
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/sched_deadline/cyclicdeadline.8 | 24 ++++++++---------
 src/sched_deadline/cyclicdeadline.c | 41 +++++++++++++++--------------
 2 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8
index 91766fb391c4..6df7faf445f9 100644
--- a/src/sched_deadline/cyclicdeadline.8
+++ b/src/sched_deadline/cyclicdeadline.8
@@ -17,7 +17,7 @@ cyclicdeadline \- This program is used to test the deadline scheduler (SCHED_DEA
 .PP
 .SH SYNOPSIS
 .B cyclicdeadline
-.RI "[-ha] [-c cpulist] [-i interval] [-s step] [-t nr_threads] [-D duration]
+.RI "[-ha] [-c CPUSET] [-D TIME] [-i INTV] [-s STEP] [-t NUM]"
 .PP
 .SH DESCRIPTION
 .B cyclicdeadline
@@ -25,28 +25,28 @@ is a cyclictest style program for testing the deadline scheduler
 .PP
 .SH OPTIONS
 .TP
-.B \-h
-Show this help menu
-.TP
 .B \-a
 Use all CPUs
 .TP
-.B \-c cpulist
+.B \-c CPUSET
 Comma / hypen separated list of CPUs to run deadline tasks on
 .TP
-.B \-i interval
+.B \-D TIME
+Specify a length for the test to run
+Append 'm', 'h', or 'd' to specify minutes, hours, or days
+.TP
+.B \-h
+Show this help menu
+.TP
+.B \-i INTV
 The shortest deadline for the tasks in us. (default 1000us)
 .TP
-.B \-s step
+.B \-s STEP
 The amount to increase the deadline for each task in us. (default 500us)
 .TP
-.B \-t nr_threads
+.B \-t NUM
 The number of threads to run as deadline (default 1)
-.TP
-.B \-D time
-Specify a length for the test to run
 .br
-Append 'm', 'h', or 'd' to specify minutes, hours, or days
 .SH AUTHOR
 cyclicdeadline was written by Steven Rostedt <rostedt@goodmis.org>
 .PP
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index a08e28e73c42..310880805553 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -630,26 +630,25 @@ static void teardown(void)
 	destroy_cpuset(CPUSET_LOCAL, 1);
 }
 
-static void usage(char **argv)
+static void usage(int error)
 {
-	char *arg = argv[0];
-	char *p = arg+strlen(arg);
-
-	while (p >= arg && *p != '/')
-		p--;
-	p++;
-
-	printf("usage: %s [options]\n"
-	       " -h - Show this help menu\n"
-	       " -a - Use all CPUs\n"
-	       " -c cpulist - Comma/hyphen separated list of CPUs to run deadline tasks on\n"
-	       " -i interval(us) - The shortest deadline for the tasks (default 1000us)\n"
-	       " -s step(us) - The amount to increase the deadline for each task (default 500us)\n"
-	       " -t threads - The number of threads to run as deadline (default 1)\n"
-	       " -D time - Specify a length for the test run\n"
-	       "           Append 'm', 'h', or 'd' to specify minutes, hours or days\n"
-	       "\n", p);
-	exit(-1);
+	printf("cyclicdeadline V %1.2f\n", VERSION);
+	printf("Usage:\n"
+	       "cyclicdeadline <options>\n\n"
+	       "-a                         Use all CPUs\n"
+	       "-c CPUSET                  Comma/hyphen separated list of CPUs to run deadline\n"
+	       "                           tasks on.\n"
+	       "-D TIME                    Specify a length for the test run.\n"
+	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
+	       "                           days\n"
+	       "-h                         Show this help menu.\n"
+	       "-i INTV                    The shortest deadline for the tasks in us\n"
+	       "                           (default 1000us).\n"
+	       "-s STEP                    The amount to increase the deadline for each task in us\n"
+	       "                           (default 500us).\n"
+	       "-t NUM                     The number of threads to run as deadline (default 1).\n"
+	       );
+	exit(error);
 }
 
 static int fail;
@@ -1057,8 +1056,10 @@ int main (int argc, char **argv)
 			duration = parse_time_string(optarg);
 			break;
 		case 'h':
+			usage(0);
+			break;
 		default:
-			usage(argv);
+			usage(1);
 		}
 	}
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 04/18] cyclicdeadline: Add long command line options
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (2 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 03/18] cyclicdeadline: Streamline usage output and man page Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 16:07   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 05/18] deadline_test: Streamline usage output and man page Daniel Wagner
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Use getopt_long to parse long version of the commands.

Change the 'a/affinity' option to handle all cases including what '-c'
did. We still keep '-c' silently supported to avoid breaking existing
users.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/sched_deadline/cyclicdeadline.8 | 17 +++++-------
 src/sched_deadline/cyclicdeadline.c | 42 ++++++++++++++++++++---------
 2 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8
index 6df7faf445f9..def42f77044a 100644
--- a/src/sched_deadline/cyclicdeadline.8
+++ b/src/sched_deadline/cyclicdeadline.8
@@ -17,7 +17,7 @@ cyclicdeadline \- This program is used to test the deadline scheduler (SCHED_DEA
 .PP
 .SH SYNOPSIS
 .B cyclicdeadline
-.RI "[-ha] [-c CPUSET] [-D TIME] [-i INTV] [-s STEP] [-t NUM]"
+.RI "[-a [CPUSET]] [-D TIME] [-h]  [-i INTV] [-s STEP] [-t NUM]"
 .PP
 .SH DESCRIPTION
 .B cyclicdeadline
@@ -25,26 +25,23 @@ is a cyclictest style program for testing the deadline scheduler
 .PP
 .SH OPTIONS
 .TP
-.B \-a
-Use all CPUs
-.TP
-.B \-c CPUSET
+.B \-a \-\-affinity [CPUSET]
 Comma / hypen separated list of CPUs to run deadline tasks on
 .TP
-.B \-D TIME
+.B \-D \-\-duration TIME
 Specify a length for the test to run
 Append 'm', 'h', or 'd' to specify minutes, hours, or days
 .TP
-.B \-h
+.B \-h \-\-help
 Show this help menu
 .TP
-.B \-i INTV
+.B \-i \-\-interval INTV
 The shortest deadline for the tasks in us. (default 1000us)
 .TP
-.B \-s STEP
+.B \-s \-\-step STEP
 The amount to increase the deadline for each task in us. (default 500us)
 .TP
-.B \-t NUM
+.B \-t \-\-threads NUM
 The number of threads to run as deadline (default 1)
 .br
 .SH AUTHOR
diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
index 310880805553..5f5cdfa08f14 100644
--- a/src/sched_deadline/cyclicdeadline.c
+++ b/src/sched_deadline/cyclicdeadline.c
@@ -17,6 +17,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
+#include <getopt.h>
 
 #include <sys/syscall.h>
 #include <sys/types.h>
@@ -635,18 +636,19 @@ static void usage(int error)
 	printf("cyclicdeadline V %1.2f\n", VERSION);
 	printf("Usage:\n"
 	       "cyclicdeadline <options>\n\n"
-	       "-a                         Use all CPUs\n"
-	       "-c CPUSET                  Comma/hyphen separated list of CPUs to run deadline\n"
-	       "                           tasks on.\n"
-	       "-D TIME                    Specify a length for the test run.\n"
+	       "-a [CPUSET] --affinity     Comma/hyphen separated list of CPUs to run deadline\n"
+	       "                           tasks on. An empty CPUSET runs on all CPUs a deadline\n"
+	       "                           task.\n"
+	       "                           on CPU 4, and thread #5 on CPU 5.\n"
+	       "-D TIME     --duration     Specify a length for the test run.\n"
 	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
 	       "                           days\n"
-	       "-h                         Show this help menu.\n"
-	       "-i INTV                    The shortest deadline for the tasks in us\n"
+	       "-h          --help         Show this help menu.\n"
+	       "-i INTV     --interval     The shortest deadline for the tasks in us\n"
 	       "                           (default 1000us).\n"
-	       "-s STEP                    The amount to increase the deadline for each task in us\n"
+	       "-s STEP     --step         The amount to increase the deadline for each task in us\n"
 	       "                           (default 500us).\n"
-	       "-t NUM                     The number of threads to run as deadline (default 1).\n"
+	       "-t NUM      --threads      The number of threads to run as deadline (default 1).\n"
 	       );
 	exit(error);
 }
@@ -1033,15 +1035,29 @@ int main (int argc, char **argv)
 		exit(-1);
 	}
 
-	while ((c = getopt(argc, argv, "+hac:i:s:t:D:")) >= 0) {
+	for (;;) {
+		static struct option options[] = {
+			{ "affinity",	optional_argument,	NULL,	'a' },
+			{ "duration",	required_argument,	NULL,	'D' },
+			{ "help",	no_argument,		NULL,	'h' },
+			{ "interval",	required_argument,	NULL,	'i' },
+			{ "threads",	required_argument,	NULL,	't' },
+			{ NULL,		0,			NULL,	0   },
+		};
+		c = getopt_long(argc, argv, "a::c:D:hi:t:", options, NULL);
+		if (c == -1)
+			break;
 		switch (c) {
 		case 'a':
-			all_cpus = 1;
+		case 'c':
 			if (!nr_threads)
 				nr_threads = cpu_count;
-			break;
-		case 'c':
-			setcpu = optarg;
+			if (optarg)
+				setcpu = optarg;
+			else if (optind < argc)
+				setcpu = argv[optind];
+			else
+				all_cpus = 1;
 			break;
 		case 'i':
 			interval = atoi(optarg);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 05/18] deadline_test: Streamline usage output and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (3 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 04/18] cyclicdeadline: Add long command line options Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 16:10   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 06/18] oslat: " Daniel Wagner
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/sched_deadline/deadline_test.8 | 37 ++++++++++++-----------
 src/sched_deadline/deadline_test.c | 47 +++++++++++++++---------------
 2 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/src/sched_deadline/deadline_test.8 b/src/sched_deadline/deadline_test.8
index 5dc99c0bfc63..8f32c5b6feb6 100644
--- a/src/sched_deadline/deadline_test.8
+++ b/src/sched_deadline/deadline_test.8
@@ -19,45 +19,44 @@ deadline_test \- High resolution test program
 This program is used to test the deadline scheduler (SCHED_DEADLINE tasks)
 .SH SYNOPSIS
 .B deadline_test
-.RI "[ \-hb ] [ \-r prio ] [ \-c cpulist ] [ \-i interval ] [ \-p percent ] [ \-P percent ] [ \-t threads ] [ \-s step[us) ]"
-
+.RI "[ \-hb ] [ \-c CPUSET ] [ \-i INTV ] [ \-p PERCENT ] [ \-P PERCENT ] \
+[ \-r PRIO ]  [ \-s STEP ] [ \-t NUM ]"
 .SH OPTIONS
 .TP
-.B \-h
-Show this help menu
-.br
-.TP
 .B \-b
 Bind on the last cpu. (shortcut for -c <lastcpu>)
 .br
 .TP
-.B \-r prio
-Add an RT task with given prio to stress system
+.B \-c CPUSET
+Comma/hyphen separated list of CPUs to run deadline tasks on
 .br
 .TP
-.B \-c cpulist
-Comma/hyphen separated list of CPUs to run deadline tasks on
+.B \-h
+Show this help menu
 .br
 .TP
-.B \-i interval
+.B \-i INTV
 The shortest deadline for the tasks
 .br
 .TP
-.B \-p percent
+.B \-p PERCENT
 The percent of bandwidth to use (1-90%)
 .br
 .TP
-.B \-P percent
-The percent of runtime for execution completion
-              (Default 100%)
+.B \-P PERCENT
+The percent of runtime for execution completion (default 100%)
 .br
 .TP
-.B \-t threads
-The number of threads to run as deadline (default 1)
+.B \-r PRIO
+Add an RT task with given prio to stress system
 .br
 .TP
-.B \-s step(us)
-The amount to increase the deadline for each task (default 500us)
+.B \-s STEP
+The amount to increase the deadline for each task in us (default 500us)
+.br
+.TP
+.B \-t NUM
+The number of threads to run as deadline (default 1)
 .br
 .SH AUTHOR
 Deadline test was written by Steven Rostedt <rostedt@goodmis.org>
diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
index 4cef2609912e..060ac896aef2 100644
--- a/src/sched_deadline/deadline_test.c
+++ b/src/sched_deadline/deadline_test.c
@@ -46,33 +46,30 @@
 
 /**
  * usage - show the usage of the program and exit.
- * @argv: The program passed in args
+ * @error: Exit error code to be used
  *
- * This is defined here to show people looking at this code how
+ * This is defined here to show peoplde looking at this code how
  * to use this program as well. 
  */
-static void usage(char **argv)
+static void usage(int error)
 {
-	char *arg = argv[0];
-	char *p = arg+strlen(arg);
-
-	while (p >= arg && *p != '/')
-		p--;
-	p++;
-
-	printf("usage: %s [options]\n"
-	       " -h - Show this help menu\n"
-	       " -b - Bind on the last cpu. (shortcut for -c <lastcpu>)\n"
-	       " -r prio - Add an RT task with given prio to stress system\n"
-	       " -c cpulist - Comma/hyphen separated list of CPUs to run deadline tasks on\n"
-	       " -i interval - The shortest deadline for the tasks\n"
-	       " -p percent - The percent of bandwidth to use (1-90%%)\n"
-	       " -P percent - The percent of runtime for execution completion\n"
-	       "              (Default 100%%)\n"
-	       " -t threads - The number of threads to run as deadline (default 1)\n"
-	       " -s step(us) - The amount to increase the deadline for each task (default 500us)\n"
-	       "\n", p);
-	exit(-1);
+	printf("deadline_test V %1.2f\n", VERSION);
+	printf("Usage:\n"
+	       "deadline_test <options>\n"
+	       "-b                         Bind on the last cpu. (shortcut for -c <lastcpu>)\n"
+	       "-c CPUSET                  Comma/hyphen separated list of CPUs to run deadline\n"
+	       "                           tasks on\n"
+	       "-h                         Show this help menu\n"
+	       "-i INTV                    The shortest deadline for the tasks\n"
+	       "-p PERCENT                 The percent of bandwidth to use (1-90%%)\n"
+	       "-P PERCENT                 The percent of runtime for execution completion\n"
+	       "                           (default 100%%)\n"
+	       "-r PRIO                    Add an RT task with given prio to stress system\n"
+	       "-s STEP                    The amount to increase the deadline for each task in us\n"
+	       "                           (default 500us)\n"
+	       "-t NUM                     The number of threads to run as deadline (default 1)\n"
+	       );
+	exit(error);
 }
 
 #define _STR(x) #x
@@ -1753,8 +1750,10 @@ int main (int argc, char **argv)
 			rt_task = atoi(optarg);
 			break;
 		case 'h':
+			usage(0);
+			break;
 		default:
-			usage(argv);
+			usage(1);
 		}
 	}
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 06/18] oslat: Streamline usage output and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (4 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 05/18] deadline_test: Streamline usage output and man page Daniel Wagner
@ 2020-10-07  8:56 ` 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
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/oslat/oslat.8 |  2 +-
 src/oslat/oslat.c | 78 ++++++++++++++++++++++-------------------------
 2 files changed, 38 insertions(+), 42 deletions(-)

diff --git a/src/oslat/oslat.8 b/src/oslat/oslat.8
index 85f2c5bcdf5c..b481d8d82783 100644
--- a/src/oslat/oslat.8
+++ b/src/oslat/oslat.8
@@ -36,7 +36,7 @@ Total memory usage will be this value multiplies 2*N,
 because there will be src/dst buffers for each thread, and
 N is the number of processors for testing.
 .TP
-.B \-t, \-\-runtime=SEC
+.B \-D, \-\-duration=TIME
 Specify test duration, e.g., 60, 20m, 2H (m/M: minutes, h/H: hours, d/D: days).
 By default the unit is s/second.
 .TP
diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index f1a82f2367d2..fafbdd694326 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -507,42 +507,37 @@ static void handle_alarm(int code)
 	g.cmd = STOP;
 }
 
-const char *helpmsg =
-"Usage: %s [options]\n"
-"\n"
-"This is an OS latency detector by running busy loops on specified cores.\n"
-"Please run this tool using root.\n"
-"\n"
-"Available options:\n"
-"\n"
-"  -b, --bucket-size      Specify the number of the buckets (4-1024)\n"
-"  -B, --bias             Add a bias to all the buckets using the estimated mininum\n"
-"  -c, --cpu-list         Specify CPUs to run on, e.g. '1,3,5,7-15'\n"
-"  -C, --cpu-main-thread  Specify which CPU the main thread runs on.  Default is cpu0.\n"
-"  -f, --rtprio           Using SCHED_FIFO priority (1-99)\n"
-"  -m, --workload-mem     Size of the memory to use for the workload (e.g., 4K, 1M).\n"
-"                         Total memory usage will be this value multiplies 2*N,\n"
-"                         because there will be src/dst buffers for each thread, and\n"
-"                         N is the number of processors for testing.\n"
-"  -s, --single-preheat   Use a single thread when measuring latency at preheat stage\n"
-"                         NOTE: please make sure the CPU frequency on all testing cores\n"
-"                         are locked before using this parmater.  If you don't know how\n"
-"                         to lock the freq then please don't use this parameter.\n"
-"  -t, --runtime          Specify test duration, e.g., 60, 20m, 2H\n"
-"                         (m/M: minutes, h/H: hours, d/D: days)\n"
-"  -T, --trace-threshold  Stop the test when threshold triggered (in us),\n"
-"                         print a marker in ftrace and stop ftrace too.\n"
-"  -v, --version          Display the version of the software.\n"
-"  -w, --workload         Specify a kind of workload, default is no workload\n"
-"                         (options: no, memmove)\n"
-"  -z, --zero-omit        Don't display buckets in the output histogram if all zeros.\n"
-"\n"
-;
-
-static void usage(void)
+static void usage(int error)
 {
-	printf(helpmsg, g.app_name);
-	exit(1);
+	printf("oslat V %1.2f\n", VERSION);
+	printf("Usage:\n"
+	       "oslat <options>\n\n"
+	       "This is an OS latency detector by running busy loops on specified cores.\n"
+	       "Please run this tool using root.\n\n"
+	       "Available options:\n\n"
+	       "-b, --bucket-size      Specify the number of the buckets (4-1024)\n"
+	       "-B, --bias             Add a bias to all the buckets using the estimated mininum\n"
+	       "-c, --cpu-list         Specify CPUs to run on, e.g. '1,3,5,7-15'\n"
+	       "-C, --cpu-main-thread  Specify which CPU the main thread runs on.  Default is cpu0.\n"
+	       "-D, --duration         Specify test duration, e.g., 60, 20m, 2H\n"
+	       "                       (m/M: minutes, h/H: hours, d/D: days)\n"
+	       "-f, --rtprio           Using SCHED_FIFO priority (1-99)\n"
+	       "-m, --workload-mem     Size of the memory to use for the workload (e.g., 4K, 1M).\n"
+	       "                       Total memory usage will be this value multiplies 2*N,\n"
+	       "                       because there will be src/dst buffers for each thread, and\n"
+	       "                       N is the number of processors for testing.\n"
+	       "-s, --single-preheat   Use a single thread when measuring latency at preheat stage\n"
+	       "                       NOTE: please make sure the CPU frequency on all testing cores\n"
+	       "                       are locked before using this parmater.  If you don't know how\n"
+	       "                       to lock the freq then please don't use this parameter.\n"
+	       "-T, --trace-threshold  Stop the test when threshold triggered (in us),\n"
+	       "                       print a marker in ftrace and stop ftrace too.\n"
+	       "-v, --version          Display the version of the software.\n"
+	       "-w, --workload         Specify a kind of workload, default is no workload\n"
+	       "                       (options: no, memmove)\n"
+	       "-z, --zero-omit        Don't display buckets in the output histogram if all zeros.\n"
+	       );
+	exit(error);
 }
 
 /* TODO: use libnuma? */
@@ -661,7 +656,7 @@ static void parse_options(int argc, char *argv[])
 			{ "bucket-size", required_argument, NULL, 'b' },
 			{ "cpu-list", required_argument, NULL, 'c' },
 			{ "cpu-main-thread", required_argument, NULL, 'C'},
-			{ "runtime", required_argument, NULL, 't' },
+			{ "duration", required_argument, NULL, 'D' },
 			{ "rtprio", required_argument, NULL, 'f' },
 			{ "help", no_argument, NULL, 'h' },
 			{ "trace-threshold", required_argument, NULL, 'T' },
@@ -673,7 +668,7 @@ static void parse_options(int argc, char *argv[])
 			{ "version", no_argument, NULL, 'v'},
 			{ NULL, 0, NULL, 0 },
 		};
-		int i, c = getopt_long(argc, argv, "b:Bc:C:f:hm:st:w:T:vz",
+		int i, c = getopt_long(argc, argv, "b:Bc:C:D:f:hm:sw:T:vz",
 				       options, NULL);
 		long ncores;
 
@@ -704,7 +699,7 @@ static void parse_options(int argc, char *argv[])
 				exit(1);
 			}
 			break;
-		case 't':
+		case 'D':
 			g.runtime = parse_runtime(optarg);
 			if (!g.runtime) {
 				printf("Illegal runtime: %s\n", optarg);
@@ -761,8 +756,11 @@ static void parse_options(int argc, char *argv[])
 		case 'z':
 			g.output_omit_zero_buckets = 1;
 			break;
+		case 'h':
+			usage(0);
+			break;
 		default:
-			usage();
+			usage(1);
 			break;
 		}
 	}
@@ -821,8 +819,6 @@ int main(int argc, char *argv[])
 	/* Run the main thread on cpu0 by default */
 	g.cpu_main_thread = 0;
 
-	printf("\nVersion: %1.2f\n\n", VERSION);
-
 	parse_options(argc, argv);
 
 	TEST(mlockall(MCL_CURRENT | MCL_FUTURE) == 0);
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 07/18] oslat: Use string parser utilies
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (5 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 06/18] oslat: " Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 17:25   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 08/18] pip_stress: Add command line parser Daniel Wagner
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Use available parse_time_string() instead locally implemented
version. While at it move the mem parser helper to the global utility
header.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/oslat/oslat.c | 67 ++---------------------------------------------
 1 file changed, 2 insertions(+), 65 deletions(-)

diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
index fafbdd694326..9df1a58f640d 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -570,69 +570,6 @@ static int parse_cpu_list(char *cpu_list, cpu_set_t *cpu_set)
 	return n_cores;
 }
 
-static int parse_runtime(const char *str)
-{
-	char *endptr;
-	int v = strtol(str, &endptr, 10);
-
-	if (!*endptr)
-		return v;
-
-	switch (*endptr) {
-	case 'd':
-	case 'D':
-		/* Days */
-		v *= 24;
-	case 'h':
-	case 'H':
-		/* Hours */
-		v *= 60;
-	case 'm':
-	case 'M':
-		/* Minutes */
-		v *= 60;
-	case 's':
-	case 'S':
-		/* Seconds */
-		break;
-	default:
-		printf("Unknown runtime suffix: %s\n", endptr);
-		v = 0;
-		break;
-	}
-
-	return v;
-}
-
-static int parse_mem_size(char *str, uint64_t *val)
-{
-	char *endptr;
-	int v = strtol(str, &endptr, 10);
-
-	if (!*endptr)
-		return v;
-
-	switch (*endptr) {
-	case 'g':
-	case 'G':
-		v *= 1024;
-	case 'm':
-	case 'M':
-		v *= 1024;
-	case 'k':
-	case 'K':
-		v *= 1024;
-	case 'b':
-	case 'B':
-		break;
-	default:
-		return -1;
-	}
-
-	*val = v;
-
-	return 0;
-}
 
 static int workload_select(char *name)
 {
@@ -700,7 +637,7 @@ static void parse_options(int argc, char *argv[])
 			}
 			break;
 		case 'D':
-			g.runtime = parse_runtime(optarg);
+			g.runtime = parse_time_string(optarg);
 			if (!g.runtime) {
 				printf("Illegal runtime: %s\n", optarg);
 				exit(1);
@@ -734,7 +671,7 @@ static void parse_options(int argc, char *argv[])
 			}
 			break;
 		case 'm':
-			if (parse_mem_size(optarg, &g.workload_mem_size)) {
+			if (parse_mem_string(optarg, &g.workload_mem_size)) {
 				printf("Unknown workload memory size '%s'.\n\n", optarg);
 				exit(1);
 			}
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 08/18] pip_stress: Add command line parser
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (6 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 07/18] oslat: Use string parser utilies Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 17:33   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 09/18] pi_stress: Streamline usage output and man page Daniel Wagner
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Add a default command line parser to print at least the current
version.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/pi_tests/pip_stress.c | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/src/pi_tests/pip_stress.c b/src/pi_tests/pip_stress.c
index c9dbd992e15d..74cf53dcfa7a 100644
--- a/src/pi_tests/pip_stress.c
+++ b/src/pi_tests/pip_stress.c
@@ -67,12 +67,17 @@ struct State *statep;
 const int policy = SCHED_FIFO;
 const int prio_min;	/* Initialized for the minimum priority of policy */
 
-struct option long_options[] = {
-    { "usleep", required_argument, 0, 0 },
-    { 0,        0,                 0, 0 },
-};
+static void usage(int error)
+{
+	printf("pip_stress V %1.2f\n", VERSION);
+	printf("Usage:\n"
+	       "pip_stress <options>\n"\
+	       "-h	--help                  Show this help menu.\n"
+	       );
+	exit(error);
+}
 
-int main(void)
+int main(int argc, char *argv[])
 {
 	void *mptr;	/* memory pointer */
 	pid_t pid1, pid2;
@@ -80,6 +85,25 @@ int main(void)
 	int res;
 	int *minimum_priority = (int*)&prio_min;
 
+	for (;;) {
+		struct option long_options[] = {
+			{ "help",	no_argument,		NULL,	'h' },
+			{ NULL,		0,			NULL,	0 },
+		};
+
+		int c = getopt_long(argc, argv, "s:h", long_options, NULL);
+		if (c == -1)
+			break;
+		switch (c) {
+		case 'h':
+			usage(0);
+			break;
+		default:
+			usage(1);
+			break;
+		};
+	}
+
 	*minimum_priority = sched_get_priority_min(policy);
 
 	if (check_privs())
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 09/18] pi_stress: Streamline usage output and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (7 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 08/18] pip_stress: Add command line parser Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-07  8:56 ` [rt-tests v2 10/18] pmqtest: " Daniel Wagner
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/pi_tests/pi_stress.8 |  79 +++++++++++----------
 src/pi_tests/pi_stress.c | 144 +++++++++++++++++++++------------------
 2 files changed, 122 insertions(+), 101 deletions(-)

diff --git a/src/pi_tests/pi_stress.8 b/src/pi_tests/pi_stress.8
index ed03ad6187e7..c3d7889a5cd5 100644
--- a/src/pi_tests/pi_stress.8
+++ b/src/pi_tests/pi_stress.8
@@ -10,25 +10,26 @@
 pi_stress \- a stress test for POSIX Priority Inheritance mutexes
 .\"}}}
 .\"{{{ Synopsis
-.\" Usage:  pi_stress [-i n ] [-g n] [-v] [-d] [-s] [-r] [-p] [-u] [-m]
+.\" Usage:  pi_stress [-d] [-D TIME] [-g N] [-h] [-i N ] [-m] [-p] [-q] [-r] [-s OPTS] [-u] [-v] [-V]
 .SH SYNOPSIS
 .B pi_stress
-.RB [ \-i|\-\-inversions
-.IR inversions ]
+.RB [ \-d|\-\-debug]
+.RB [ \-D|\-\-duration
+.iR TIME ]
 .RB [ \-g|\-\-groups
-.IR groups
-.RB [ \-d|\-\-debug ]
-.RB [ \-v|\-\-verbose ]
-.RB [ \-s|\-\-sched
-.IR sched_opts ]
-.RB [ \-r|\-\-rr ]
-.RB [ \-p|\-\-prompt ]
+.IR N ]
+.RB [ \-i|\-\-inversions
+.IR INV ]
 .RB [ \-m|\-\-mlockall ]
+.RB [ \-p|\-\-prompt ]
+.RB [ \-q|\-\-quiet ]
+.RB [ \-r|\-\-rr ]
+.RB [ \-s|\-\-sched
+.IR OPTS ]
 .RB [ \-u|\-\-uniprocessor ]
+.RB [ \-v|\-\-verbose ]
+.RB [ \-V|\-\-version ]
 .br
-.\" help
-.B pi_stress
-.RB \-h|\-\-help
 .SH DESCRIPTION
 .B pi_stress
 is a program used to stress the
@@ -43,38 +44,46 @@ condition that will deadlock if
 doesn't work.
 
 .SH OPTIONS
-.IP "\-i n|\-\-inversions=n"
-Run for
-.I n
-number of inversion conditions. This is the total number of inversions
-for all inversion groups. Default is \-1 for infinite.
-.IP "\-g n|\-\-groups=n"
-The number of inversion groups to run. Defaults to 10.
-.IP \-d|\-\-debug
+.IP "\-d|\-\-debug"
 Run in debug mode; lots of extra prints
-.IP "\-D, \-\-duration=TIME"
+.IP "\-D TIME, \-\-duration=TIME"
 Specify a length for the test run.
 .br
 Append 'm', 'h', or 'd' to specify minutes, hours or days.
-.IP \-v|\-\-verbose
-Run with verbose messages
-.IP \-r|\-\-rr
+.IP "\-g N|\-\-groups=N"
+The number of inversion groups to run. Defaults to 10.
+.IP "\-h|\-\-help"
+Display a short help message and options.
+.IP "\-i N|\-\-inversions=N"
+.I N
+number of inversion conditions. This is the total number of inversions
+for all inversion groups. Default is \-1 for infinite.
+.IP "\-m|\-\-mlockall"
+Call mlockall to lock current and future memory allocations and
+prevent being paged out
+.IP "\-p|\-\-prompt"
+Prompt before actually starting the stress test
+.IP "\-q|\-\-quiet"
+Suppress running output
+.IP "\-r|\-\-rr"
 Run inversion group threads as SCHED_RR (round-robin). The default is
 to run the inversion threads as SCHED_FIFO.
-.IP \-s|\-\-sched
+.IP "\-s OPTS|\-\-sched OPTS"
 scheduling options per thread type:
-id=[high|med|low],policy=[fifo,rr],priority=<n>,policy=deadline,runtime=<n>,deadline=<n>,period=<n>
-.IP \-p|\-\-prompt
-Prompt before actually starting the stress test
-.IP \-u|\-\-uniprocessor
+.br
+id=[high|med|low],
+.br
+policy=[fifo,rr],priority=N,
+.br
+policy=deadline,runtime=N,deadline=N,period=N
+.IP "\-u|\-\-uniprocessor"
 Run all threads on one processor. The default is to run all inversion
 group threads on one processor and the admin threads (reporting
 thread, keyboard reader, etc.) on a different processor.
-.IP \-m|\-\-mlockall
-Call mlockall to lock current and future memory allocations and
-prevent being paged out
-.IP \-h|\-\-help
-Display a short help message and options.
+.IP "\-v|\-\-verbose"
+Run with verbose messages
+.IP "\-V|\-\-version"
+Print version number
 .SH CAVEATS
 The pi_stress test threads run as SCHED_FIFO or SCHED_RR threads,
 which means that they can starve critical system threads. It is
diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
index e03cca25b933..84da241098af 100644
--- a/src/pi_tests/pi_stress.c
+++ b/src/pi_tests/pi_stress.c
@@ -121,24 +121,6 @@ int uniprocessor = 0;
 /* lock all memory */
 int lockall = 0;
 
-/* command line options */
-struct option options[] = {
-	{"duration", required_argument, NULL, 'D'},
-	{"verbose", no_argument, NULL, 'v'},
-	{"quiet", no_argument, NULL, 'q'},
-	{"groups", required_argument, NULL, 'g'},
-	{"inversions", required_argument, NULL, 'i'},
-	{"rr", no_argument, NULL, 'r'},
-	{"sched", required_argument, NULL, 's'},
-	{"uniprocessor", no_argument, NULL, 'u'},
-	{"prompt", no_argument, NULL, 'p'},
-	{"debug", no_argument, NULL, 'd'},
-	{"version", no_argument, NULL, 'V'},
-	{"mlockall", no_argument, NULL, 'm'},
-	{"help", no_argument, NULL, 'h'},
-	{NULL, 0, NULL, 0},
-};
-
 #define NUM_TEST_THREADS 3
 #define NUM_ADMIN_THREADS 1
 
@@ -219,7 +201,7 @@ int setup_thread_attr(pthread_attr_t * attr, struct sched_attr * sa,
 		      cpu_set_t * mask);
 int set_cpu_affinity(cpu_set_t * test_mask, cpu_set_t * admin_mask);
 void process_command_line(int argc, char **argv);
-void usage(void);
+void usage(int error);
 int block_signals(void);
 int allow_sigterm(void);
 void set_shutdown_flag(void);
@@ -989,27 +971,35 @@ void *high_priority(void *arg)
 	return NULL;
 }
 
-void usage(void)
+void usage(int error)
 {
-	printf("usage: pi_stress <options>\n\n");
-	printf("-v\t--verbose\t- lots of output\n");
-	printf("-q\t--quiet\t\t- suppress running output\n");
-	printf ("-D TIME\t--duration=TIME\n\t\t\t- length of test run in seconds (default is infinite)\n");
-	printf("\t\t\t  Append 'm', 'h', or 'd'\n\t\t\t  to specify minutes, hours or days.\n");
-	printf("-g\t--groups=<n>\t- set the number of inversion groups [%d]\n",
-	       ngroups);
-	printf ("-i INVERSIONS\t\t--inversions=INVERSIONS\n\t\t\t  number of inversions per group (default is infinite)\n");
-	printf("-r\t--rr\t\t- use SCHED_RR for test threads [SCHED_FIFO]\n");
-	printf("-s SCHED_OPTS\t--sched\t\t- scheduling options per thread type:\n");
-	printf("\t\tid=[high|med|low]\t\t\t- select thread\n");
-	printf("\t\t,policy=[fifo,rr],priority=<n>\t\t- SCHED_FIFO or SCHED_RR\n");
-	printf("\t\t,policy=deadline,runtime=<n>,deadline=<n>,period=<n>\t- SCHED_DEADLINE\n");
-	printf("-p\t--prompt\t- prompt before starting the test\n");
-	printf ("-u\t--uniprocessor\t- force all threads to run on one processor\n");
-	printf("-m\t--mlockall\t- lock current and future memory\n");
-	printf("-d\t--debug\t\t- turn on debug prints\n");
-	printf("-V\t--version\t- print version number on output\n");
-	printf("-h\t--help\t\t- print this message\n");
+	printf("pi_stress V %1.2f\n", VERSION);
+	printf("Usage:\n"
+	       "pi_stress <options>\n\n"
+	       "-d       --debug           turn on debug prints\n"
+	       "-D TIME  --duration=TIME   length of test run in seconds (default is infinite)\n"
+	       "                           Append 'm', 'h', or 'd'\n"
+	       "                           to specify minutes, hours or days.\n"
+	       "-g N     --groups=N        set the number of inversion groups\n"
+	       "-h       --help            print this message\n"
+	       "-i INV   --inversions=INV  number of inversions per group (default is infinite)\n"
+	       "-m       --mlockall        lock current and future memory\n"
+	       "-p       --prompt          prompt before starting the test\n"
+	       "-q       --quiet           suppress running output\n"
+	       "-r       --rr              use SCHED_RR for test threads [SCHED_FIFO]\n"
+	       "-s OPTS  --sched OPTS      scheduling options per thread type:\n"
+	       "   tid=[high|med|low]      select thread\n"
+	       "   ,policy=[fifo,rr]       scheduling class [SCHED_FIFO, SCHED_RR]\n"
+	       "     ,priority=N           scheduling priority\n"
+	       "   ,policy=[deadline]      scheduling class [DEADLINE]\n"
+               "     ,runtime=N\n"
+	       "     ,deadline=N\n"
+	       "     ,period=N\n"
+	       "-u       --uniprocessor    force all threads to run on one processor\n"
+	       "-v       --verbose         lots of output\n"
+	       "-V       --version         print version number on output\n"
+	       );
+	exit(error);
 }
 
 /* block all signals (called from main) */
@@ -1287,26 +1277,33 @@ int process_sched_line(const char *arg)
 
 void process_command_line(int argc, char **argv)
 {
-	int opt;
-	while ((opt = getopt_long(argc, argv, "+hD:vqi:g:rs:pdVum", options, NULL)) != -1) {
-		switch (opt) {
-		case 'h':
-			usage();
-			exit(0);
-		case 'D':
-			duration = parse_time_string(optarg);
-			break;
-		case 'v':
-			verbose = 1;
-			quiet = 0;
+	for (;;) {
+		struct option options[] = {
+			{"debug",		no_argument,		NULL, 'd'},
+			{"duration",		required_argument,	NULL, 'D'},
+			{"groups",		required_argument,	NULL, 'g'},
+			{"help",		no_argument,		NULL, 'h'},
+			{"inversions",		required_argument,	NULL, 'i'},
+			{"mlockall",		no_argument,		NULL, 'm'},
+			{"prompt",		no_argument,		NULL, 'p'},
+			{"quiet",		no_argument,		NULL, 'q'},
+			{"rr",			no_argument,		NULL, 'r'},
+			{"sched",		required_argument,	NULL, 's'},
+			{"uniprocessor",	no_argument,		NULL, 'u'},
+			{"verbose",		no_argument,		NULL, 'v'},
+			{"version",		no_argument,		NULL, 'V'},
+			{NULL, 0, NULL, 0},
+		};
+
+		int c = getopt_long(argc, argv, "+hD:vqi:g:rs:pdVum", options, NULL);
+		if (c == -1)
 			break;
-		case 'q':
-			verbose = 0;
-			quiet = 1;
+		switch (c) {
+		case 'd':
+			debugging = 1;
 			break;
-		case 'i':
-			inversions = strtol(optarg, NULL, 10);
-			pi_info("doing %d inversion per group\n", inversions);
+		case 'D':
+			duration = parse_time_string(optarg);
 			break;
 		case 'g':
 			ngroups = strtol(optarg, NULL, 10);
@@ -1318,6 +1315,23 @@ void process_command_line(int argc, char **argv)
 			}
 			pi_info("number of groups set to %d\n", ngroups);
 			break;
+		case 'h':
+			usage(0);
+			break;
+		case 'i':
+			inversions = strtol(optarg, NULL, 10);
+			pi_info("doing %d inversion per group\n", inversions);
+			break;
+		case 'm':
+			lockall = 1;
+			break;
+		case 'p':
+			prompt = 1;
+			break;
+		case 'q':
+			verbose = 0;
+			quiet = 1;
+			break;
 		case 'r':
 			policy = SCHED_RR;
 			break;
@@ -1325,20 +1339,18 @@ void process_command_line(int argc, char **argv)
 			if (process_sched_line(optarg))
 				pi_error("ignoring invalid options '%s'\n", optarg);
 			break;
-		case 'p':
-			prompt = 1;
+		case 'u':
+			uniprocessor = 1;
 			break;
-		case 'd':
-			debugging = 1;
+		case 'v':
+			verbose = 1;
+			quiet = 0;
 			break;
 		case 'V':
 			printf("pi_stress v%1.2f ", VERSION);
 			exit(0);
-		case 'u':
-			uniprocessor = 1;
-			break;
-		case 'm':
-			lockall = 1;
+		default:
+			usage(1);
 			break;
 		}
 	}
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 10/18] pmqtest: Streamline usage output and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (8 preceding siblings ...)
  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 ` 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
                   ` (7 subsequent siblings)
  17 siblings, 2 replies; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/pmqtest/pmqtest.8 |  5 ++-
 src/pmqtest/pmqtest.c | 88 ++++++++++++++++++++++---------------------
 2 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/src/pmqtest/pmqtest.8 b/src/pmqtest/pmqtest.8
index 9108a939b9f7..e44411ce0ef3 100644
--- a/src/pmqtest/pmqtest.8
+++ b/src/pmqtest/pmqtest.8
@@ -4,7 +4,7 @@
 \fBpmqtest\fR \- Start pairs of threads and measure the latency of interprocess communication with POSIX messages queues
 .SH "SYNTAX"
 .LP
-pmqtest [-a|-a PROC] [-b USEC] [-d DIST] [-i INTV] [-l loops] [-p PRIO] [-S] [-t|-t NUM] [-T TO]
+pmqtest [-a|-a PROC] [-b USEC] [-d DIST] [-D TIME] [-f TO] [-h] [-i INTV] [-l LOOPS] [-p PRIO] [-S] [-t|-t NUM]
 .br
 .SH "DESCRIPTION"
 .LP
@@ -26,6 +26,9 @@ Specify a length for the test run.
 .br
 Append 'm', 'h', or 'd' to specify minutes, hours or days.
 .TP
+.B \-h, \-\-help
+Print help message
+.TP
 .B \-f, \-\-forcetimeout=TO
 Set an artificial delay of the send function to force timeout of the receiver, requires the -T option
 .TP
diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c
index 5db8d348cdf8..938dc8d93c3f 100644
--- a/src/pmqtest/pmqtest.c
+++ b/src/pmqtest/pmqtest.c
@@ -217,36 +217,36 @@ void *pmqthread(void *param)
 	return NULL;
 }
 
-
-static void display_help(void)
+static void display_help(int error)
 {
 	printf("pmqtest V %1.2f\n", VERSION);
-	puts("Usage: pmqtest <options>");
-	puts("Function: test POSIX message queue latency");
-	puts(
-	"Options:\n"
-	"-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
-	"                           with NUM pin all threads to the processor NUM\n"
-	"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
-	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
-	"-f TO    --forcetimeout=TO force timeout of mq_timedreceive(), requires -T\n"
-	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
-	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
-	"-D       --duration=TIME   specify a length for the test run.\n"
-	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
-	"-p PRIO  --prio=PRIO       priority\n"
-	"-S       --smp             SMP testing: options -a -t and same priority\n"
-        "                           of all threads\n"
-	"-t       --threads         one thread per available processor\n"
-	"-t [NUM] --threads=NUM     number of threads:\n"
-	"                           without NUM, threads = max_cpus\n"
-	"                           without -t default = 1\n"
-	"-T TO    --timeout=TO      use mq_timedreceive() instead of mq_receive()\n"
-	"                           with timeout TO in seconds\n");
-	exit(1);
+	printf("Usage:\n"
+	       "pmqtest <options>\n\n"
+	       "Function: test POSIX message queue latency\n\n"
+	       "Available options:\n\n"
+	       "-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
+	       "                           with NUM pin all threads to the processor NUM\n"
+	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
+	       "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
+	       "-D TIME  --duration=TIME   specify a length for the test run.\n"
+	       "                           Append 'm', 'h', or 'd' to specify\n"
+	       "                           minutes, hours or days.\n"
+	       "-f TO    --forcetimeout=TO force timeout of mq_timedreceive(), requires -T\n"
+	       "-h       --help            print this help message\n"
+	       "-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
+	       "-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+	       "-p PRIO  --prio=PRIO       priority\n"
+	       "-S       --smp             SMP testing: options -a -t and same priority\n"
+	       "                           of all threads\n"
+	       "-t       --threads         one thread per available processor\n"
+	       "-t [NUM] --threads=NUM     number of threads:\n"
+	       "                           without NUM, threads = max_cpus\n"
+	       "                           without -t default = 1\n"
+	       "-T TO    --timeout=TO      use mq_timedreceive() instead of mq_receive()\n"
+	       "                           with timeout TO in seconds\n");
+	exit(error);
 }
 
-
 static int setaffinity = AFFINITY_UNSPECIFIED;
 static int affinity;
 static int tracelimit;
@@ -270,21 +270,21 @@ static void process_options (int argc, char *argv[])
 		int option_index = 0;
 		/** Options for getopt */
 		static struct option long_options[] = {
-			{"affinity", optional_argument, NULL, 'a'},
-			{"breaktrace", required_argument, NULL, 'b'},
-			{"distance", required_argument, NULL, 'd'},
-			{"forcetimeout", required_argument, NULL, 'f'},
-			{"interval", required_argument, NULL, 'i'},
-			{"loops", required_argument, NULL, 'l'},
-			{"duration", required_argument, NULL, 'D'},
-			{"priority", required_argument, NULL, 'p'},
-			{"smp", no_argument, NULL, 'S'},
-			{"threads", optional_argument, NULL, 't'},
-			{"timeout", required_argument, NULL, 'T'},
-			{"help", no_argument, NULL, '?'},
+			{"affinity",		optional_argument,	NULL, 'a'},
+			{"breaktrace",		required_argument,	NULL, 'b'},
+			{"distance",		required_argument,	NULL, 'd'},
+			{"duration",		required_argument,	NULL, 'D'},
+			{"forcetimeout",	required_argument,	NULL, 'f'},
+			{"help",		no_argument,		NULL, 'h'},
+			{"interval",		required_argument,	NULL, 'i'},
+			{"loops",		required_argument,	NULL, 'l'},
+			{"priority",		required_argument,	NULL, 'p'},
+			{"smp",			no_argument,		NULL, 'S'},
+			{"threads",		optional_argument,	NULL, 't'},
+			{"timeout",		required_argument,	NULL, 'T'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "a::b:d:f:i:l:D:p:St::T:",
+		int c = getopt_long (argc, argv, "a::b:d:D:f:i:l:p:St::T:",
 			long_options, &option_index);
 		if (c == -1)
 			break;
@@ -306,10 +306,12 @@ static void process_options (int argc, char *argv[])
 			break;
 		case 'b': tracelimit = atoi(optarg); break;
 		case 'd': distance = atoi(optarg); break;
+		case 'D': duration = parse_time_string(optarg); break;
 		case 'f': forcetimeout = atoi(optarg); break;
+		case '?':
+		case 'h': display_help(0); break;
 		case 'i': interval = atoi(optarg); break;
 		case 'l': max_cycles = atoi(optarg); break;
-		case 'D': duration = parse_time_string(optarg); break;
 		case 'p': priority = atoi(optarg); break;
 		case 'S':
 			smp = 1;
@@ -329,7 +331,9 @@ static void process_options (int argc, char *argv[])
 				num_threads = max_cpus;
 			break;
 		case 'T': timeout = atoi(optarg); break;
-		case '?': error = 1; break;
+		default:
+			display_help(1);
+			break;
 		}
 	}
 
@@ -362,7 +366,7 @@ static void process_options (int argc, char *argv[])
 		sameprio = 1;
 
 	if (error)
-		display_help ();
+		display_help (error);
 }
 
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 11/18] ptsematest: Streamline usage output and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (9 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 10/18] pmqtest: " Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 18:25   ` John Kacur
  2021-02-10 16:08   ` Peter Xu
  2020-10-07  8:56 ` [rt-tests v2 12/18] queuelat: Streamline usage " Daniel Wagner
                   ` (6 subsequent siblings)
  17 siblings, 2 replies; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/ptsematest/ptsematest.8 |  5 ++-
 src/ptsematest/ptsematest.c | 76 +++++++++++++++++++------------------
 2 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/src/ptsematest/ptsematest.8 b/src/ptsematest/ptsematest.8
index 5ee7d694d50d..05a0cdfd3657 100644
--- a/src/ptsematest/ptsematest.8
+++ b/src/ptsematest/ptsematest.8
@@ -4,7 +4,7 @@
 \fBptsematest\fR \- Start two threads and measure the latency of interprocess communication with POSIX mutex.
 .SH "SYNOPSIS"
 .LP
-ptsematest [-a|--affinity [PROC]] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME][-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-S|--smp] [-t|--threads [NUM]]
+ptsematest [-a|--affinity [PROC]] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME] [-h|--help] [-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-S|--smp] [-t|--threads [NUM]]
 .br
 .SH "DESCRIPTION"
 .LP
@@ -26,6 +26,9 @@ Specify a length for the test run.
 .br
 Append 'm', 'h', or 'd' to specify minutes, hours or days.
 .TP
+.B \-h, \-\-help
+Print help message.
+.TP
 .B \-i, \-\-interval=INTV
 Set the base interval of the thread(s) in microseconds (default is 1000 us). This sets the interval of the first thread. See also -d.
 .TP
diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c
index de8ea2fe1b0c..02919e3f5eef 100644
--- a/src/ptsematest/ptsematest.c
+++ b/src/ptsematest/ptsematest.c
@@ -141,29 +141,31 @@ void *semathread(void *param)
 }
 
 
-static void display_help(void)
+static void display_help(int error)
 {
 	printf("ptsematest V %1.2f\n", VERSION);
-	puts("Usage: ptsematest <options>");
-	puts("Function: test POSIX threads mutex latency");
-	puts(
-	"Options:\n"
-	"-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
-	"                           with NUM pin all threads to the processor NUM\n"
-	"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
-	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
-	"-D       --duration=TIME   specify a length for the test run.\n"
-	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
-	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
-	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
-	"-p PRIO  --prio=PRIO       priority\n"
-	"-S       --smp             SMP testing: options -a -t and same priority\n"
-        "                           of all threads\n"
-	"-t       --threads         one thread per available processor\n"
-	"-t [NUM] --threads=NUM     number of threads:\n"
-	"                           without NUM, threads = max_cpus\n"
-	"                           without -t default = 1\n");
-	exit(1);
+	printf("Usage:\n"
+	       "ptsematest <options>\n\n"
+	       "Function: test POSIX threads mutex latency\n\n"
+	       "Available options:\n"
+	       "-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
+	       "                           with NUM pin all threads to the processor NUM\n"
+	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
+	       "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
+	       "-D       --duration=TIME   specify a length for the test run.\n"
+	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
+	       "                           days.\n"
+	       "-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
+	       "-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+	       "-p PRIO  --prio=PRIO       priority\n"
+	       "-S       --smp             SMP testing: options -a -t and same priority\n"
+	       "                           of all threads\n"
+	       "-t       --threads         one thread per available processor\n"
+	       "-t [NUM] --threads=NUM     number of threads:\n"
+	       "                           without NUM, threads = max_cpus\n"
+	       "                           without -t default = 1\n"
+	       );
+	exit(0);
 }
 
 
@@ -188,16 +190,16 @@ static void process_options (int argc, char *argv[])
 		int option_index = 0;
 		/** Options for getopt */
 		static struct option long_options[] = {
-			{"affinity", optional_argument, NULL, 'a'},
-			{"breaktrace", required_argument, NULL, 'b'},
-			{"distance", required_argument, NULL, 'd'},
-			{"interval", required_argument, NULL, 'i'},
-			{"loops", required_argument, NULL, 'l'},
-			{"duration", required_argument, NULL, 'D'},
-			{"priority", required_argument, NULL, 'p'},
-			{"smp", no_argument, NULL, 'S'},
-			{"threads", optional_argument, NULL, 't'},
-			{"help", no_argument, NULL, '?'},
+			{"affinity",	optional_argument,	NULL, 'a'},
+			{"breaktrace",	required_argument,	NULL, 'b'},
+			{"distance",	required_argument,	NULL, 'd'},
+			{"duration",	required_argument,	NULL, 'D'},
+			{"help",	no_argument,		NULL, 'h'},
+			{"interval",	required_argument,	NULL, 'i'},
+			{"loops",	required_argument,	NULL, 'l'},
+			{"priority",	required_argument,	NULL, 'p'},
+			{"smp",		no_argument,		NULL, 'S'},
+			{"threads",	optional_argument,	NULL, 't'},
 			{NULL, 0, NULL, 0}
 		};
 		int c = getopt_long (argc, argv, "a::b:d:i:l:D:p:St::h",
@@ -222,9 +224,11 @@ static void process_options (int argc, char *argv[])
 			break;
 		case 'b': tracelimit = atoi(optarg); break;
 		case 'd': distance = atoi(optarg); break;
+		case 'D': duration = parse_time_string(optarg); break;
 		case 'i': interval = atoi(optarg); break;
+		case '?':
+		case 'h': display_help(0); break;
 		case 'l': max_cycles = atoi(optarg); break;
-		case 'D': duration = parse_time_string(optarg); break;
 		case 'p': priority = atoi(optarg); break;
 		case 'S':
 			smp = 1;
@@ -243,9 +247,9 @@ static void process_options (int argc, char *argv[])
 			else
 				num_threads = max_cpus;
 			break;
-		case 'h':
-			display_help();
-		case '?': error = 1; break;
+		default:
+			display_help(1);
+			break;
 		}
 	}
 
@@ -275,7 +279,7 @@ static void process_options (int argc, char *argv[])
 		sameprio = 1;
 
 	if (error)
-		display_help();
+		display_help(error);
 }
 
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 12/18] queuelat: Streamline usage and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (10 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 11/18] ptsematest: " Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 18:40   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 13/18] rt-migrate-test: " Daniel Wagner
                   ` (5 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

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


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 13/18] rt-migrate-test: Streamline usage and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (11 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 12/18] queuelat: Streamline usage " Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 18:47   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 14/18] signaltest: " Daniel Wagner
                   ` (4 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/rt-migrate-test/rt-migrate-test.8 | 41 +++++++-------
 src/rt-migrate-test/rt-migrate-test.c | 82 +++++++++++++--------------
 2 files changed, 59 insertions(+), 64 deletions(-)

diff --git a/src/rt-migrate-test/rt-migrate-test.8 b/src/rt-migrate-test/rt-migrate-test.8
index b9c07f1ed80a..5bbacb5333b8 100644
--- a/src/rt-migrate-test/rt-migrate-test.8
+++ b/src/rt-migrate-test/rt-migrate-test.8
@@ -1,11 +1,11 @@
 .\"
-.TH RT-MIGRATE-TEST 8 "April 21, 2016"
+.TH RT-MIGRATE-TEST 8 "September 18, 2020"
 .\" Please adjust this date whenever editing this manpage
 .SH NAME
 rt-migrate-test \- real-time task migration program
 .SH SYNOPSIS
-.B rt-migrate-test 
-.RI "[\-ceh] [\-p prio] [\-r time] [\-s time] [\-m time] [\-l loops] [nr_tasks]
+.LP
+rt-migrate-test [-c|--check] [-D|--duration TIME] [-e|--equal] [-h|--help] [-l|--loops LOOPS] [-m|--maxerr TIME] [-p|--prio PRIO] [-r|--run-time TIME] [-s|--sleep-time TIME] [NR_TASKS]
 .SH DESCRIPTION
 Test real-time multiprocessor scheduling of tasks to ensure the highest priority tasks are running on all available CPUs
 .SH OPTIONS
@@ -15,44 +15,43 @@ This program follows the usual GNU command line syntax, with long options starti
 In the summary of options, a value in brackets (), indicates a default value
 .br
 .TP
+.B \-c, \-\-check
+Stop if lower prio task is quicker than higher (off)
+.TP
 .B \-D, \-\-duration=TIME
 Specify a length for the test run.
 .br
 Append 'm', 'h', or 'd' to specify minutes, hours or days.
 .TP
-.B \-p, \-\-prio=prio
-base priority to start RT tasks with (2)
+.B \-e, \-\-equal
+Use equal prio for #CPU-1 tasks (requires > 2 CPUS)
 .br
 .TP
-.B \-r, \-\-run\-time=time
-Run time (ms) to busy loop the threads (20)
+.B \-h, \-\-help
+Display usage
 .br
 .TP
-.B \-s, \-\-sleep\-time=time
-Sleep time (ms) between intervals (100)
+.B \-l \-\-loops=LOOPS
+Number of iterations to run (50)
 .br
 .TP
-.B \-m, \-\-maxerr=time
+.B \-m, \-\-maxerr=TIME
 Max allowed error (microsecs)
 .br
 .TP
-.B \-l \-\-loops=loops
-Number of iterations to run (50)
-.br
-.TP
-.B \-e
-Use equal prio for #CPU-1 tasks (requires > 2 CPUS)
+.B \-p, \-\-prio=PRIO
+base priority to start RT tasks with (2)
 .br
 .TP
-.B \-c, \-\-check
-Stop if lower prio task is quicker than higher (off)
+.B \-r, \-\-run\-time=TIME
+Run time (ms) to busy loop the threads (20)
 .br
 .TP
-.B \-h, \-\-help
-Display usage
+.B \-s, \-\-sleep\-time=TIME
+Sleep time (ms) between intervals (100)
 .br
 .TP
-.B [nr\-tasks]
+.B [NR_TASKS]
 number of tasks to run (number of cpus + 1)
 .br
 .SH AUTHOR
diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c
index 4863238edeb4..68824606faf1 100644
--- a/src/rt-migrate-test/rt-migrate-test.c
+++ b/src/rt-migrate-test/rt-migrate-test.c
@@ -146,71 +146,67 @@ static void print_progress_bar(int percent)
 	fflush(stderr);
 }
 
-static void usage(char **argv)
+static void usage(int error)
 {
-	char *arg = argv[0];
-	char *p = arg+strlen(arg);
-
-	while (p >= arg && *p != '/')
-		p--;
-	p++;
-
-	printf("%s %1.2f\n", p, VERSION);
+	printf("rt-migrate-test %1.2f\n", VERSION);
 	printf("Usage:\n"
-	       "%s <options> nr_tasks\n\n"
-	       "-p prio --prio  prio        base priority to start RT tasks with (2)\n"
-	       "-r time --run-time time     Run time (ms) to busy loop the threads (20)\n"
-	       "-s time --sleep-time time   Sleep time (ms) between intervals (100)\n"
-	       "-m time --maxerr time       Max allowed error (microsecs)\n"
-	       "-l loops --loops loops      Number of iterations to run (50)\n"
-	       "-D       --duration=TIME    specify a length for the test run.\n"
-	       "                            Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
-	       "-e                          Use equal prio for #CPU-1 tasks (requires > 2 CPUS)\n"
-	       "-c    --check               Stop if lower prio task is quicker than higher (off)\n"
-	       "-h    --help\n"
-	       "  () above are defaults \n",
-		p);
-	exit(0);
+	       "rt-migrate-test <options> [NR_TASKS]\n\n"
+	       "-c       --check           Stop if lower prio task is quicker than higher (off)\n"
+	       "-D TIME  --duration=TIME   Specify a length for the test run.\n"
+	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
+	       "                           days.\n"
+	       "-e       --equal           Use equal prio for #CPU-1 tasks (requires > 2 CPUS)\n"
+	       "-h       --help            Print this help message\n"
+	       "-l LOOPS --loops=LOOPS     Number of iterations to run (50)\n"
+	       "-m TIME  --maxerr=TIME     Max allowed error (microsecs)\n"
+	       "-p PRIO  --prio=PRIO       base priority to start RT tasks with (2)\n"
+	       "-r TIME  --run-time=TIME   Run time (ms) to busy loop the threads (20)\n"
+	       "-s TIME  --sleep-time=TIME Sleep time (ms) between intervals (100)\n\n"
+	       "  () above are defaults \n"
+	       );
+	exit(error);
 }
 
-static void parse_options (int argc, char *argv[])
+static void parse_options(int argc, char *argv[])
 {
 	for (;;) {
 		int option_index = 0;
 		/** Options for getopt */
 		static struct option long_options[] = {
-			{"prio", required_argument, NULL, 'p'},
-			{"run-time", required_argument, NULL, 'r'},
-			{"sleep-time", required_argument, NULL, 's'},
-			{"maxerr", required_argument, NULL, 'm'},
-			{"loops", required_argument, NULL, 'l'},
-			{"duration", required_argument, NULL, 'D'},
-			{"check", no_argument, NULL, 'c'},
-			{"help", no_argument, NULL, '?'},
+			{"check",	no_argument,		NULL, 'c'},
+			{"duration",	required_argument,	NULL, 'D'},
+			{"equal",	no_argument,		NULL, 'e'},
+			{"help",	no_argument,		NULL, 'h'},
+			{"loops",	required_argument,	NULL, 'l'},
+			{"maxerr",	required_argument,	NULL, 'm'},
+			{"prio",	required_argument,	NULL, 'p'},
+			{"run-time",	required_argument,	NULL, 'r'},
+			{"sleep-time",	required_argument,	NULL, 's'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "p:r:s:m:l:D:ech",
+		int c = getopt_long(argc, argv, "cD:ehl:m:p:r:s:",
 			long_options, &option_index);
 		if (c == -1)
 			break;
 		switch (c) {
-		case 'p': prio_start = atoi(optarg); break;
-		case 'r':
-			run_interval = atoi(optarg);
-			break;
-		case 's': interval = atoi(optarg); break;
-		case 'l': nr_runs = atoi(optarg); break;
+		case 'c': check = 1; break;
 		case 'D': duration = parse_time_string(optarg); break;
-		case 'm': max_err = usec2nano(atoi(optarg)); break;
 		case 'e': equal = 1; break;
-		case 'c': check = 1; break;
 		case '?':
 		case 'h':
-			usage(argv);
+			usage(0);
 			break;
+		case 'l': nr_runs = atoi(optarg); break;
+		case 'm': max_err = usec2nano(atoi(optarg)); break;
+		case 'p': prio_start = atoi(optarg); break;
+		case 'r':
+			run_interval = atoi(optarg);
+			break;
+		case 's': interval = atoi(optarg); break;
+		default:
+			usage(1);
 		}
 	}
-
 }
 
 static unsigned long long get_time(void)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 14/18] signaltest: Streamline usage and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (12 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 13/18] rt-migrate-test: " Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 18:50   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 15/18] sigwaittest: " Daniel Wagner
                   ` (3 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/signaltest/signaltest.8 | 13 +++++-----
 src/signaltest/signaltest.c | 47 ++++++++++++++++++++-----------------
 2 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/src/signaltest/signaltest.8 b/src/signaltest/signaltest.8
index bd6ffe5c7a36..dc3eaab2293a 100644
--- a/src/signaltest/signaltest.8
+++ b/src/signaltest/signaltest.8
@@ -1,11 +1,11 @@
 .\"
-.TH SIGNALTEST 8 "October 1, 2015"
+.TH SIGNALTEST 8 "September 18, 2020"
 .\" Please adjust this date whenever updating this manpage
 .SH NAME
 signaltest \- signal roundtrip test software
 .SH SYNOPSIS
-.B signaltest
-.RI "[ \-b USEC ] [ \-l LOOPS ] [ \-p PRIO] [ \-q ] [ \-t NUM ] [ \-m ] [ \-v ] [ \-\-help ]"
+.LP
+signaltest [ -b|--backtrace USEC ] [-D|--duration TIME] [-h|--help] [-l|--loops LOOPS ] [-p|--prio PRIO] [-q|--quiet] [-t|--threads NUM] [-m|--mlockall ] [-v|--verbose ]
 .SH OPTIONS
 These programs follow the usual GNU command line syntax, with long options
 starting with two dashes ('\-\-').
@@ -18,6 +18,10 @@ Specify a length for the test run.
 .br
 Append 'm', 'h', or 'd' to specify minutes, hours or days.
 .TP
+.B \-\-help
+.br
+display usage information
+.TP
 .B \-l, \-\-loops=LOOPS
 Number of loops: default=0 (endless)
 .TP
@@ -37,9 +41,6 @@ lock current and future memory allocations
 output values on stdout for statistics
 .br
 format: n:c:v n=tasknum c=count v=value in us
-.TP
-.B \-\-help
-display usage information
 .SH AUTHOR
 signaltest was written by Thomas Gleixner <tglx@linuxtronix.de>.
 .PP
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index a67eddaf8420..c718f8676b9f 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -180,23 +180,25 @@ void *signalthread(void *param)
 
 
 /* Print usage information */
-static void display_help(void)
+static void display_help(int error)
 {
 	printf("signaltest V %1.2f\n", VERSION);
 	printf("Usage:\n"
 		"signaltest <options>\n\n"
 		"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
-		"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
 		"-D       --duration=TIME   specify a length for the test run.\n"
-		"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
+		"                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
+		"                           days.\n"
+		"-h       --help            display usage information\n"
+		"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+		"-m       --mlockall        lock current and future memory allocations\n"
 		"-p PRIO  --prio=PRIO       priority of highest prio thread\n"
 		"-q       --quiet           print a summary only on exit\n"
 		"-t NUM   --threads=NUM     number of threads: default=2\n"
-		"-m       --mlockall        lock current and future memory allocations\n"
 		"-v       --verbose         output values on stdout for statistics\n"
 		"                           format: n:c:v n=tasknum c=count v=value in us\n"
-		"--help			    display usage information\n");
-	exit(0);
+		);
+	exit(error);
 }
 
 static int priority;
@@ -208,38 +210,39 @@ static int quiet;
 static int lockall = 0;
 
 /* Process commandline options */
-static void process_options (int argc, char *argv[])
+static void process_options(int argc, char *argv[])
 {
 	int error = 0;
 	for (;;) {
 		int option_index = 0;
 		/** Options for getopt */
 		static struct option long_options[] = {
-			{"breaktrace", required_argument, NULL, 'b'},
-			{"loops", required_argument, NULL, 'l'},
-			{"duration", required_argument, NULL, 'D'},
-			{"priority", required_argument, NULL, 'p'},
-			{"quiet", no_argument, NULL, 'q'},
-			{"threads", required_argument, NULL, 't'},
-			{"verbose", no_argument, NULL, 'v'},
-			{"mlockall", no_argument, NULL, 'm'},
-			{"help", no_argument, NULL, '?'},
+			{"breaktrace",		required_argument,	NULL, 'b'},
+			{"duration",		required_argument,	NULL, 'D'},
+			{"help",		no_argument,		NULL, 'h'},
+			{"loops",		required_argument,	NULL, 'l'},
+			{"mlockall",		no_argument,		NULL, 'm'},
+			{"priority",		required_argument,	NULL, 'p'},
+			{"quiet",		no_argument,		NULL, 'q'},
+			{"threads",		required_argument,	NULL, 't'},
+			{"verbose",		no_argument,		NULL, 'v'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "b:c:d:i:l:D:np:qrsmt:v",
-			long_options, &option_index);
+		int c = getopt_long(argc, argv, "b:D:hl:mp:qt:v",
+				long_options, &option_index);
 		if (c == -1)
 			break;
 		switch (c) {
 		case 'b': tracelimit = atoi(optarg); break;
-		case 'l': max_cycles = atoi(optarg); break;
 		case 'D': duration = parse_time_string(optarg); break;
+		case '?':
+		case 'h': display_help(0); break;
+		case 'l': max_cycles = atoi(optarg); break;
+		case 'm': lockall = 1; break;
 		case 'p': priority = atoi(optarg); break;
 		case 'q': quiet = 1; break;
 		case 't': num_threads = atoi(optarg); break;
-		case 'm': lockall = 1; break;
 		case 'v': verbose = 1; break;
-		case '?': error = 1; break;
 		}
 	}
 
@@ -253,7 +256,7 @@ static void process_options (int argc, char *argv[])
 		error = 1;
 
 	if (error)
-		display_help ();
+		display_help(error);
 }
 
 static void check_kernel(void)
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 15/18] sigwaittest: Streamline usage and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (13 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 14/18] signaltest: " Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 18:51   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 16/18] ssdd: " Daniel Wagner
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/sigwaittest/sigwaittest.8 |  4 +-
 src/sigwaittest/sigwaittest.c | 76 +++++++++++++++++++----------------
 2 files changed, 44 insertions(+), 36 deletions(-)

diff --git a/src/sigwaittest/sigwaittest.8 b/src/sigwaittest/sigwaittest.8
index 2be9c03d05ca..a2dc1bc080a3 100644
--- a/src/sigwaittest/sigwaittest.8
+++ b/src/sigwaittest/sigwaittest.8
@@ -4,7 +4,7 @@
 \fBsigwaittest\fR \- Start two threads or fork two processes and measure the latency between sending and receiving a signal
 .SH "SYNTAX"
 .LP
-sigwaittest [-a|-a PROC] [-b USEC] [-d DIST] [-f] [-i INTV] [-l loops] [-p PRIO] [-t|-t NUM]
+sigwaittest [-a|--affinity PROC] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME] [-f|--fork [OPT]] [-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-t|--threads [NUM]]
 .br
 .SH "DESCRIPTION"
 .LP
@@ -26,7 +26,7 @@ Specify a length for the test run.
 .br
 Append 'm', 'h', or 'd' to specify minutes, hours or days.
 .TP
-.B \-f, \-\-fork
+.B \-f, \-\-fork[=OPT]
 Instead of creating threads (which is the default), fork new processes
 .TP
 .B \-i, \-\-interval=INTV
diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
index e7393f791519..12b55e901ce5 100644
--- a/src/sigwaittest/sigwaittest.c
+++ b/src/sigwaittest/sigwaittest.c
@@ -206,28 +206,30 @@ void *semathread(void *param)
 }
 
 
-static void display_help(void)
+static void display_help(int error)
 {
 	printf("sigwaittest V %1.2f\n", VERSION);
-	puts("Usage: sigwaittest <options>");
-	puts("Function: test sigwait() latency");
-	puts(
-	"Options:\n"
-	"-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
-	"                           with NUM pin all threads to the processor NUM\n"
-	"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
-	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
-	"-f       --fork            fork new processes instead of creating threads\n"
-	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
-	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
-	"-D       --duration=TIME   specify a length for the test run.\n"
-	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
-	"-p PRIO  --prio=PRIO       priority\n"
-	"-t       --threads         one thread per available processor\n"
-	"-t [NUM] --threads=NUM     number of threads:\n"
-	"                           without NUM, threads = max_cpus\n"
-	"                           without -t default = 1\n");
-	exit(1);
+	printf("Usage:\n"
+	       "sigwaittest <options>\n\n"
+	       "Function: test sigwait() latency\n\n"
+	       "Available options:\n"
+	       "-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
+	       "                           with NUM pin all threads to the processor NUM\n"
+	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
+	       "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
+	       "-D       --duration=TIME   specify a length for the test run.\n"
+	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
+	       "                           days.\n"
+	       "-f [OPT] --fork[=OPT]      fork new processes instead of creating threads\n"
+	       "-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
+	       "-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+	       "-p PRIO  --prio=PRIO       priority\n"
+	       "-t       --threads         one thread per available processor\n"
+	       "-t [NUM] --threads=NUM     number of threads:\n"
+	       "                           without NUM, threads = max_cpus\n"
+	       "                           without -t default = 1\n"
+	       );
+	exit(error);
 }
 
 
@@ -250,19 +252,19 @@ static void process_options (int argc, char *argv[])
 		int option_index = 0;
 		/** Options for getopt */
 		static struct option long_options[] = {
-			{"affinity", optional_argument, NULL, 'a'},
-			{"breaktrace", required_argument, NULL, 'b'},
-			{"distance", required_argument, NULL, 'd'},
-			{"fork", optional_argument, NULL, 'f'},
-			{"interval", required_argument, NULL, 'i'},
-			{"loops", required_argument, NULL, 'l'},
-			{"duration", required_argument, NULL, 'D'},
-			{"priority", required_argument, NULL, 'p'},
-			{"threads", optional_argument, NULL, 't'},
-			{"help", no_argument, NULL, '?'},
+			{"affinity",		optional_argument,	NULL, 'a'},
+			{"breaktrace",		required_argument,	NULL, 'b'},
+			{"distance",		required_argument,	NULL, 'd'},
+			{"duration",		required_argument,	NULL, 'D'},
+			{"fork",		optional_argument,	NULL, 'f'},
+			{"help",		no_argument,		NULL, 'h'},
+			{"interval",		required_argument,	NULL, 'i'},
+			{"loops",		required_argument,	NULL, 'l'},
+			{"priority",		required_argument,	NULL, 'p'},
+			{"threads",		optional_argument,	NULL, 't'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "a::b:d:f::i:l:D:p:t::",
+		int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:t::",
 			long_options, &option_index);
 		if (c == -1)
 			break;
@@ -280,6 +282,7 @@ static void process_options (int argc, char *argv[])
 			break;
 		case 'b': thistracelimit = atoi(optarg); break;
 		case 'd': distance = atoi(optarg); break;
+		case 'D': duration = parse_time_string(optarg); break;
 		case 'f':
 			if (optarg != NULL) {
 				wasforked = 1;
@@ -291,9 +294,12 @@ static void process_options (int argc, char *argv[])
 			} else
 				mustfork = 1;
 			break;
+		case '?':
+		case 'h':
+			display_help(0);
+			break;
 		case 'i': interval = atoi(optarg); break;
 		case 'l': max_cycles = atoi(optarg); break;
-		case 'D': duration = parse_time_string(optarg); break;
 		case 'p': priority = atoi(optarg); break;
 		case 't':
 			if (optarg != NULL)
@@ -303,7 +309,9 @@ static void process_options (int argc, char *argv[])
 			else
 				num_threads = max_cpus;
 			break;
-		case '?': error = 1; break;
+		default:
+			display_help(1);
+			break;
 		}
 	}
 
@@ -331,7 +339,7 @@ static void process_options (int argc, char *argv[])
 		tracelimit = thistracelimit;
 	}
 	if (error)
-		display_help ();
+		display_help (error);
 }
 
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 16/18] ssdd: Streamline usage and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (14 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 15/18] sigwaittest: " Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 18:57   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 17/18] svsematest: " Daniel Wagner
  2020-10-07  8:56 ` [rt-tests v2 18/18] hackbench: " Daniel Wagner
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/ssdd/ssdd.8 | 35 +++++++++++++++++-----------------
 src/ssdd/ssdd.c | 50 +++++++++++++++++++++++++++----------------------
 2 files changed, 45 insertions(+), 40 deletions(-)

diff --git a/src/ssdd/ssdd.8 b/src/ssdd/ssdd.8
index 99f30145d079..5c29d0abb732 100644
--- a/src/ssdd/ssdd.8
+++ b/src/ssdd/ssdd.8
@@ -1,31 +1,30 @@
-.TH SSDD 8 "June 13, 2019"
+.TH SSDD 8 "September 19, 2020"
 .SH NAME
 ssdd \- have a tracer do a bunch of PTRACE_SINGLESTEPs
 .SH SYNOPSIS
-.B ssdd
-.RI "<options>"
+.LP
+ssdd [-f|--forks NUM] [-h|--help] [-i|--iters NUM]
 .SH DESCRIPTION
-Have a tracer do a bunch of PTRACE_SINGLESTEPs against
-a tracee as fast as possible.  Create several of these
-tracer/tracee pairs and see if they can be made to
-interfere with each other.
-The tracer waits on each PTRACE_SINGLESTEP with a waitpid(2)
-and checks that waitpid's return values for correctness.
+Have a tracer do a bunch of PTRACE_SINGLESTEPs against a tracee as
+fast as possible. Create several of these tracer/tracee pairs and
+see if they can be made to interfere with each other. The tracer
+waits on each PTRACE_SINGLESTEP with a waitpid(2) and checks that
+waitpid's return values for correctness.
 .SH OPTIONS
-.B \-f, \-\-forks
-number of tracer/tracee pairs to fork off.
-Default is 10.
-.br
 .TP
-.B \-i, \-\-iters
-number of PTRACE_SINGLESTEP iterations to
-do before declaring success, for each tracer/
-tracee pair set up. Default is 10,000.
+.B \-f, \-\-forks=NUM
+number of tracer/tracee pairs to fork off.
 .br
+Default is 10.
 .TP
 .B \-h, \-\-help
 Display usage
-
+.TP
+.B \-i, \-\-iters=NUM
+number of PTRACE_SINGLESTEP iterations to do before declaring
+success, for each tracer tracee pair set up.
+.br
+Default is 10,000.
 .SH AUTHOR
 ssdd was written by Joe Korty <joe.korty@concurrent-rt.com>
 .PP
diff --git a/src/ssdd/ssdd.c b/src/ssdd/ssdd.c
index f165da96e23a..66d6009dc572 100644
--- a/src/ssdd/ssdd.c
+++ b/src/ssdd/ssdd.c
@@ -68,13 +68,16 @@ static int got_sigchld;
 
 enum option_value { OPT_NFORKS=1, OPT_NITERS, OPT_HELP };
 
-static void usage()
+static void usage(int error)
 {
-	printf("ssdd <options>\n");
-	printf("\t-f --forks=<number of forks>\n");
-	printf("\t-i --iters=<number of iterations>\n");
-	printf("\t-h --help\n");
-	exit(0);
+	printf("ssdd V %1.2f\n", VERSION);
+	printf("Usage:\n"
+	       "ssdd <options>\n\n"
+	       "-f       --forks=NUM       number of forks\n"
+	       "-h       --help            print this message\n"
+	       "-i       --iters=NUM       number of iterations\n"
+	       );
+	exit(error);
 }
 
 static int do_wait(pid_t *wait_pid, int *ret_sig)
@@ -292,27 +295,30 @@ int main(int argc, char **argv)
 		int option_index = 0;
 
 		static struct option long_options[] = {
-			{"forks", required_argument, NULL, OPT_NFORKS},
-			{"iters", required_argument, NULL, OPT_NITERS},
-			{"help", no_argument, NULL, OPT_HELP},
+			{"forks",		required_argument,	NULL, OPT_NFORKS},
+			{"help",		no_argument,		NULL, OPT_HELP},
+			{"iters",		required_argument,	NULL, OPT_NITERS},
 			{NULL, 0, NULL, 0},
 		};
-		int c = getopt_long(argc, argv, "f:i:h", long_options, &option_index);
+		int c = getopt_long(argc, argv, "f:hi:", long_options, &option_index);
 		if (c == -1)
 			break;
 		switch(c) {
-			case 'f':
-			case OPT_NFORKS:
-				nforks = atoi(optarg);
-				break;
-			case 'i':
-			case OPT_NITERS:
-				nsteps = atoi(optarg);
-				break;
-			case 'h':
-			case OPT_HELP:
-				usage();
-				break;
+		case 'f':
+		case OPT_NFORKS:
+			nforks = atoi(optarg);
+			break;
+		case 'h':
+		case OPT_HELP:
+			usage(0);
+			break;
+		case 'i':
+		case OPT_NITERS:
+			nsteps = atoi(optarg);
+			break;
+		default:
+			usage(1);
+			break;
 		}
 	}
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 17/18] svsematest: Streamline usage and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (15 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 16/18] ssdd: " Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 18:59   ` John Kacur
  2020-10-07  8:56 ` [rt-tests v2 18/18] hackbench: " Daniel Wagner
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/svsematest/svsematest.8 |  6 +--
 src/svsematest/svsematest.c | 83 +++++++++++++++++++------------------
 2 files changed, 46 insertions(+), 43 deletions(-)

diff --git a/src/svsematest/svsematest.8 b/src/svsematest/svsematest.8
index 98322c105803..5fcb96149bdd 100644
--- a/src/svsematest/svsematest.8
+++ b/src/svsematest/svsematest.8
@@ -4,15 +4,15 @@
 \fBsvsematest\fR \- Start two threads or fork two processes and measure the latency of SYSV semaphores
 .SH "SYNTAX"
 .LP
-svsematest [-a|-a PROC] [-b USEC] [-d DIST] [-f] [-i INTV] [-l loops] [-p PRIO] [-t|-t NUM]
+svsematest [-a|--affinity NUM] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME] [-f|--fork [OPT]] [-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-S|--smp] [-t|--threads [NUM]]
 .br
 .SH "DESCRIPTION"
 .LP
 The program \fBsvsematest\fR starts two threads or, optionally, forks two processes that are synchronized via SYSV semaphores and measures the latency between releasing a semaphore on one side and getting it on the other side.
 .SH "OPTIONS"
 .TP
-.B \-a, \-\-affinity[=PROC]
-Run on processor number PROC. If PROC is not specified, run on current processor.
+.B \-a, \-\-affinity[=NUM]
+Run on processor number NUM. If PROC is not specified, run on current processor.
 .TP
 .B \-b, \-\-breaktrace=USEC
 Send break trace command when latency > USEC. This is a debugging option to control the latency tracer in the realtime preemption patch.
diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c
index 607b397bf39e..7412168bd98a 100644
--- a/src/svsematest/svsematest.c
+++ b/src/svsematest/svsematest.c
@@ -218,33 +218,34 @@ union semun {
 };
 
 
-static void display_help(void)
+static void display_help(int error)
 {
 	printf("svsematest V %1.2f\n", VERSION);
-	puts("Usage: svsematest <options>");
-	puts("Function: test SYSV semaphore latency");
-	puts(
-	"Options:\n"
-	"-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
-	"                           with NUM pin all threads to the processor NUM\n"
-	"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
-	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
-	"-f       --fork            fork new processes instead of creating threads\n"
-	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
-	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
-	"-D       --duration=TIME   specify a length for the test run.\n"
-	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
-	"-p PRIO  --prio=PRIO       priority\n"
-	"-S       --smp             SMP testing: options -a -t and same priority\n"
-        "                           of all threads\n"
-	"-t       --threads         one thread per available processor\n"
-	"-t [NUM] --threads=NUM     number of threads:\n"
-	"                           without NUM, threads = max_cpus\n"
-	"                           without -t default = 1\n");
-	exit(1);
+	printf("Usage:\n"
+	       "svsematest <options>\n\n"
+	       "Function: test SYSV semaphore latency\n\n"
+	       "Avaiable options:\n"
+	       "-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
+	       "                           with NUM pin all threads to the processor NUM\n"
+	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
+	       "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
+	       "-D       --duration=TIME   specify a length for the test run.\n"
+	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
+	       "                           days.\n"
+	       "-f [OPT] --fork[=OPT]      fork new processes instead of creating threads\n"
+	       "-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
+	       "-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
+	       "-p PRIO  --prio=PRIO       priority\n"
+	       "-S       --smp             SMP testing: options -a -t and same priority\n"
+	       "                           of all threads\n"
+	       "-t       --threads         one thread per available processor\n"
+	       "-t [NUM] --threads[=NUM]   number of threads:\n"
+	       "                           without NUM, threads = max_cpus\n"
+	       "                           without -t default = 1\n"
+	       );
+	exit(error);
 }
 
-
 static int setaffinity = AFFINITY_UNSPECIFIED;
 static int affinity;
 static int priority;
@@ -256,7 +257,7 @@ static int distance = 500;
 static int smp;
 static int sameprio;
 
-static void process_options (int argc, char *argv[])
+static void process_options(int argc, char *argv[])
 {
 	int error = 0;
 	int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
@@ -266,20 +267,20 @@ static void process_options (int argc, char *argv[])
 		int option_index = 0;
 		/** Options for getopt */
 		static struct option long_options[] = {
-			{"affinity", optional_argument, NULL, 'a'},
-			{"breaktrace", required_argument, NULL, 'b'},
-			{"distance", required_argument, NULL, 'd'},
-			{"fork", optional_argument, NULL, 'f'},
-			{"interval", required_argument, NULL, 'i'},
-			{"loops", required_argument, NULL, 'l'},
-			{"duration", required_argument, NULL, 'D'},
-			{"priority", required_argument, NULL, 'p'},
-			{"smp", no_argument, NULL, 'S'},
-			{"threads", optional_argument, NULL, 't'},
-			{"help", no_argument, NULL, '?'},
+			{"affinity",		optional_argument,	NULL, 'a'},
+			{"breaktrace",		required_argument,	NULL, 'b'},
+			{"distance",		required_argument,	NULL, 'd'},
+			{"duration",		required_argument,	NULL, 'D'},
+			{"fork",		optional_argument,	NULL, 'f'},
+			{"help",		no_argument,		NULL, 'h'},
+			{"interval",		required_argument,	NULL, 'i'},
+			{"loops",		required_argument,	NULL, 'l'},
+			{"priority",		required_argument,	NULL, 'p'},
+			{"smp",			no_argument,		NULL, 'S'},
+			{"threads",		optional_argument,	NULL, 't'},
 			{NULL, 0, NULL, 0}
 		};
-		int c = getopt_long (argc, argv, "a::b:d:f::i:l:D:p:St::h",
+		int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:St::",
 			long_options, &option_index);
 		if (c == -1)
 			break;
@@ -301,6 +302,7 @@ static void process_options (int argc, char *argv[])
 			break;
 		case 'b': thistracelimit = atoi(optarg); break;
 		case 'd': distance = atoi(optarg); break;
+		case 'D': duration = parse_time_string(optarg); break;
 		case 'f':
 			if (optarg != NULL) {
 				wasforked = 1;
@@ -312,9 +314,9 @@ static void process_options (int argc, char *argv[])
 			} else
 				mustfork = 1;
 			break;
+		case 'h': display_help(0); break;
 		case 'i': interval = atoi(optarg); break;
 		case 'l': max_cycles = atoi(optarg); break;
-		case 'D': duration = parse_time_string(optarg); break;
 		case 'p': priority = atoi(optarg); break;
 		case 'S':
 			smp = 1;
@@ -333,8 +335,9 @@ static void process_options (int argc, char *argv[])
 			else
 				num_threads = max_cpus;
 			break;
-		case 'h': error = 1; break;
-		case '?': error = 1; break;
+		default:
+			display_help(1);
+			break;
 		}
 	}
 
@@ -365,7 +368,7 @@ static void process_options (int argc, char *argv[])
 		tracelimit = thistracelimit;
 	}
 	if (error)
-		display_help ();
+		display_help(error);
 }
 
 
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [rt-tests v2 18/18] hackbench: Streamline usage and man page
  2020-10-07  8:56 [rt-tests v2 00/18] Streamline command line Daniel Wagner
                   ` (16 preceding siblings ...)
  2020-10-07  8:56 ` [rt-tests v2 17/18] svsematest: " Daniel Wagner
@ 2020-10-07  8:56 ` Daniel Wagner
  2020-10-23 19:03   ` John Kacur
  17 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-07  8:56 UTC (permalink / raw)
  To: Clark Williams, John Kacur; +Cc: linux-rt-users, Daniel Wagner

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


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 01/18] rt-util: Move parse_cpumask from cyclictest
  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
  0 siblings, 1 reply; 49+ messages in thread
From: John Kacur @ 2020-10-23 15:46 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> In order to be reuse the cpumask parsing code, move it to libary.
> Several tools implement their own version of this. Let's use one
> global one instead.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  Makefile                    | 12 +++---
>  src/cyclictest/cyclictest.c | 68 +++++++--------------------------
>  src/include/rt-utils.h      |  3 ++
>  src/lib/rt-utils.c          | 76 +++++++++++++++++++++++++++++++++++++
>  4 files changed, 98 insertions(+), 61 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index c3ebbd7b2a2e..3627084437c1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -20,9 +20,14 @@ sources = cyclictest.c \
>  	  ssdd.c \
>  	  oslat.c
>  
> +# You have to have libnuma installed, which is fine to do even if you are
> +# running on non-numa machines
> +CFLAGS += -DNUMA
> +NUMA_LIBS = -lnuma
> +
>  TARGETS = $(sources:.c=)
>  LIBS	= -lrt -lpthread
> -RTTESTLIB = -lrttest -L$(OBJDIR)
> +RTTESTLIB = -lrttest -L$(OBJDIR) $(NUMA_LIBS)

Currently only cyclictest was compiled with NUMA_LIBS, this change will 
compile everything with NUMA_LIBS. I checked the size of the programs, and 
they don't grow that much with this change, but they are small programs to
begin with, do we want to keep this functionality separate?

 
>  EXTRA_LIBS ?= -ldl	# for get_cpu
>  DESTDIR	?=
>  prefix  ?= /usr/local
> @@ -79,11 +84,6 @@ ostype := $(lastword $(subst -, ,$(dumpmachine)))
>  machinetype := $(shell echo $(dumpmachine)| \
>      sed -e 's/-.*//' -e 's/i.86/i386/' -e 's/mips.*/mips/' -e 's/ppc.*/powerpc/')
>  
> -# You have to have libnuma installed, which is fine to do even if you are
> -# running on non-numa machines
> -CFLAGS += -DNUMA
> -NUMA_LIBS = -lnuma
> -
>  include src/arch/android/Makefile
>  
>  VPATH	= src/cyclictest:
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index b41d42f13f24..02cb92813fb7 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -908,11 +908,6 @@ static int clocksources[] = {
>  	CLOCK_REALTIME,
>  };
>  
> -static unsigned int is_cpumask_zero(const struct bitmask *mask)
> -{
> -	return (rt_numa_bitmask_count(mask) == 0);
> -}
> -
>  /* Get available cpus according to getaffinity or according to the
>   * intersection of getaffinity and the user specified affinity
>   * in the case of AFFINITY_SPECIFIED, the function has to be called
> @@ -997,52 +992,6 @@ static int cpu_for_thread_ua(int thread_num, int max_cpus)
>  	return 0;
>  }
>  
> -
> -/* After this function is called, affinity_mask is the intersection of the user
> - * supplied affinity mask and the affinity mask from the run time environment */
> -static void use_current_cpuset(const int max_cpus)
> -{
> -	int i;
> -	pid_t pid;
> -	struct bitmask *curmask;
> -
> -	pid = getpid();
> -
> -	curmask = numa_allocate_cpumask();
> -	numa_sched_getaffinity(pid, curmask);
> -
> -	/* Clear bits that are not set in both the cpuset from the environment,
> -	 * and in the user specified affinity for cyclictest */
> -	for (i=0; i < max_cpus; i++) {
> -		if ((!rt_numa_bitmask_isbitset(affinity_mask, i)) || (!rt_numa_bitmask_isbitset(curmask, i))) {
> -			numa_bitmask_clearbit(affinity_mask, i);
> -		}
> -	}
> -
> -	numa_bitmask_free(curmask);
> -}
> -
> -static void parse_cpumask(const char *option, const int max_cpus)
> -{
> -	affinity_mask = rt_numa_parse_cpustring(option, max_cpus);
> -	if (affinity_mask) {
> -		if (is_cpumask_zero(affinity_mask)) {
> -			rt_bitmask_free(affinity_mask);
> -			affinity_mask = NULL;
> -		} else {
> -			use_current_cpuset(max_cpus);
> -		}
> -
> -	}
> -	if (!affinity_mask)
> -		display_help(1);
> -
> -	if (verbose) {
> -		printf("%s: Using %u cpus.\n", __func__,
> -			rt_numa_bitmask_count(affinity_mask));
> -	}
> -}
> -
>  static void handlepolicy(char *polname)
>  {
>  	if (strncasecmp(polname, "other", 5) == 0)
> @@ -1176,15 +1125,24 @@ static void process_options (int argc, char *argv[], int max_cpus)
>  			if (smp)
>  				break;
>  			numa_initialize();
> -			if (optarg != NULL) {
> -				parse_cpumask(optarg, max_cpus);
> +			if (optarg) {
> +				parse_cpumask(optarg, max_cpus, &affinity_mask);
>  				setaffinity = AFFINITY_SPECIFIED;
> -			} else if (optind<argc && (atoi(argv[optind]) || argv[optind][0] == '0' || argv[optind][0] == '!')) {
> -				parse_cpumask(argv[optind], max_cpus);
> +			} else if (optind < argc &&
> +				   (atoi(argv[optind]) ||
> +				    argv[optind][0] == '0' ||
> +				    argv[optind][0] == '!')) {
> +				parse_cpumask(argv[optind], max_cpus, &affinity_mask);
>  				setaffinity = AFFINITY_SPECIFIED;
>  			} else {
>  				setaffinity = AFFINITY_USEALL;
>  			}
> +
> +			if (setaffinity == AFFINITY_SPECIFIED && !affinity_mask)
> +				display_help(1);
> +			if (verbose)
> +				printf("Using %u cpus.\n",
> +					numa_bitmask_weight(affinity_mask));
>  			break;
>  		case 'A':
>  		case OPT_ALIGNED:
> diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h
> index 4ed1cbc53ece..3b97655a20f2 100644
> --- a/src/include/rt-utils.h
> +++ b/src/include/rt-utils.h
> @@ -3,6 +3,7 @@
>  #define __RT_UTILS_H
>  
>  #include <stdint.h>
> +#include <numa.h>
>  
>  #define _STR(x) #x
>  #define STR(x) _STR(x)
> @@ -28,6 +29,8 @@ uint32_t string_to_policy(const char *str);
>  pid_t gettid(void);
>  
>  int parse_time_string(char *val);
> +int parse_mem_string(char *str, uint64_t *val);
> +int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask);
>  
>  void enable_trace_mark(void);
>  void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2)));
> diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c
> index f786588706cd..302b91388df5 100644
> --- a/src/lib/rt-utils.c
> +++ b/src/lib/rt-utils.c
> @@ -362,6 +362,82 @@ int parse_time_string(char *val)
>  	return t;
>  }
>  
> +int parse_mem_string(char *str, uint64_t *val)
> +{
> +	char *endptr;
> +	int v = strtol(str, &endptr, 10);
> +
> +	if (!*endptr)
> +		return v;
> +
> +	switch (*endptr) {
> +	case 'g':
> +	case 'G':
> +		v *= 1024;
> +	case 'm':
> +	case 'M':
> +		v *= 1024;
> +	case 'k':
> +	case 'K':
> +		v *= 1024;
> +	case 'b':
> +	case 'B':
> +		break;
> +	default:
> +		return -1;
> +	}
> +
> +	*val = v;
> +
> +	return 0;
> +}
> +
> +/*
> + * After this function is called, affinity_mask is the intersection of
> + * the user supplied affinity mask and the affinity mask from the run
> + * time environment
> + */
> +static void use_current_cpuset(int max_cpus, struct bitmask *cpumask)
> +{
> +	struct bitmask *curmask;
> +	int i;
> +
> +	curmask = numa_allocate_cpumask();
> +	numa_sched_getaffinity(getpid(), curmask);
> +
> +	/*
> +	 * Clear bits that are not set in both the cpuset from the
> +	 * environment, and in the user specified affinity.
> +	 */
> +	for (i = 0; i < max_cpus; i++) {
> +		if ((!numa_bitmask_isbitset(cpumask, i)) ||
> +		    (!numa_bitmask_isbitset(curmask, i)))
> +			numa_bitmask_clearbit(cpumask, i);
> +	}
> +
> +	numa_bitmask_free(curmask);
> +}
> +
> +int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask)
> +{
> +	struct bitmask *mask;
> +
> +	mask = numa_parse_cpustring_all(str);
> +	if (!mask)
> +		return -ENOMEM;
> +
> +	if (numa_bitmask_weight(mask) == 0) {
> +		numa_bitmask_free(mask);
> +		*cpumask = NULL;
> +		return 0;
> +	}
> +
> +	use_current_cpuset(max_cpus, mask);
> +	*cpumask = mask;
> +
> +	return 0;
> +}
> +
>  void open_tracemark_fd(void)
>  {
>  	char path[MAX_PATH];
> -- 
> 2.28.0
> 
> 

This is a good idea, I'd just prefer to keep the libraries separate for 
now.

John

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 02/18] cyclictest: Use numa library helpers in get_available_cpus()
  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
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 15:55 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> The numa library has support for counting the bits in the affinity
> mask and how many CPUs are available and usable by the tasks. Let's
> use those helpers.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/cyclictest/cyclictest.c | 22 +++-------------------
>  1 file changed, 3 insertions(+), 19 deletions(-)
> 
> diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
> index 02cb92813fb7..d7477c686435 100644
> --- a/src/cyclictest/cyclictest.c
> +++ b/src/cyclictest/cyclictest.c
> @@ -915,26 +915,10 @@ static int clocksources[] = {
>   */
>  static int get_available_cpus(void)
>  {
> -	int num_cpus = 0;
> -	int res;
> -	pthread_t thread;
> -	cpu_set_t cpuset;
> -
> -
> -	if (affinity_mask != NULL) {
> -		num_cpus = rt_numa_bitmask_count(affinity_mask);
> -	} else {
> -		CPU_ZERO(&cpuset);
> -		thread = pthread_self();
> -		res = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
> -		if (res != 0) {
> -			fatal("pthread_getaffinity_np failed: %s\n", strerror(res));
> -		}
> -		num_cpus = CPU_COUNT(&cpuset);
> -	}
> -
> -	return num_cpus;
> +	if (affinity_mask)
> +		return numa_bitmask_weight(affinity_mask);
>  
> +	return numa_num_task_cpus();
>  }
>  
>  /* cpu_for_thread AFFINITY_SPECIFIED */
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

Thanks!

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 03/18] cyclicdeadline: Streamline usage output and man page
  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
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 16:01 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/sched_deadline/cyclicdeadline.8 | 24 ++++++++---------
>  src/sched_deadline/cyclicdeadline.c | 41 +++++++++++++++--------------
>  2 files changed, 33 insertions(+), 32 deletions(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8
> index 91766fb391c4..6df7faf445f9 100644
> --- a/src/sched_deadline/cyclicdeadline.8
> +++ b/src/sched_deadline/cyclicdeadline.8
> @@ -17,7 +17,7 @@ cyclicdeadline \- This program is used to test the deadline scheduler (SCHED_DEA
>  .PP
>  .SH SYNOPSIS
>  .B cyclicdeadline
> -.RI "[-ha] [-c cpulist] [-i interval] [-s step] [-t nr_threads] [-D duration]
> +.RI "[-ha] [-c CPUSET] [-D TIME] [-i INTV] [-s STEP] [-t NUM]"
>  .PP
>  .SH DESCRIPTION
>  .B cyclicdeadline
> @@ -25,28 +25,28 @@ is a cyclictest style program for testing the deadline scheduler
>  .PP
>  .SH OPTIONS
>  .TP
> -.B \-h
> -Show this help menu
> -.TP
>  .B \-a
>  Use all CPUs
>  .TP
> -.B \-c cpulist
> +.B \-c CPUSET
>  Comma / hypen separated list of CPUs to run deadline tasks on
>  .TP
> -.B \-i interval
> +.B \-D TIME
> +Specify a length for the test to run
> +Append 'm', 'h', or 'd' to specify minutes, hours, or days
> +.TP
> +.B \-h
> +Show this help menu
> +.TP
> +.B \-i INTV
>  The shortest deadline for the tasks in us. (default 1000us)
>  .TP
> -.B \-s step
> +.B \-s STEP
>  The amount to increase the deadline for each task in us. (default 500us)
>  .TP
> -.B \-t nr_threads
> +.B \-t NUM
>  The number of threads to run as deadline (default 1)
> -.TP
> -.B \-D time
> -Specify a length for the test to run
>  .br
> -Append 'm', 'h', or 'd' to specify minutes, hours, or days
>  .SH AUTHOR
>  cyclicdeadline was written by Steven Rostedt <rostedt@goodmis.org>
>  .PP
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index a08e28e73c42..310880805553 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -630,26 +630,25 @@ static void teardown(void)
>  	destroy_cpuset(CPUSET_LOCAL, 1);
>  }
>  
> -static void usage(char **argv)
> +static void usage(int error)
>  {
> -	char *arg = argv[0];
> -	char *p = arg+strlen(arg);
> -
> -	while (p >= arg && *p != '/')
> -		p--;
> -	p++;
> -
> -	printf("usage: %s [options]\n"
> -	       " -h - Show this help menu\n"
> -	       " -a - Use all CPUs\n"
> -	       " -c cpulist - Comma/hyphen separated list of CPUs to run deadline tasks on\n"
> -	       " -i interval(us) - The shortest deadline for the tasks (default 1000us)\n"
> -	       " -s step(us) - The amount to increase the deadline for each task (default 500us)\n"
> -	       " -t threads - The number of threads to run as deadline (default 1)\n"
> -	       " -D time - Specify a length for the test run\n"
> -	       "           Append 'm', 'h', or 'd' to specify minutes, hours or days\n"
> -	       "\n", p);
> -	exit(-1);
> +	printf("cyclicdeadline V %1.2f\n", VERSION);
> +	printf("Usage:\n"
> +	       "cyclicdeadline <options>\n\n"
> +	       "-a                         Use all CPUs\n"
> +	       "-c CPUSET                  Comma/hyphen separated list of 
CPUs to run deadline\n"
> +	       "                           tasks on.\n"
> +	       "-D TIME                    Specify a length for the test run.\n"
> +	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
> +	       "                           days\n"
> +	       "-h                         Show this help menu.\n"
> +	       "-i INTV                    The shortest deadline for the tasks in us\n"
> +	       "                           (default 1000us).\n"
> +	       "-s STEP                    The amount to increase the deadline for each task in us\n"
> +	       "                           (default 500us).\n"
> +	       "-t NUM                     The number of threads to run as deadline (default 1).\n"
> +	       );
> +	exit(error);
>  }
>  
>  static int fail;
> @@ -1057,8 +1056,10 @@ int main (int argc, char **argv)
>  			duration = parse_time_string(optarg);
>  			break;
>  		case 'h':
> +			usage(0);
> +			break;
>  		default:
> -			usage(argv);
> +			usage(1);
>  		}
>  	}
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

Thanks!

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 04/18] cyclicdeadline: Add long command line options
  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
  0 siblings, 1 reply; 49+ messages in thread
From: John Kacur @ 2020-10-23 16:07 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Use getopt_long to parse long version of the commands.
> 
> Change the 'a/affinity' option to handle all cases including what '-c'
> did. We still keep '-c' silently supported to avoid breaking existing
> users.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/sched_deadline/cyclicdeadline.8 | 17 +++++-------
>  src/sched_deadline/cyclicdeadline.c | 42 ++++++++++++++++++++---------
>  2 files changed, 36 insertions(+), 23 deletions(-)
> 
> diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8
> index 6df7faf445f9..def42f77044a 100644
> --- a/src/sched_deadline/cyclicdeadline.8
> +++ b/src/sched_deadline/cyclicdeadline.8
> @@ -17,7 +17,7 @@ cyclicdeadline \- This program is used to test the deadline scheduler (SCHED_DEA
>  .PP
>  .SH SYNOPSIS
>  .B cyclicdeadline
> -.RI "[-ha] [-c CPUSET] [-D TIME] [-i INTV] [-s STEP] [-t NUM]"
> +.RI "[-a [CPUSET]] [-D TIME] [-h]  [-i INTV] [-s STEP] [-t NUM]"
>  .PP
>  .SH DESCRIPTION
>  .B cyclicdeadline
> @@ -25,26 +25,23 @@ is a cyclictest style program for testing the deadline scheduler
>  .PP
>  .SH OPTIONS
>  .TP
> -.B \-a
> -Use all CPUs
> -.TP
> -.B \-c CPUSET
> +.B \-a \-\-affinity [CPUSET]
>  Comma / hypen separated list of CPUs to run deadline tasks on
>  .TP
> -.B \-D TIME
> +.B \-D \-\-duration TIME
>  Specify a length for the test to run
>  Append 'm', 'h', or 'd' to specify minutes, hours, or days
>  .TP
> -.B \-h
> +.B \-h \-\-help
>  Show this help menu
>  .TP
> -.B \-i INTV
> +.B \-i \-\-interval INTV
>  The shortest deadline for the tasks in us. (default 1000us)
>  .TP
> -.B \-s STEP
> +.B \-s \-\-step STEP
>  The amount to increase the deadline for each task in us. (default 500us)
>  .TP
> -.B \-t NUM
> +.B \-t \-\-threads NUM
>  The number of threads to run as deadline (default 1)
>  .br
>  .SH AUTHOR
> diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c
> index 310880805553..5f5cdfa08f14 100644
> --- a/src/sched_deadline/cyclicdeadline.c
> +++ b/src/sched_deadline/cyclicdeadline.c
> @@ -17,6 +17,7 @@
>  #include <ctype.h>
>  #include <errno.h>
>  #include <signal.h>
> +#include <getopt.h>
>  
>  #include <sys/syscall.h>
>  #include <sys/types.h>
> @@ -635,18 +636,19 @@ static void usage(int error)
>  	printf("cyclicdeadline V %1.2f\n", VERSION);
>  	printf("Usage:\n"
>  	       "cyclicdeadline <options>\n\n"
> -	       "-a                         Use all CPUs\n"
> -	       "-c CPUSET                  Comma/hyphen separated list of CPUs to run deadline\n"
> -	       "                           tasks on.\n"
> -	       "-D TIME                    Specify a length for the test run.\n"
> +	       "-a [CPUSET] --affinity     Comma/hyphen separated list of CPUs to run deadline\n"
> +	       "                           tasks on. An empty CPUSET runs on all CPUs a deadline\n"
> +	       "                           task.\n"
> +	       "                           on CPU 4, and thread #5 on CPU 5.\n"
> +	       "-D TIME     --duration     Specify a length for the test run.\n"
>  	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
>  	       "                           days\n"
> -	       "-h                         Show this help menu.\n"
> -	       "-i INTV                    The shortest deadline for the tasks in us\n"
> +	       "-h          --help         Show this help menu.\n"
> +	       "-i INTV     --interval     The shortest deadline for the tasks in us\n"
>  	       "                           (default 1000us).\n"
> -	       "-s STEP                    The amount to increase the deadline for each task in us\n"
> +	       "-s STEP     --step         The amount to increase the deadline for each task in us\n"
>  	       "                           (default 500us).\n"
> -	       "-t NUM                     The number of threads to run as deadline (default 1).\n"
> +	       "-t NUM      --threads      The number of threads to run as deadline (default 1).\n"
>  	       );
>  	exit(error);
>  }
> @@ -1033,15 +1035,29 @@ int main (int argc, char **argv)
>  		exit(-1);
>  	}
>  
> -	while ((c = getopt(argc, argv, "+hac:i:s:t:D:")) >= 0) {
> +	for (;;) {
> +		static struct option options[] = {
> +			{ "affinity",	optional_argument,	NULL,	'a' },
> +			{ "duration",	required_argument,	NULL,	'D' },
> +			{ "help",	no_argument,		NULL,	'h' },
> +			{ "interval",	required_argument,	NULL,	'i' },
> +			{ "threads",	required_argument,	NULL,	't' },
> +			{ NULL,		0,			NULL,	0   },
> +		};
> +		c = getopt_long(argc, argv, "a::c:D:hi:t:", options, NULL);
> +		if (c == -1)
> +			break;
>  		switch (c) {
>  		case 'a':
> -			all_cpus = 1;
> +		case 'c':
>  			if (!nr_threads)
>  				nr_threads = cpu_count;
> -			break;
> -		case 'c':
> -			setcpu = optarg;
> +			if (optarg)
> +				setcpu = optarg;
> +			else if (optind < argc)
> +				setcpu = argv[optind];
> +			else
> +				all_cpus = 1;
>  			break;
>  		case 'i':
>  			interval = atoi(optarg);
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

Go ahead and send me a patch to remove the -c option
no need to retain this for silent backwards compatibility.

Thanks

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 05/18] deadline_test: Streamline usage output and man page
  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
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 16:10 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/sched_deadline/deadline_test.8 | 37 ++++++++++++-----------
>  src/sched_deadline/deadline_test.c | 47 +++++++++++++++---------------
>  2 files changed, 41 insertions(+), 43 deletions(-)
> 
> diff --git a/src/sched_deadline/deadline_test.8 b/src/sched_deadline/deadline_test.8
> index 5dc99c0bfc63..8f32c5b6feb6 100644
> --- a/src/sched_deadline/deadline_test.8
> +++ b/src/sched_deadline/deadline_test.8
> @@ -19,45 +19,44 @@ deadline_test \- High resolution test program
>  This program is used to test the deadline scheduler (SCHED_DEADLINE tasks)
>  .SH SYNOPSIS
>  .B deadline_test
> -.RI "[ \-hb ] [ \-r prio ] [ \-c cpulist ] [ \-i interval ] [ \-p percent ] [ \-P percent ] [ \-t threads ] [ \-s step[us) ]"
> -
> +.RI "[ \-hb ] [ \-c CPUSET ] [ \-i INTV ] [ \-p PERCENT ] [ \-P PERCENT ] \
> +[ \-r PRIO ]  [ \-s STEP ] [ \-t NUM ]"
>  .SH OPTIONS
>  .TP
> -.B \-h
> -Show this help menu
> -.br
> -.TP
>  .B \-b
>  Bind on the last cpu. (shortcut for -c <lastcpu>)
>  .br
>  .TP
> -.B \-r prio
> -Add an RT task with given prio to stress system
> +.B \-c CPUSET
> +Comma/hyphen separated list of CPUs to run deadline tasks on
>  .br
>  .TP
> -.B \-c cpulist
> -Comma/hyphen separated list of CPUs to run deadline tasks on
> +.B \-h
> +Show this help menu
>  .br
>  .TP
> -.B \-i interval
> +.B \-i INTV
>  The shortest deadline for the tasks
>  .br
>  .TP
> -.B \-p percent
> +.B \-p PERCENT
>  The percent of bandwidth to use (1-90%)
>  .br
>  .TP
> -.B \-P percent
> -The percent of runtime for execution completion
> -              (Default 100%)
> +.B \-P PERCENT
> +The percent of runtime for execution completion (default 100%)
>  .br
>  .TP
> -.B \-t threads
> -The number of threads to run as deadline (default 1)
> +.B \-r PRIO
> +Add an RT task with given prio to stress system
>  .br
>  .TP
> -.B \-s step(us)
> -The amount to increase the deadline for each task (default 500us)
> +.B \-s STEP
> +The amount to increase the deadline for each task in us (default 500us)
> +.br
> +.TP
> +.B \-t NUM
> +The number of threads to run as deadline (default 1)
>  .br
>  .SH AUTHOR
>  Deadline test was written by Steven Rostedt <rostedt@goodmis.org>
> diff --git a/src/sched_deadline/deadline_test.c b/src/sched_deadline/deadline_test.c
> index 4cef2609912e..060ac896aef2 100644
> --- a/src/sched_deadline/deadline_test.c
> +++ b/src/sched_deadline/deadline_test.c
> @@ -46,33 +46,30 @@
>  
>  /**
>   * usage - show the usage of the program and exit.
> - * @argv: The program passed in args
> + * @error: Exit error code to be used
>   *
> - * This is defined here to show people looking at this code how
> + * This is defined here to show peoplde looking at this code how
>   * to use this program as well. 
>   */
> -static void usage(char **argv)
> +static void usage(int error)
>  {
> -	char *arg = argv[0];
> -	char *p = arg+strlen(arg);
> -
> -	while (p >= arg && *p != '/')
> -		p--;
> -	p++;
> -
> -	printf("usage: %s [options]\n"
> -	       " -h - Show this help menu\n"
> -	       " -b - Bind on the last cpu. (shortcut for -c <lastcpu>)\n"
> -	       " -r prio - Add an RT task with given prio to stress system\n"
> -	       " -c cpulist - Comma/hyphen separated list of CPUs to run deadline tasks on\n"
> -	       " -i interval - The shortest deadline for the tasks\n"
> -	       " -p percent - The percent of bandwidth to use (1-90%%)\n"
> -	       " -P percent - The percent of runtime for execution completion\n"
> -	       "              (Default 100%%)\n"
> -	       " -t threads - The number of threads to run as deadline (default 1)\n"
> -	       " -s step(us) - The amount to increase the deadline for each task (default 500us)\n"
> -	       "\n", p);
> -	exit(-1);
> +	printf("deadline_test V %1.2f\n", VERSION);
> +	printf("Usage:\n"
> +	       "deadline_test <options>\n"
> +	       "-b                         Bind on the last cpu. (shortcut for -c <lastcpu>)\n"
> +	       "-c CPUSET                  Comma/hyphen separated list of CPUs to run deadline\n"
> +	       "                           tasks on\n"
> +	       "-h                         Show this help menu\n"
> +	       "-i INTV                    The shortest deadline for the tasks\n"
> +	       "-p PERCENT                 The percent of bandwidth to use (1-90%%)\n"
> +	       "-P PERCENT                 The percent of runtime for execution completion\n"
> +	       "                           (default 100%%)\n"
> +	       "-r PRIO                    Add an RT task with given prio to stress system\n"
> +	       "-s STEP                    The amount to increase the deadline for each task in us\n"
> +	       "                           (default 500us)\n"
> +	       "-t NUM                     The number of threads to run as deadline (default 1)\n"
> +	       );
> +	exit(error);
>  }
>  
>  #define _STR(x) #x
> @@ -1753,8 +1750,10 @@ int main (int argc, char **argv)
>  			rt_task = atoi(optarg);
>  			break;
>  		case 'h':
> +			usage(0);
> +			break;
>  		default:
> -			usage(argv);
> +			usage(1);
>  		}
>  	}
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com

Thanks!

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 06/18] oslat: Streamline usage output and man page
  2020-10-07  8:56 ` [rt-tests v2 06/18] oslat: " Daniel Wagner
@ 2020-10-23 17:19   ` John Kacur
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 17:19 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/oslat/oslat.8 |  2 +-
>  src/oslat/oslat.c | 78 ++++++++++++++++++++++-------------------------
>  2 files changed, 38 insertions(+), 42 deletions(-)
> 
> diff --git a/src/oslat/oslat.8 b/src/oslat/oslat.8
> index 85f2c5bcdf5c..b481d8d82783 100644
> --- a/src/oslat/oslat.8
> +++ b/src/oslat/oslat.8
> @@ -36,7 +36,7 @@ Total memory usage will be this value multiplies 2*N,
>  because there will be src/dst buffers for each thread, and
>  N is the number of processors for testing.
>  .TP
> -.B \-t, \-\-runtime=SEC
> +.B \-D, \-\-duration=TIME
>  Specify test duration, e.g., 60, 20m, 2H (m/M: minutes, h/H: hours, d/D: days).
>  By default the unit is s/second.
>  .TP
> diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
> index f1a82f2367d2..fafbdd694326 100644
> --- a/src/oslat/oslat.c
> +++ b/src/oslat/oslat.c
> @@ -507,42 +507,37 @@ static void handle_alarm(int code)
>  	g.cmd = STOP;
>  }
>  
> -const char *helpmsg =
> -"Usage: %s [options]\n"
> -"\n"
> -"This is an OS latency detector by running busy loops on specified cores.\n"
> -"Please run this tool using root.\n"
> -"\n"
> -"Available options:\n"
> -"\n"
> -"  -b, --bucket-size      Specify the number of the buckets (4-1024)\n"
> -"  -B, --bias             Add a bias to all the buckets using the estimated mininum\n"
> -"  -c, --cpu-list         Specify CPUs to run on, e.g. '1,3,5,7-15'\n"
> -"  -C, --cpu-main-thread  Specify which CPU the main thread runs on.  Default is cpu0.\n"
> -"  -f, --rtprio           Using SCHED_FIFO priority (1-99)\n"
> -"  -m, --workload-mem     Size of the memory to use for the workload (e.g., 4K, 1M).\n"
> -"                         Total memory usage will be this value multiplies 2*N,\n"
> -"                         because there will be src/dst buffers for each thread, and\n"
> -"                         N is the number of processors for testing.\n"
> -"  -s, --single-preheat   Use a single thread when measuring latency at preheat stage\n"
> -"                         NOTE: please make sure the CPU frequency on all testing cores\n"
> -"                         are locked before using this parmater.  If you don't know how\n"
> -"                         to lock the freq then please don't use this parameter.\n"
> -"  -t, --runtime          Specify test duration, e.g., 60, 20m, 2H\n"
> -"                         (m/M: minutes, h/H: hours, d/D: days)\n"
> -"  -T, --trace-threshold  Stop the test when threshold triggered (in us),\n"
> -"                         print a marker in ftrace and stop ftrace too.\n"
> -"  -v, --version          Display the version of the software.\n"
> -"  -w, --workload         Specify a kind of workload, default is no workload\n"
> -"                         (options: no, memmove)\n"
> -"  -z, --zero-omit        Don't display buckets in the output histogram if all zeros.\n"
> -"\n"
> -;
> -
> -static void usage(void)
> +static void usage(int error)
>  {
> -	printf(helpmsg, g.app_name);
> -	exit(1);
> +	printf("oslat V %1.2f\n", VERSION);
> +	printf("Usage:\n"
> +	       "oslat <options>\n\n"
> +	       "This is an OS latency detector by running busy loops on specified cores.\n"
> +	       "Please run this tool using root.\n\n"
> +	       "Available options:\n\n"
> +	       "-b, --bucket-size      Specify the number of the buckets (4-1024)\n"
> +	       "-B, --bias             Add a bias to all the buckets using the estimated mininum\n"
> +	       "-c, --cpu-list         Specify CPUs to run on, e.g. '1,3,5,7-15'\n"
> +	       "-C, --cpu-main-thread  Specify which CPU the main thread runs on.  Default is cpu0.\n"
> +	       "-D, --duration         Specify test duration, e.g., 60, 20m, 2H\n"
> +	       "                       (m/M: minutes, h/H: hours, d/D: days)\n"
> +	       "-f, --rtprio           Using SCHED_FIFO priority (1-99)\n"
> +	       "-m, --workload-mem     Size of the memory to use for the workload (e.g., 4K, 1M).\n"
> +	       "                       Total memory usage will be this value multiplies 2*N,\n"
> +	       "                       because there will be src/dst buffers for each thread, and\n"
> +	       "                       N is the number of processors for testing.\n"
> +	       "-s, --single-preheat   Use a single thread when measuring latency at preheat stage\n"
> +	       "                       NOTE: please make sure the CPU frequency on all testing cores\n"
> +	       "                       are locked before using this parmater.  If you don't know how\n"
> +	       "                       to lock the freq then please don't use this parameter.\n"
> +	       "-T, --trace-threshold  Stop the test when threshold triggered (in us),\n"
> +	       "                       print a marker in ftrace and stop ftrace too.\n"
> +	       "-v, --version          Display the version of the software.\n"
> +	       "-w, --workload         Specify a kind of workload, default is no workload\n"
> +	       "                       (options: no, memmove)\n"
> +	       "-z, --zero-omit        Don't display buckets in the output histogram if all zeros.\n"
> +	       );
> +	exit(error);
>  }
>  
>  /* TODO: use libnuma? */
> @@ -661,7 +656,7 @@ static void parse_options(int argc, char *argv[])
>  			{ "bucket-size", required_argument, NULL, 'b' },
>  			{ "cpu-list", required_argument, NULL, 'c' },
>  			{ "cpu-main-thread", required_argument, NULL, 'C'},
> -			{ "runtime", required_argument, NULL, 't' },
> +			{ "duration", required_argument, NULL, 'D' },
>  			{ "rtprio", required_argument, NULL, 'f' },
>  			{ "help", no_argument, NULL, 'h' },
>  			{ "trace-threshold", required_argument, NULL, 'T' },
> @@ -673,7 +668,7 @@ static void parse_options(int argc, char *argv[])
>  			{ "version", no_argument, NULL, 'v'},
>  			{ NULL, 0, NULL, 0 },
>  		};
> -		int i, c = getopt_long(argc, argv, "b:Bc:C:f:hm:st:w:T:vz",
> +		int i, c = getopt_long(argc, argv, "b:Bc:C:D:f:hm:sw:T:vz",
>  				       options, NULL);
>  		long ncores;
>  
> @@ -704,7 +699,7 @@ static void parse_options(int argc, char *argv[])
>  				exit(1);
>  			}
>  			break;
> -		case 't':
> +		case 'D':
>  			g.runtime = parse_runtime(optarg);
>  			if (!g.runtime) {
>  				printf("Illegal runtime: %s\n", optarg);
> @@ -761,8 +756,11 @@ static void parse_options(int argc, char *argv[])
>  		case 'z':
>  			g.output_omit_zero_buckets = 1;
>  			break;
> +		case 'h':
> +			usage(0);
> +			break;
>  		default:
> -			usage();
> +			usage(1);
>  			break;
>  		}
>  	}
> @@ -821,8 +819,6 @@ int main(int argc, char *argv[])
>  	/* Run the main thread on cpu0 by default */
>  	g.cpu_main_thread = 0;
>  
> -	printf("\nVersion: %1.2f\n\n", VERSION);
> -
>  	parse_options(argc, argv);
>  
>  	TEST(mlockall(MCL_CURRENT | MCL_FUTURE) == 0);
> -- 
> 2.28.0
> 
> 

Signed-off-by: John Kacur <jkacur@redhat.com>

Thanks

In the future at least put one line in the text though, not just a title.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 07/18] oslat: Use string parser utilies
  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
  0 siblings, 1 reply; 49+ messages in thread
From: John Kacur @ 2020-10-23 17:25 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Use available parse_time_string() instead locally implemented
> version. While at it move the mem parser helper to the global utility
> header.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/oslat/oslat.c | 67 ++---------------------------------------------
>  1 file changed, 2 insertions(+), 65 deletions(-)
> 
> diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c
> index fafbdd694326..9df1a58f640d 100644
> --- a/src/oslat/oslat.c
> +++ b/src/oslat/oslat.c
> @@ -570,69 +570,6 @@ static int parse_cpu_list(char *cpu_list, cpu_set_t *cpu_set)
>  	return n_cores;
>  }
>  
> -static int parse_runtime(const char *str)
> -{
> -	char *endptr;
> -	int v = strtol(str, &endptr, 10);
> -
> -	if (!*endptr)
> -		return v;
> -
> -	switch (*endptr) {
> -	case 'd':
> -	case 'D':
> -		/* Days */
> -		v *= 24;
> -	case 'h':
> -	case 'H':
> -		/* Hours */
> -		v *= 60;
> -	case 'm':
> -	case 'M':
> -		/* Minutes */
> -		v *= 60;
> -	case 's':
> -	case 'S':
> -		/* Seconds */
> -		break;
> -	default:
> -		printf("Unknown runtime suffix: %s\n", endptr);
> -		v = 0;
> -		break;
> -	}
> -
> -	return v;
> -}
> -
> -static int parse_mem_size(char *str, uint64_t *val)
> -{
> -	char *endptr;
> -	int v = strtol(str, &endptr, 10);
> -
> -	if (!*endptr)
> -		return v;
> -
> -	switch (*endptr) {
> -	case 'g':
> -	case 'G':
> -		v *= 1024;
> -	case 'm':
> -	case 'M':
> -		v *= 1024;
> -	case 'k':
> -	case 'K':
> -		v *= 1024;
> -	case 'b':
> -	case 'B':
> -		break;
> -	default:
> -		return -1;
> -	}
> -
> -	*val = v;
> -
> -	return 0;
> -}
>  
>  static int workload_select(char *name)
>  {
> @@ -700,7 +637,7 @@ static void parse_options(int argc, char *argv[])
>  			}
>  			break;
>  		case 'D':
> -			g.runtime = parse_runtime(optarg);
> +			g.runtime = parse_time_string(optarg);
>  			if (!g.runtime) {
>  				printf("Illegal runtime: %s\n", optarg);
>  				exit(1);
> @@ -734,7 +671,7 @@ static void parse_options(int argc, char *argv[])
>  			}
>  			break;
>  		case 'm':
> -			if (parse_mem_size(optarg, &g.workload_mem_size)) {
> +			if (parse_mem_string(optarg, &g.workload_mem_size)) {
>  				printf("Unknown workload memory size '%s'.\n\n", optarg);
>  				exit(1);
>  			}
> -- 
> 2.28.0
> 
> 

This one is pending either your changes that I requested to the first 
patch, or an argument as to why I should accept the first patch.

Cheers!

John

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 08/18] pip_stress: Add command line parser
  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
  0 siblings, 1 reply; 49+ messages in thread
From: John Kacur @ 2020-10-23 17:33 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Add a default command line parser to print at least the current
> version.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/pi_tests/pip_stress.c | 34 +++++++++++++++++++++++++++++-----
>  1 file changed, 29 insertions(+), 5 deletions(-)
> 
> diff --git a/src/pi_tests/pip_stress.c b/src/pi_tests/pip_stress.c
> index c9dbd992e15d..74cf53dcfa7a 100644
> --- a/src/pi_tests/pip_stress.c
> +++ b/src/pi_tests/pip_stress.c
> @@ -67,12 +67,17 @@ struct State *statep;
>  const int policy = SCHED_FIFO;
>  const int prio_min;	/* Initialized for the minimum priority of policy */
>  
> -struct option long_options[] = {
> -    { "usleep", required_argument, 0, 0 },
> -    { 0,        0,                 0, 0 },
> -};
> +static void usage(int error)
> +{
> +	printf("pip_stress V %1.2f\n", VERSION);
> +	printf("Usage:\n"
> +	       "pip_stress <options>\n"\
> +	       "-h	--help                  Show this help menu.\n"
> +	       );
> +	exit(error);
> +}
>  
> -int main(void)
> +int main(int argc, char *argv[])
>  {
>  	void *mptr;	/* memory pointer */
>  	pid_t pid1, pid2;
> @@ -80,6 +85,25 @@ int main(void)
>  	int res;
>  	int *minimum_priority = (int*)&prio_min;
>  
> +	for (;;) {
> +		struct option long_options[] = {
> +			{ "help",	no_argument,		NULL,	'h' },
> +			{ NULL,		0,			NULL,	0 },
> +		};
> +
> +		int c = getopt_long(argc, argv, "s:h", long_options, NULL);
> +		if (c == -1)
> +			break;
> +		switch (c) {
> +		case 'h':
> +			usage(0);
> +			break;
> +		default:
> +			usage(1);
> +			break;
> +		};
> +	}
> +
>  	*minimum_priority = sched_get_priority_min(policy);
>  
>  	if (check_privs())
> -- 
> 2.28.0
> 
> 

Uglifying my beautiful program in the name conformity?

Ugh, ok fine

Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 10/18] pmqtest: Streamline usage output and man page
  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
  1 sibling, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 18:18 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/pmqtest/pmqtest.8 |  5 ++-
>  src/pmqtest/pmqtest.c | 88 ++++++++++++++++++++++---------------------
>  2 files changed, 50 insertions(+), 43 deletions(-)
> 
> diff --git a/src/pmqtest/pmqtest.8 b/src/pmqtest/pmqtest.8
> index 9108a939b9f7..e44411ce0ef3 100644
> --- a/src/pmqtest/pmqtest.8
> +++ b/src/pmqtest/pmqtest.8
> @@ -4,7 +4,7 @@
>  \fBpmqtest\fR \- Start pairs of threads and measure the latency of interprocess communication with POSIX messages queues
>  .SH "SYNTAX"
>  .LP
> -pmqtest [-a|-a PROC] [-b USEC] [-d DIST] [-i INTV] [-l loops] [-p PRIO] [-S] [-t|-t NUM] [-T TO]
> +pmqtest [-a|-a PROC] [-b USEC] [-d DIST] [-D TIME] [-f TO] [-h] [-i INTV] [-l LOOPS] [-p PRIO] [-S] [-t|-t NUM]
>  .br
>  .SH "DESCRIPTION"
>  .LP
> @@ -26,6 +26,9 @@ Specify a length for the test run.
>  .br
>  Append 'm', 'h', or 'd' to specify minutes, hours or days.
>  .TP
> +.B \-h, \-\-help
> +Print help message
> +.TP
>  .B \-f, \-\-forcetimeout=TO
>  Set an artificial delay of the send function to force timeout of the receiver, requires the -T option
>  .TP
> diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c
> index 5db8d348cdf8..938dc8d93c3f 100644
> --- a/src/pmqtest/pmqtest.c
> +++ b/src/pmqtest/pmqtest.c
> @@ -217,36 +217,36 @@ void *pmqthread(void *param)
>  	return NULL;
>  }
>  
> -
> -static void display_help(void)
> +static void display_help(int error)
>  {
>  	printf("pmqtest V %1.2f\n", VERSION);
> -	puts("Usage: pmqtest <options>");
> -	puts("Function: test POSIX message queue latency");
> -	puts(
> -	"Options:\n"
> -	"-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> -	"                           with NUM pin all threads to the processor NUM\n"
> -	"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> -	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> -	"-f TO    --forcetimeout=TO force timeout of mq_timedreceive(), requires -T\n"
> -	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> -	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> -	"-D       --duration=TIME   specify a length for the test run.\n"
> -	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
> -	"-p PRIO  --prio=PRIO       priority\n"
> -	"-S       --smp             SMP testing: options -a -t and same priority\n"
> -        "                           of all threads\n"
> -	"-t       --threads         one thread per available processor\n"
> -	"-t [NUM] --threads=NUM     number of threads:\n"
> -	"                           without NUM, threads = max_cpus\n"
> -	"                           without -t default = 1\n"
> -	"-T TO    --timeout=TO      use mq_timedreceive() instead of mq_receive()\n"
> -	"                           with timeout TO in seconds\n");
> -	exit(1);
> +	printf("Usage:\n"
> +	       "pmqtest <options>\n\n"
> +	       "Function: test POSIX message queue latency\n\n"
> +	       "Available options:\n\n"
> +	       "-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> +	       "                           with NUM pin all threads to the processor NUM\n"
> +	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> +	       "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> +	       "-D TIME  --duration=TIME   specify a length for the test run.\n"
> +	       "                           Append 'm', 'h', or 'd' to specify\n"
> +	       "                           minutes, hours or days.\n"
> +	       "-f TO    --forcetimeout=TO force timeout of mq_timedreceive(), requires -T\n"
> +	       "-h       --help            print this help message\n"
> +	       "-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> +	       "-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> +	       "-p PRIO  --prio=PRIO       priority\n"
> +	       "-S       --smp             SMP testing: options -a -t and same priority\n"
> +	       "                           of all threads\n"
> +	       "-t       --threads         one thread per available processor\n"
> +	       "-t [NUM] --threads=NUM     number of threads:\n"
> +	       "                           without NUM, threads = max_cpus\n"
> +	       "                           without -t default = 1\n"
> +	       "-T TO    --timeout=TO      use mq_timedreceive() instead of mq_receive()\n"
> +	       "                           with timeout TO in seconds\n");
> +	exit(error);
>  }
>  
> -
>  static int setaffinity = AFFINITY_UNSPECIFIED;
>  static int affinity;
>  static int tracelimit;
> @@ -270,21 +270,21 @@ static void process_options (int argc, char *argv[])
>  		int option_index = 0;
>  		/** Options for getopt */
>  		static struct option long_options[] = {
> -			{"affinity", optional_argument, NULL, 'a'},
> -			{"breaktrace", required_argument, NULL, 'b'},
> -			{"distance", required_argument, NULL, 'd'},
> -			{"forcetimeout", required_argument, NULL, 'f'},
> -			{"interval", required_argument, NULL, 'i'},
> -			{"loops", required_argument, NULL, 'l'},
> -			{"duration", required_argument, NULL, 'D'},
> -			{"priority", required_argument, NULL, 'p'},
> -			{"smp", no_argument, NULL, 'S'},
> -			{"threads", optional_argument, NULL, 't'},
> -			{"timeout", required_argument, NULL, 'T'},
> -			{"help", no_argument, NULL, '?'},
> +			{"affinity",		optional_argument,	NULL, 'a'},
> +			{"breaktrace",		required_argument,	NULL, 'b'},
> +			{"distance",		required_argument,	NULL, 'd'},
> +			{"duration",		required_argument,	NULL, 'D'},
> +			{"forcetimeout",	required_argument,	NULL, 'f'},
> +			{"help",		no_argument,		NULL, 'h'},
> +			{"interval",		required_argument,	NULL, 'i'},
> +			{"loops",		required_argument,	NULL, 'l'},
> +			{"priority",		required_argument,	NULL, 'p'},
> +			{"smp",			no_argument,		NULL, 'S'},
> +			{"threads",		optional_argument,	NULL, 't'},
> +			{"timeout",		required_argument,	NULL, 'T'},
>  			{NULL, 0, NULL, 0}
>  		};
> -		int c = getopt_long (argc, argv, "a::b:d:f:i:l:D:p:St::T:",
> +		int c = getopt_long (argc, argv, "a::b:d:D:f:i:l:p:St::T:",
>  			long_options, &option_index);
>  		if (c == -1)
>  			break;
> @@ -306,10 +306,12 @@ static void process_options (int argc, char *argv[])
>  			break;
>  		case 'b': tracelimit = atoi(optarg); break;
>  		case 'd': distance = atoi(optarg); break;
> +		case 'D': duration = parse_time_string(optarg); break;
>  		case 'f': forcetimeout = atoi(optarg); break;
> +		case '?':
> +		case 'h': display_help(0); break;
>  		case 'i': interval = atoi(optarg); break;
>  		case 'l': max_cycles = atoi(optarg); break;
> -		case 'D': duration = parse_time_string(optarg); break;
>  		case 'p': priority = atoi(optarg); break;
>  		case 'S':
>  			smp = 1;
> @@ -329,7 +331,9 @@ static void process_options (int argc, char *argv[])
>  				num_threads = max_cpus;
>  			break;
>  		case 'T': timeout = atoi(optarg); break;
> -		case '?': error = 1; break;
> +		default:
> +			display_help(1);
> +			break;
>  		}
>  	}
>  
> @@ -362,7 +366,7 @@ static void process_options (int argc, char *argv[])
>  		sameprio = 1;
>  
>  	if (error)
> -		display_help ();
> +		display_help (error);
>  }
>  
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 10/18] pmqtest: Streamline usage output and man page
  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
  1 sibling, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 18:23 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/pmqtest/pmqtest.8 |  5 ++-
>  src/pmqtest/pmqtest.c | 88 ++++++++++++++++++++++---------------------
>  2 files changed, 50 insertions(+), 43 deletions(-)
> 
> diff --git a/src/pmqtest/pmqtest.8 b/src/pmqtest/pmqtest.8
> index 9108a939b9f7..e44411ce0ef3 100644
> --- a/src/pmqtest/pmqtest.8
> +++ b/src/pmqtest/pmqtest.8
> @@ -4,7 +4,7 @@
>  \fBpmqtest\fR \- Start pairs of threads and measure the latency of interprocess communication with POSIX messages queues
>  .SH "SYNTAX"
>  .LP
> -pmqtest [-a|-a PROC] [-b USEC] [-d DIST] [-i INTV] [-l loops] [-p PRIO] [-S] [-t|-t NUM] [-T TO]
> +pmqtest [-a|-a PROC] [-b USEC] [-d DIST] [-D TIME] [-f TO] [-h] [-i INTV] [-l LOOPS] [-p PRIO] [-S] [-t|-t NUM]
>  .br
>  .SH "DESCRIPTION"
>  .LP
> @@ -26,6 +26,9 @@ Specify a length for the test run.
>  .br
>  Append 'm', 'h', or 'd' to specify minutes, hours or days.
>  .TP
> +.B \-h, \-\-help
> +Print help message
> +.TP
>  .B \-f, \-\-forcetimeout=TO
>  Set an artificial delay of the send function to force timeout of the receiver, requires the -T option
>  .TP
> diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c
> index 5db8d348cdf8..938dc8d93c3f 100644
> --- a/src/pmqtest/pmqtest.c
> +++ b/src/pmqtest/pmqtest.c
> @@ -217,36 +217,36 @@ void *pmqthread(void *param)
>  	return NULL;
>  }
>  
> -
> -static void display_help(void)
> +static void display_help(int error)
>  {
>  	printf("pmqtest V %1.2f\n", VERSION);
> -	puts("Usage: pmqtest <options>");
> -	puts("Function: test POSIX message queue latency");
> -	puts(
> -	"Options:\n"
> -	"-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> -	"                           with NUM pin all threads to the processor NUM\n"
> -	"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> -	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> -	"-f TO    --forcetimeout=TO force timeout of mq_timedreceive(), requires -T\n"
> -	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> -	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> -	"-D       --duration=TIME   specify a length for the test run.\n"
> -	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
> -	"-p PRIO  --prio=PRIO       priority\n"
> -	"-S       --smp             SMP testing: options -a -t and same priority\n"
> -        "                           of all threads\n"
> -	"-t       --threads         one thread per available processor\n"
> -	"-t [NUM] --threads=NUM     number of threads:\n"
> -	"                           without NUM, threads = max_cpus\n"
> -	"                           without -t default = 1\n"
> -	"-T TO    --timeout=TO      use mq_timedreceive() instead of mq_receive()\n"
> -	"                           with timeout TO in seconds\n");
> -	exit(1);
> +	printf("Usage:\n"
> +	       "pmqtest <options>\n\n"
> +	       "Function: test POSIX message queue latency\n\n"
> +	       "Available options:\n\n"
> +	       "-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> +	       "                           with NUM pin all threads to the processor NUM\n"
> +	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> +	       "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> +	       "-D TIME  --duration=TIME   specify a length for the test run.\n"
> +	       "                           Append 'm', 'h', or 'd' to specify\n"
> +	       "                           minutes, hours or days.\n"
> +	       "-f TO    --forcetimeout=TO force timeout of mq_timedreceive(), requires -T\n"
> +	       "-h       --help            print this help message\n"
> +	       "-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> +	       "-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> +	       "-p PRIO  --prio=PRIO       priority\n"
> +	       "-S       --smp             SMP testing: options -a -t and same priority\n"
> +	       "                           of all threads\n"
> +	       "-t       --threads         one thread per available processor\n"
> +	       "-t [NUM] --threads=NUM     number of threads:\n"
> +	       "                           without NUM, threads = max_cpus\n"
> +	       "                           without -t default = 1\n"
> +	       "-T TO    --timeout=TO      use mq_timedreceive() instead of mq_receive()\n"
> +	       "                           with timeout TO in seconds\n");
> +	exit(error);
>  }
>  
> -
>  static int setaffinity = AFFINITY_UNSPECIFIED;
>  static int affinity;
>  static int tracelimit;
> @@ -270,21 +270,21 @@ static void process_options (int argc, char *argv[])
>  		int option_index = 0;
>  		/** Options for getopt */
>  		static struct option long_options[] = {
> -			{"affinity", optional_argument, NULL, 'a'},
> -			{"breaktrace", required_argument, NULL, 'b'},
> -			{"distance", required_argument, NULL, 'd'},
> -			{"forcetimeout", required_argument, NULL, 'f'},
> -			{"interval", required_argument, NULL, 'i'},
> -			{"loops", required_argument, NULL, 'l'},
> -			{"duration", required_argument, NULL, 'D'},
> -			{"priority", required_argument, NULL, 'p'},
> -			{"smp", no_argument, NULL, 'S'},
> -			{"threads", optional_argument, NULL, 't'},
> -			{"timeout", required_argument, NULL, 'T'},
> -			{"help", no_argument, NULL, '?'},
> +			{"affinity",		optional_argument,	NULL, 'a'},
> +			{"breaktrace",		required_argument,	NULL, 'b'},
> +			{"distance",		required_argument,	NULL, 'd'},
> +			{"duration",		required_argument,	NULL, 'D'},
> +			{"forcetimeout",	required_argument,	NULL, 'f'},
> +			{"help",		no_argument,		NULL, 'h'},
> +			{"interval",		required_argument,	NULL, 'i'},
> +			{"loops",		required_argument,	NULL, 'l'},
> +			{"priority",		required_argument,	NULL, 'p'},
> +			{"smp",			no_argument,		NULL, 'S'},
> +			{"threads",		optional_argument,	NULL, 't'},
> +			{"timeout",		required_argument,	NULL, 'T'},
>  			{NULL, 0, NULL, 0}
>  		};
> -		int c = getopt_long (argc, argv, "a::b:d:f:i:l:D:p:St::T:",
> +		int c = getopt_long (argc, argv, "a::b:d:D:f:i:l:p:St::T:",
>  			long_options, &option_index);
>  		if (c == -1)
>  			break;
> @@ -306,10 +306,12 @@ static void process_options (int argc, char *argv[])
>  			break;
>  		case 'b': tracelimit = atoi(optarg); break;
>  		case 'd': distance = atoi(optarg); break;
> +		case 'D': duration = parse_time_string(optarg); break;
>  		case 'f': forcetimeout = atoi(optarg); break;
> +		case '?':
> +		case 'h': display_help(0); break;
>  		case 'i': interval = atoi(optarg); break;
>  		case 'l': max_cycles = atoi(optarg); break;
> -		case 'D': duration = parse_time_string(optarg); break;
>  		case 'p': priority = atoi(optarg); break;
>  		case 'S':
>  			smp = 1;
> @@ -329,7 +331,9 @@ static void process_options (int argc, char *argv[])
>  				num_threads = max_cpus;
>  			break;
>  		case 'T': timeout = atoi(optarg); break;
> -		case '?': error = 1; break;
> +		default:
> +			display_help(1);
> +			break;
>  		}
>  	}
>  
> @@ -362,7 +366,7 @@ static void process_options (int argc, char *argv[])
>  		sameprio = 1;
>  
>  	if (error)
> -		display_help ();
> +		display_help (error);
>  }
>  
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 11/18] ptsematest: Streamline usage output and man page
  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
  1 sibling, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 18:25 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/ptsematest/ptsematest.8 |  5 ++-
>  src/ptsematest/ptsematest.c | 76 +++++++++++++++++++------------------
>  2 files changed, 44 insertions(+), 37 deletions(-)
> 
> diff --git a/src/ptsematest/ptsematest.8 b/src/ptsematest/ptsematest.8
> index 5ee7d694d50d..05a0cdfd3657 100644
> --- a/src/ptsematest/ptsematest.8
> +++ b/src/ptsematest/ptsematest.8
> @@ -4,7 +4,7 @@
>  \fBptsematest\fR \- Start two threads and measure the latency of interprocess communication with POSIX mutex.
>  .SH "SYNOPSIS"
>  .LP
> -ptsematest [-a|--affinity [PROC]] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME][-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-S|--smp] [-t|--threads [NUM]]
> +ptsematest [-a|--affinity [PROC]] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME] [-h|--help] [-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-S|--smp] [-t|--threads [NUM]]
>  .br
>  .SH "DESCRIPTION"
>  .LP
> @@ -26,6 +26,9 @@ Specify a length for the test run.
>  .br
>  Append 'm', 'h', or 'd' to specify minutes, hours or days.
>  .TP
> +.B \-h, \-\-help
> +Print help message.
> +.TP
>  .B \-i, \-\-interval=INTV
>  Set the base interval of the thread(s) in microseconds (default is 1000 us). This sets the interval of the first thread. See also -d.
>  .TP
> diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c
> index de8ea2fe1b0c..02919e3f5eef 100644
> --- a/src/ptsematest/ptsematest.c
> +++ b/src/ptsematest/ptsematest.c
> @@ -141,29 +141,31 @@ void *semathread(void *param)
>  }
>  
>  
> -static void display_help(void)
> +static void display_help(int error)
>  {
>  	printf("ptsematest V %1.2f\n", VERSION);
> -	puts("Usage: ptsematest <options>");
> -	puts("Function: test POSIX threads mutex latency");
> -	puts(
> -	"Options:\n"
> -	"-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> -	"                           with NUM pin all threads to the processor NUM\n"
> -	"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> -	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> -	"-D       --duration=TIME   specify a length for the test run.\n"
> -	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
> -	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> -	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> -	"-p PRIO  --prio=PRIO       priority\n"
> -	"-S       --smp             SMP testing: options -a -t and same priority\n"
> -        "                           of all threads\n"
> -	"-t       --threads         one thread per available processor\n"
> -	"-t [NUM] --threads=NUM     number of threads:\n"
> -	"                           without NUM, threads = max_cpus\n"
> -	"                           without -t default = 1\n");
> -	exit(1);
> +	printf("Usage:\n"
> +	       "ptsematest <options>\n\n"
> +	       "Function: test POSIX threads mutex latency\n\n"
> +	       "Available options:\n"
> +	       "-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> +	       "                           with NUM pin all threads to the processor NUM\n"
> +	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> +	       "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> +	       "-D       --duration=TIME   specify a length for the test run.\n"
> +	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
> +	       "                           days.\n"
> +	       "-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> +	       "-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> +	       "-p PRIO  --prio=PRIO       priority\n"
> +	       "-S       --smp             SMP testing: options -a -t and same priority\n"
> +	       "                           of all threads\n"
> +	       "-t       --threads         one thread per available processor\n"
> +	       "-t [NUM] --threads=NUM     number of threads:\n"
> +	       "                           without NUM, threads = max_cpus\n"
> +	       "                           without -t default = 1\n"
> +	       );
> +	exit(0);
>  }
>  
>  
> @@ -188,16 +190,16 @@ static void process_options (int argc, char *argv[])
>  		int option_index = 0;
>  		/** Options for getopt */
>  		static struct option long_options[] = {
> -			{"affinity", optional_argument, NULL, 'a'},
> -			{"breaktrace", required_argument, NULL, 'b'},
> -			{"distance", required_argument, NULL, 'd'},
> -			{"interval", required_argument, NULL, 'i'},
> -			{"loops", required_argument, NULL, 'l'},
> -			{"duration", required_argument, NULL, 'D'},
> -			{"priority", required_argument, NULL, 'p'},
> -			{"smp", no_argument, NULL, 'S'},
> -			{"threads", optional_argument, NULL, 't'},
> -			{"help", no_argument, NULL, '?'},
> +			{"affinity",	optional_argument,	NULL, 'a'},
> +			{"breaktrace",	required_argument,	NULL, 'b'},
> +			{"distance",	required_argument,	NULL, 'd'},
> +			{"duration",	required_argument,	NULL, 'D'},
> +			{"help",	no_argument,		NULL, 'h'},
> +			{"interval",	required_argument,	NULL, 'i'},
> +			{"loops",	required_argument,	NULL, 'l'},
> +			{"priority",	required_argument,	NULL, 'p'},
> +			{"smp",		no_argument,		NULL, 'S'},
> +			{"threads",	optional_argument,	NULL, 't'},
>  			{NULL, 0, NULL, 0}
>  		};
>  		int c = getopt_long (argc, argv, "a::b:d:i:l:D:p:St::h",
> @@ -222,9 +224,11 @@ static void process_options (int argc, char *argv[])
>  			break;
>  		case 'b': tracelimit = atoi(optarg); break;
>  		case 'd': distance = atoi(optarg); break;
> +		case 'D': duration = parse_time_string(optarg); break;
>  		case 'i': interval = atoi(optarg); break;
> +		case '?':
> +		case 'h': display_help(0); break;
>  		case 'l': max_cycles = atoi(optarg); break;
> -		case 'D': duration = parse_time_string(optarg); break;
>  		case 'p': priority = atoi(optarg); break;
>  		case 'S':
>  			smp = 1;
> @@ -243,9 +247,9 @@ static void process_options (int argc, char *argv[])
>  			else
>  				num_threads = max_cpus;
>  			break;
> -		case 'h':
> -			display_help();
> -		case '?': error = 1; break;
> +		default:
> +			display_help(1);
> +			break;
>  		}
>  	}
>  
> @@ -275,7 +279,7 @@ static void process_options (int argc, char *argv[])
>  		sameprio = 1;
>  
>  	if (error)
> -		display_help();
> +		display_help(error);
>  }
>  
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 12/18] queuelat: Streamline usage and man page
  2020-10-07  8:56 ` [rt-tests v2 12/18] queuelat: Streamline usage " Daniel Wagner
@ 2020-10-23 18:40   ` John Kacur
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 18:40 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



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>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 13/18] rt-migrate-test: Streamline usage and man page
  2020-10-07  8:56 ` [rt-tests v2 13/18] rt-migrate-test: " Daniel Wagner
@ 2020-10-23 18:47   ` John Kacur
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 18:47 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/rt-migrate-test/rt-migrate-test.8 | 41 +++++++-------
>  src/rt-migrate-test/rt-migrate-test.c | 82 +++++++++++++--------------
>  2 files changed, 59 insertions(+), 64 deletions(-)
> 
> diff --git a/src/rt-migrate-test/rt-migrate-test.8 b/src/rt-migrate-test/rt-migrate-test.8
> index b9c07f1ed80a..5bbacb5333b8 100644
> --- a/src/rt-migrate-test/rt-migrate-test.8
> +++ b/src/rt-migrate-test/rt-migrate-test.8
> @@ -1,11 +1,11 @@
>  .\"
> -.TH RT-MIGRATE-TEST 8 "April 21, 2016"
> +.TH RT-MIGRATE-TEST 8 "September 18, 2020"
>  .\" Please adjust this date whenever editing this manpage
>  .SH NAME
>  rt-migrate-test \- real-time task migration program
>  .SH SYNOPSIS
> -.B rt-migrate-test 
> -.RI "[\-ceh] [\-p prio] [\-r time] [\-s time] [\-m time] [\-l loops] [nr_tasks]
> +.LP
> +rt-migrate-test [-c|--check] [-D|--duration TIME] [-e|--equal] [-h|--help] [-l|--loops LOOPS] [-m|--maxerr TIME] [-p|--prio PRIO] [-r|--run-time TIME] [-s|--sleep-time TIME] [NR_TASKS]
>  .SH DESCRIPTION
>  Test real-time multiprocessor scheduling of tasks to ensure the highest priority tasks are running on all available CPUs
>  .SH OPTIONS
> @@ -15,44 +15,43 @@ This program follows the usual GNU command line syntax, with long options starti
>  In the summary of options, a value in brackets (), indicates a default value
>  .br
>  .TP
> +.B \-c, \-\-check
> +Stop if lower prio task is quicker than higher (off)
> +.TP
>  .B \-D, \-\-duration=TIME
>  Specify a length for the test run.
>  .br
>  Append 'm', 'h', or 'd' to specify minutes, hours or days.
>  .TP
> -.B \-p, \-\-prio=prio
> -base priority to start RT tasks with (2)
> +.B \-e, \-\-equal
> +Use equal prio for #CPU-1 tasks (requires > 2 CPUS)
>  .br
>  .TP
> -.B \-r, \-\-run\-time=time
> -Run time (ms) to busy loop the threads (20)
> +.B \-h, \-\-help
> +Display usage
>  .br
>  .TP
> -.B \-s, \-\-sleep\-time=time
> -Sleep time (ms) between intervals (100)
> +.B \-l \-\-loops=LOOPS
> +Number of iterations to run (50)
>  .br
>  .TP
> -.B \-m, \-\-maxerr=time
> +.B \-m, \-\-maxerr=TIME
>  Max allowed error (microsecs)
>  .br
>  .TP
> -.B \-l \-\-loops=loops
> -Number of iterations to run (50)
> -.br
> -.TP
> -.B \-e
> -Use equal prio for #CPU-1 tasks (requires > 2 CPUS)
> +.B \-p, \-\-prio=PRIO
> +base priority to start RT tasks with (2)
>  .br
>  .TP
> -.B \-c, \-\-check
> -Stop if lower prio task is quicker than higher (off)
> +.B \-r, \-\-run\-time=TIME
> +Run time (ms) to busy loop the threads (20)
>  .br
>  .TP
> -.B \-h, \-\-help
> -Display usage
> +.B \-s, \-\-sleep\-time=TIME
> +Sleep time (ms) between intervals (100)
>  .br
>  .TP
> -.B [nr\-tasks]
> +.B [NR_TASKS]
>  number of tasks to run (number of cpus + 1)
>  .br
>  .SH AUTHOR
> diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c
> index 4863238edeb4..68824606faf1 100644
> --- a/src/rt-migrate-test/rt-migrate-test.c
> +++ b/src/rt-migrate-test/rt-migrate-test.c
> @@ -146,71 +146,67 @@ static void print_progress_bar(int percent)
>  	fflush(stderr);
>  }
>  
> -static void usage(char **argv)
> +static void usage(int error)
>  {
> -	char *arg = argv[0];
> -	char *p = arg+strlen(arg);
> -
> -	while (p >= arg && *p != '/')
> -		p--;
> -	p++;
> -
> -	printf("%s %1.2f\n", p, VERSION);
> +	printf("rt-migrate-test %1.2f\n", VERSION);
>  	printf("Usage:\n"
> -	       "%s <options> nr_tasks\n\n"
> -	       "-p prio --prio  prio        base priority to start RT tasks with (2)\n"
> -	       "-r time --run-time time     Run time (ms) to busy loop the threads (20)\n"
> -	       "-s time --sleep-time time   Sleep time (ms) between intervals (100)\n"
> -	       "-m time --maxerr time       Max allowed error (microsecs)\n"
> -	       "-l loops --loops loops      Number of iterations to run (50)\n"
> -	       "-D       --duration=TIME    specify a length for the test run.\n"
> -	       "                            Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
> -	       "-e                          Use equal prio for #CPU-1 tasks (requires > 2 CPUS)\n"
> -	       "-c    --check               Stop if lower prio task is quicker than higher (off)\n"
> -	       "-h    --help\n"
> -	       "  () above are defaults \n",
> -		p);
> -	exit(0);
> +	       "rt-migrate-test <options> [NR_TASKS]\n\n"
> +	       "-c       --check           Stop if lower prio task is quicker than higher (off)\n"
> +	       "-D TIME  --duration=TIME   Specify a length for the test run.\n"
> +	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
> +	       "                           days.\n"
> +	       "-e       --equal           Use equal prio for #CPU-1 tasks (requires > 2 CPUS)\n"
> +	       "-h       --help            Print this help message\n"
> +	       "-l LOOPS --loops=LOOPS     Number of iterations to run (50)\n"
> +	       "-m TIME  --maxerr=TIME     Max allowed error (microsecs)\n"
> +	       "-p PRIO  --prio=PRIO       base priority to start RT tasks with (2)\n"
> +	       "-r TIME  --run-time=TIME   Run time (ms) to busy loop the threads (20)\n"
> +	       "-s TIME  --sleep-time=TIME Sleep time (ms) between intervals (100)\n\n"
> +	       "  () above are defaults \n"
> +	       );
> +	exit(error);
>  }
>  
> -static void parse_options (int argc, char *argv[])
> +static void parse_options(int argc, char *argv[])
>  {
>  	for (;;) {
>  		int option_index = 0;
>  		/** Options for getopt */
>  		static struct option long_options[] = {
> -			{"prio", required_argument, NULL, 'p'},
> -			{"run-time", required_argument, NULL, 'r'},
> -			{"sleep-time", required_argument, NULL, 's'},
> -			{"maxerr", required_argument, NULL, 'm'},
> -			{"loops", required_argument, NULL, 'l'},
> -			{"duration", required_argument, NULL, 'D'},
> -			{"check", no_argument, NULL, 'c'},
> -			{"help", no_argument, NULL, '?'},
> +			{"check",	no_argument,		NULL, 'c'},
> +			{"duration",	required_argument,	NULL, 'D'},
> +			{"equal",	no_argument,		NULL, 'e'},
> +			{"help",	no_argument,		NULL, 'h'},
> +			{"loops",	required_argument,	NULL, 'l'},
> +			{"maxerr",	required_argument,	NULL, 'm'},
> +			{"prio",	required_argument,	NULL, 'p'},
> +			{"run-time",	required_argument,	NULL, 'r'},
> +			{"sleep-time",	required_argument,	NULL, 's'},
>  			{NULL, 0, NULL, 0}
>  		};
> -		int c = getopt_long (argc, argv, "p:r:s:m:l:D:ech",
> +		int c = getopt_long(argc, argv, "cD:ehl:m:p:r:s:",
>  			long_options, &option_index);
>  		if (c == -1)
>  			break;
>  		switch (c) {
> -		case 'p': prio_start = atoi(optarg); break;
> -		case 'r':
> -			run_interval = atoi(optarg);
> -			break;
> -		case 's': interval = atoi(optarg); break;
> -		case 'l': nr_runs = atoi(optarg); break;
> +		case 'c': check = 1; break;
>  		case 'D': duration = parse_time_string(optarg); break;
> -		case 'm': max_err = usec2nano(atoi(optarg)); break;
>  		case 'e': equal = 1; break;
> -		case 'c': check = 1; break;
>  		case '?':
>  		case 'h':
> -			usage(argv);
> +			usage(0);
>  			break;
> +		case 'l': nr_runs = atoi(optarg); break;
> +		case 'm': max_err = usec2nano(atoi(optarg)); break;
> +		case 'p': prio_start = atoi(optarg); break;
> +		case 'r':
> +			run_interval = atoi(optarg);
> +			break;
> +		case 's': interval = atoi(optarg); break;
> +		default:
> +			usage(1);
>  		}
>  	}
> -
>  }
>  
>  static unsigned long long get_time(void)
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 14/18] signaltest: Streamline usage and man page
  2020-10-07  8:56 ` [rt-tests v2 14/18] signaltest: " Daniel Wagner
@ 2020-10-23 18:50   ` John Kacur
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 18:50 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/signaltest/signaltest.8 | 13 +++++-----
>  src/signaltest/signaltest.c | 47 ++++++++++++++++++++-----------------
>  2 files changed, 32 insertions(+), 28 deletions(-)
> 
> diff --git a/src/signaltest/signaltest.8 b/src/signaltest/signaltest.8
> index bd6ffe5c7a36..dc3eaab2293a 100644
> --- a/src/signaltest/signaltest.8
> +++ b/src/signaltest/signaltest.8
> @@ -1,11 +1,11 @@
>  .\"
> -.TH SIGNALTEST 8 "October 1, 2015"
> +.TH SIGNALTEST 8 "September 18, 2020"
>  .\" Please adjust this date whenever updating this manpage
>  .SH NAME
>  signaltest \- signal roundtrip test software
>  .SH SYNOPSIS
> -.B signaltest
> -.RI "[ \-b USEC ] [ \-l LOOPS ] [ \-p PRIO] [ \-q ] [ \-t NUM ] [ \-m ] [ \-v ] [ \-\-help ]"
> +.LP
> +signaltest [ -b|--backtrace USEC ] [-D|--duration TIME] [-h|--help] [-l|--loops LOOPS ] [-p|--prio PRIO] [-q|--quiet] [-t|--threads NUM] [-m|--mlockall ] [-v|--verbose ]
>  .SH OPTIONS
>  These programs follow the usual GNU command line syntax, with long options
>  starting with two dashes ('\-\-').
> @@ -18,6 +18,10 @@ Specify a length for the test run.
>  .br
>  Append 'm', 'h', or 'd' to specify minutes, hours or days.
>  .TP
> +.B \-\-help
> +.br
> +display usage information
> +.TP
>  .B \-l, \-\-loops=LOOPS
>  Number of loops: default=0 (endless)
>  .TP
> @@ -37,9 +41,6 @@ lock current and future memory allocations
>  output values on stdout for statistics
>  .br
>  format: n:c:v n=tasknum c=count v=value in us
> -.TP
> -.B \-\-help
> -display usage information
>  .SH AUTHOR
>  signaltest was written by Thomas Gleixner <tglx@linuxtronix.de>.
>  .PP
> diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
> index a67eddaf8420..c718f8676b9f 100644
> --- a/src/signaltest/signaltest.c
> +++ b/src/signaltest/signaltest.c
> @@ -180,23 +180,25 @@ void *signalthread(void *param)
>  
>  
>  /* Print usage information */
> -static void display_help(void)
> +static void display_help(int error)
>  {
>  	printf("signaltest V %1.2f\n", VERSION);
>  	printf("Usage:\n"
>  		"signaltest <options>\n\n"
>  		"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> -		"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
>  		"-D       --duration=TIME   specify a length for the test run.\n"
> -		"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
> +		"                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
> +		"                           days.\n"
> +		"-h       --help            display usage information\n"
> +		"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> +		"-m       --mlockall        lock current and future memory allocations\n"
>  		"-p PRIO  --prio=PRIO       priority of highest prio thread\n"
>  		"-q       --quiet           print a summary only on exit\n"
>  		"-t NUM   --threads=NUM     number of threads: default=2\n"
> -		"-m       --mlockall        lock current and future memory allocations\n"
>  		"-v       --verbose         output values on stdout for statistics\n"
>  		"                           format: n:c:v n=tasknum c=count v=value in us\n"
> -		"--help			    display usage information\n");
> -	exit(0);
> +		);
> +	exit(error);
>  }
>  
>  static int priority;
> @@ -208,38 +210,39 @@ static int quiet;
>  static int lockall = 0;
>  
>  /* Process commandline options */
> -static void process_options (int argc, char *argv[])
> +static void process_options(int argc, char *argv[])
>  {
>  	int error = 0;
>  	for (;;) {
>  		int option_index = 0;
>  		/** Options for getopt */
>  		static struct option long_options[] = {
> -			{"breaktrace", required_argument, NULL, 'b'},
> -			{"loops", required_argument, NULL, 'l'},
> -			{"duration", required_argument, NULL, 'D'},
> -			{"priority", required_argument, NULL, 'p'},
> -			{"quiet", no_argument, NULL, 'q'},
> -			{"threads", required_argument, NULL, 't'},
> -			{"verbose", no_argument, NULL, 'v'},
> -			{"mlockall", no_argument, NULL, 'm'},
> -			{"help", no_argument, NULL, '?'},
> +			{"breaktrace",		required_argument,	NULL, 'b'},
> +			{"duration",		required_argument,	NULL, 'D'},
> +			{"help",		no_argument,		NULL, 'h'},
> +			{"loops",		required_argument,	NULL, 'l'},
> +			{"mlockall",		no_argument,		NULL, 'm'},
> +			{"priority",		required_argument,	NULL, 'p'},
> +			{"quiet",		no_argument,		NULL, 'q'},
> +			{"threads",		required_argument,	NULL, 't'},
> +			{"verbose",		no_argument,		NULL, 'v'},
>  			{NULL, 0, NULL, 0}
>  		};
> -		int c = getopt_long (argc, argv, "b:c:d:i:l:D:np:qrsmt:v",
> -			long_options, &option_index);
> +		int c = getopt_long(argc, argv, "b:D:hl:mp:qt:v",
> +				long_options, &option_index);
>  		if (c == -1)
>  			break;
>  		switch (c) {
>  		case 'b': tracelimit = atoi(optarg); break;
> -		case 'l': max_cycles = atoi(optarg); break;
>  		case 'D': duration = parse_time_string(optarg); break;
> +		case '?':
> +		case 'h': display_help(0); break;
> +		case 'l': max_cycles = atoi(optarg); break;
> +		case 'm': lockall = 1; break;
>  		case 'p': priority = atoi(optarg); break;
>  		case 'q': quiet = 1; break;
>  		case 't': num_threads = atoi(optarg); break;
> -		case 'm': lockall = 1; break;
>  		case 'v': verbose = 1; break;
> -		case '?': error = 1; break;
>  		}
>  	}
>  
> @@ -253,7 +256,7 @@ static void process_options (int argc, char *argv[])
>  		error = 1;
>  
>  	if (error)
> -		display_help ();
> +		display_help(error);
>  }
>  
>  static void check_kernel(void)
> -- 
> 2.28.0
> 
> 

Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 15/18] sigwaittest: Streamline usage and man page
  2020-10-07  8:56 ` [rt-tests v2 15/18] sigwaittest: " Daniel Wagner
@ 2020-10-23 18:51   ` John Kacur
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 18:51 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/sigwaittest/sigwaittest.8 |  4 +-
>  src/sigwaittest/sigwaittest.c | 76 +++++++++++++++++++----------------
>  2 files changed, 44 insertions(+), 36 deletions(-)
> 
> diff --git a/src/sigwaittest/sigwaittest.8 b/src/sigwaittest/sigwaittest.8
> index 2be9c03d05ca..a2dc1bc080a3 100644
> --- a/src/sigwaittest/sigwaittest.8
> +++ b/src/sigwaittest/sigwaittest.8
> @@ -4,7 +4,7 @@
>  \fBsigwaittest\fR \- Start two threads or fork two processes and measure the latency between sending and receiving a signal
>  .SH "SYNTAX"
>  .LP
> -sigwaittest [-a|-a PROC] [-b USEC] [-d DIST] [-f] [-i INTV] [-l loops] [-p PRIO] [-t|-t NUM]
> +sigwaittest [-a|--affinity PROC] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME] [-f|--fork [OPT]] [-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-t|--threads [NUM]]
>  .br
>  .SH "DESCRIPTION"
>  .LP
> @@ -26,7 +26,7 @@ Specify a length for the test run.
>  .br
>  Append 'm', 'h', or 'd' to specify minutes, hours or days.
>  .TP
> -.B \-f, \-\-fork
> +.B \-f, \-\-fork[=OPT]
>  Instead of creating threads (which is the default), fork new processes
>  .TP
>  .B \-i, \-\-interval=INTV
> diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c
> index e7393f791519..12b55e901ce5 100644
> --- a/src/sigwaittest/sigwaittest.c
> +++ b/src/sigwaittest/sigwaittest.c
> @@ -206,28 +206,30 @@ void *semathread(void *param)
>  }
>  
>  
> -static void display_help(void)
> +static void display_help(int error)
>  {
>  	printf("sigwaittest V %1.2f\n", VERSION);
> -	puts("Usage: sigwaittest <options>");
> -	puts("Function: test sigwait() latency");
> -	puts(
> -	"Options:\n"
> -	"-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> -	"                           with NUM pin all threads to the processor NUM\n"
> -	"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> -	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> -	"-f       --fork            fork new processes instead of creating threads\n"
> -	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> -	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> -	"-D       --duration=TIME   specify a length for the test run.\n"
> -	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
> -	"-p PRIO  --prio=PRIO       priority\n"
> -	"-t       --threads         one thread per available processor\n"
> -	"-t [NUM] --threads=NUM     number of threads:\n"
> -	"                           without NUM, threads = max_cpus\n"
> -	"                           without -t default = 1\n");
> -	exit(1);
> +	printf("Usage:\n"
> +	       "sigwaittest <options>\n\n"
> +	       "Function: test sigwait() latency\n\n"
> +	       "Available options:\n"
> +	       "-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> +	       "                           with NUM pin all threads to the processor NUM\n"
> +	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> +	       "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> +	       "-D       --duration=TIME   specify a length for the test run.\n"
> +	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
> +	       "                           days.\n"
> +	       "-f [OPT] --fork[=OPT]      fork new processes instead of creating threads\n"
> +	       "-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> +	       "-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> +	       "-p PRIO  --prio=PRIO       priority\n"
> +	       "-t       --threads         one thread per available processor\n"
> +	       "-t [NUM] --threads=NUM     number of threads:\n"
> +	       "                           without NUM, threads = max_cpus\n"
> +	       "                           without -t default = 1\n"
> +	       );
> +	exit(error);
>  }
>  
>  
> @@ -250,19 +252,19 @@ static void process_options (int argc, char *argv[])
>  		int option_index = 0;
>  		/** Options for getopt */
>  		static struct option long_options[] = {
> -			{"affinity", optional_argument, NULL, 'a'},
> -			{"breaktrace", required_argument, NULL, 'b'},
> -			{"distance", required_argument, NULL, 'd'},
> -			{"fork", optional_argument, NULL, 'f'},
> -			{"interval", required_argument, NULL, 'i'},
> -			{"loops", required_argument, NULL, 'l'},
> -			{"duration", required_argument, NULL, 'D'},
> -			{"priority", required_argument, NULL, 'p'},
> -			{"threads", optional_argument, NULL, 't'},
> -			{"help", no_argument, NULL, '?'},
> +			{"affinity",		optional_argument,	NULL, 'a'},
> +			{"breaktrace",		required_argument,	NULL, 'b'},
> +			{"distance",		required_argument,	NULL, 'd'},
> +			{"duration",		required_argument,	NULL, 'D'},
> +			{"fork",		optional_argument,	NULL, 'f'},
> +			{"help",		no_argument,		NULL, 'h'},
> +			{"interval",		required_argument,	NULL, 'i'},
> +			{"loops",		required_argument,	NULL, 'l'},
> +			{"priority",		required_argument,	NULL, 'p'},
> +			{"threads",		optional_argument,	NULL, 't'},
>  			{NULL, 0, NULL, 0}
>  		};
> -		int c = getopt_long (argc, argv, "a::b:d:f::i:l:D:p:t::",
> +		int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:t::",
>  			long_options, &option_index);
>  		if (c == -1)
>  			break;
> @@ -280,6 +282,7 @@ static void process_options (int argc, char *argv[])
>  			break;
>  		case 'b': thistracelimit = atoi(optarg); break;
>  		case 'd': distance = atoi(optarg); break;
> +		case 'D': duration = parse_time_string(optarg); break;
>  		case 'f':
>  			if (optarg != NULL) {
>  				wasforked = 1;
> @@ -291,9 +294,12 @@ static void process_options (int argc, char *argv[])
>  			} else
>  				mustfork = 1;
>  			break;
> +		case '?':
> +		case 'h':
> +			display_help(0);
> +			break;
>  		case 'i': interval = atoi(optarg); break;
>  		case 'l': max_cycles = atoi(optarg); break;
> -		case 'D': duration = parse_time_string(optarg); break;
>  		case 'p': priority = atoi(optarg); break;
>  		case 't':
>  			if (optarg != NULL)
> @@ -303,7 +309,9 @@ static void process_options (int argc, char *argv[])
>  			else
>  				num_threads = max_cpus;
>  			break;
> -		case '?': error = 1; break;
> +		default:
> +			display_help(1);
> +			break;
>  		}
>  	}
>  
> @@ -331,7 +339,7 @@ static void process_options (int argc, char *argv[])
>  		tracelimit = thistracelimit;
>  	}
>  	if (error)
> -		display_help ();
> +		display_help (error);
>  }
>  
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 16/18] ssdd: Streamline usage and man page
  2020-10-07  8:56 ` [rt-tests v2 16/18] ssdd: " Daniel Wagner
@ 2020-10-23 18:57   ` John Kacur
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 18:57 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/ssdd/ssdd.8 | 35 +++++++++++++++++-----------------
>  src/ssdd/ssdd.c | 50 +++++++++++++++++++++++++++----------------------
>  2 files changed, 45 insertions(+), 40 deletions(-)
> 
> diff --git a/src/ssdd/ssdd.8 b/src/ssdd/ssdd.8
> index 99f30145d079..5c29d0abb732 100644
> --- a/src/ssdd/ssdd.8
> +++ b/src/ssdd/ssdd.8
> @@ -1,31 +1,30 @@
> -.TH SSDD 8 "June 13, 2019"
> +.TH SSDD 8 "September 19, 2020"
>  .SH NAME
>  ssdd \- have a tracer do a bunch of PTRACE_SINGLESTEPs
>  .SH SYNOPSIS
> -.B ssdd
> -.RI "<options>"
> +.LP
> +ssdd [-f|--forks NUM] [-h|--help] [-i|--iters NUM]
>  .SH DESCRIPTION
> -Have a tracer do a bunch of PTRACE_SINGLESTEPs against
> -a tracee as fast as possible.  Create several of these
> -tracer/tracee pairs and see if they can be made to
> -interfere with each other.
> -The tracer waits on each PTRACE_SINGLESTEP with a waitpid(2)
> -and checks that waitpid's return values for correctness.
> +Have a tracer do a bunch of PTRACE_SINGLESTEPs against a tracee as
> +fast as possible. Create several of these tracer/tracee pairs and
> +see if they can be made to interfere with each other. The tracer
> +waits on each PTRACE_SINGLESTEP with a waitpid(2) and checks that
> +waitpid's return values for correctness.
>  .SH OPTIONS
> -.B \-f, \-\-forks
> -number of tracer/tracee pairs to fork off.
> -Default is 10.
> -.br
>  .TP
> -.B \-i, \-\-iters
> -number of PTRACE_SINGLESTEP iterations to
> -do before declaring success, for each tracer/
> -tracee pair set up. Default is 10,000.
> +.B \-f, \-\-forks=NUM
> +number of tracer/tracee pairs to fork off.
>  .br
> +Default is 10.
>  .TP
>  .B \-h, \-\-help
>  Display usage
> -
> +.TP
> +.B \-i, \-\-iters=NUM
> +number of PTRACE_SINGLESTEP iterations to do before declaring
> +success, for each tracer tracee pair set up.
> +.br
> +Default is 10,000.
>  .SH AUTHOR
>  ssdd was written by Joe Korty <joe.korty@concurrent-rt.com>
>  .PP
> diff --git a/src/ssdd/ssdd.c b/src/ssdd/ssdd.c
> index f165da96e23a..66d6009dc572 100644
> --- a/src/ssdd/ssdd.c
> +++ b/src/ssdd/ssdd.c
> @@ -68,13 +68,16 @@ static int got_sigchld;
>  
>  enum option_value { OPT_NFORKS=1, OPT_NITERS, OPT_HELP };
>  
> -static void usage()
> +static void usage(int error)
>  {
> -	printf("ssdd <options>\n");
> -	printf("\t-f --forks=<number of forks>\n");
> -	printf("\t-i --iters=<number of iterations>\n");
> -	printf("\t-h --help\n");
> -	exit(0);
> +	printf("ssdd V %1.2f\n", VERSION);
> +	printf("Usage:\n"
> +	       "ssdd <options>\n\n"
> +	       "-f       --forks=NUM       number of forks\n"
> +	       "-h       --help            print this message\n"
> +	       "-i       --iters=NUM       number of iterations\n"
> +	       );
> +	exit(error);
>  }
>  
>  static int do_wait(pid_t *wait_pid, int *ret_sig)
> @@ -292,27 +295,30 @@ int main(int argc, char **argv)
>  		int option_index = 0;
>  
>  		static struct option long_options[] = {
> -			{"forks", required_argument, NULL, OPT_NFORKS},
> -			{"iters", required_argument, NULL, OPT_NITERS},
> -			{"help", no_argument, NULL, OPT_HELP},
> +			{"forks",		required_argument,	NULL, OPT_NFORKS},
> +			{"help",		no_argument,		NULL, OPT_HELP},
> +			{"iters",		required_argument,	NULL, OPT_NITERS},
>  			{NULL, 0, NULL, 0},
>  		};
> -		int c = getopt_long(argc, argv, "f:i:h", long_options, &option_index);
> +		int c = getopt_long(argc, argv, "f:hi:", long_options, &option_index);
>  		if (c == -1)
>  			break;
>  		switch(c) {
> -			case 'f':
> -			case OPT_NFORKS:
> -				nforks = atoi(optarg);
> -				break;
> -			case 'i':
> -			case OPT_NITERS:
> -				nsteps = atoi(optarg);
> -				break;
> -			case 'h':
> -			case OPT_HELP:
> -				usage();
> -				break;
> +		case 'f':
> +		case OPT_NFORKS:
> +			nforks = atoi(optarg);
> +			break;
> +		case 'h':
> +		case OPT_HELP:
> +			usage(0);
> +			break;
> +		case 'i':
> +		case OPT_NITERS:
> +			nsteps = atoi(optarg);
> +			break;
> +		default:
> +			usage(1);
> +			break;
>  		}
>  	}
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 17/18] svsematest: Streamline usage and man page
  2020-10-07  8:56 ` [rt-tests v2 17/18] svsematest: " Daniel Wagner
@ 2020-10-23 18:59   ` John Kacur
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 18:59 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



On Wed, 7 Oct 2020, Daniel Wagner wrote:

> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>  src/svsematest/svsematest.8 |  6 +--
>  src/svsematest/svsematest.c | 83 +++++++++++++++++++------------------
>  2 files changed, 46 insertions(+), 43 deletions(-)
> 
> diff --git a/src/svsematest/svsematest.8 b/src/svsematest/svsematest.8
> index 98322c105803..5fcb96149bdd 100644
> --- a/src/svsematest/svsematest.8
> +++ b/src/svsematest/svsematest.8
> @@ -4,15 +4,15 @@
>  \fBsvsematest\fR \- Start two threads or fork two processes and measure the latency of SYSV semaphores
>  .SH "SYNTAX"
>  .LP
> -svsematest [-a|-a PROC] [-b USEC] [-d DIST] [-f] [-i INTV] [-l loops] [-p PRIO] [-t|-t NUM]
> +svsematest [-a|--affinity NUM] [-b|--breaktrace USEC] [-d|--distance DIST] [-D|--duration TIME] [-f|--fork [OPT]] [-i|--interval INTV] [-l|--loops LOOPS] [-p|--prio PRIO] [-S|--smp] [-t|--threads [NUM]]
>  .br
>  .SH "DESCRIPTION"
>  .LP
>  The program \fBsvsematest\fR starts two threads or, optionally, forks two processes that are synchronized via SYSV semaphores and measures the latency between releasing a semaphore on one side and getting it on the other side.
>  .SH "OPTIONS"
>  .TP
> -.B \-a, \-\-affinity[=PROC]
> -Run on processor number PROC. If PROC is not specified, run on current processor.
> +.B \-a, \-\-affinity[=NUM]
> +Run on processor number NUM. If PROC is not specified, run on current processor.
>  .TP
>  .B \-b, \-\-breaktrace=USEC
>  Send break trace command when latency > USEC. This is a debugging option to control the latency tracer in the realtime preemption patch.
> diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c
> index 607b397bf39e..7412168bd98a 100644
> --- a/src/svsematest/svsematest.c
> +++ b/src/svsematest/svsematest.c
> @@ -218,33 +218,34 @@ union semun {
>  };
>  
>  
> -static void display_help(void)
> +static void display_help(int error)
>  {
>  	printf("svsematest V %1.2f\n", VERSION);
> -	puts("Usage: svsematest <options>");
> -	puts("Function: test SYSV semaphore latency");
> -	puts(
> -	"Options:\n"
> -	"-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> -	"                           with NUM pin all threads to the processor NUM\n"
> -	"-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> -	"-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> -	"-f       --fork            fork new processes instead of creating threads\n"
> -	"-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> -	"-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> -	"-D       --duration=TIME   specify a length for the test run.\n"
> -	"                           Append 'm', 'h', or 'd' to specify minutes, hours or days.\n"
> -	"-p PRIO  --prio=PRIO       priority\n"
> -	"-S       --smp             SMP testing: options -a -t and same priority\n"
> -        "                           of all threads\n"
> -	"-t       --threads         one thread per available processor\n"
> -	"-t [NUM] --threads=NUM     number of threads:\n"
> -	"                           without NUM, threads = max_cpus\n"
> -	"                           without -t default = 1\n");
> -	exit(1);
> +	printf("Usage:\n"
> +	       "svsematest <options>\n\n"
> +	       "Function: test SYSV semaphore latency\n\n"
> +	       "Avaiable options:\n"
> +	       "-a [NUM] --affinity        run thread #N on processor #N, if possible\n"
> +	       "                           with NUM pin all threads to the processor NUM\n"
> +	       "-b USEC  --breaktrace=USEC send break trace command when latency > USEC\n"
> +	       "-d DIST  --distance=DIST   distance of thread intervals in us default=500\n"
> +	       "-D       --duration=TIME   specify a length for the test run.\n"
> +	       "                           Append 'm', 'h', or 'd' to specify minutes, hours or\n"
> +	       "                           days.\n"
> +	       "-f [OPT] --fork[=OPT]      fork new processes instead of creating threads\n"
> +	       "-i INTV  --interval=INTV   base interval of thread in us default=1000\n"
> +	       "-l LOOPS --loops=LOOPS     number of loops: default=0(endless)\n"
> +	       "-p PRIO  --prio=PRIO       priority\n"
> +	       "-S       --smp             SMP testing: options -a -t and same priority\n"
> +	       "                           of all threads\n"
> +	       "-t       --threads         one thread per available processor\n"
> +	       "-t [NUM] --threads[=NUM]   number of threads:\n"
> +	       "                           without NUM, threads = max_cpus\n"
> +	       "                           without -t default = 1\n"
> +	       );
> +	exit(error);
>  }
>  
> -
>  static int setaffinity = AFFINITY_UNSPECIFIED;
>  static int affinity;
>  static int priority;
> @@ -256,7 +257,7 @@ static int distance = 500;
>  static int smp;
>  static int sameprio;
>  
> -static void process_options (int argc, char *argv[])
> +static void process_options(int argc, char *argv[])
>  {
>  	int error = 0;
>  	int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
> @@ -266,20 +267,20 @@ static void process_options (int argc, char *argv[])
>  		int option_index = 0;
>  		/** Options for getopt */
>  		static struct option long_options[] = {
> -			{"affinity", optional_argument, NULL, 'a'},
> -			{"breaktrace", required_argument, NULL, 'b'},
> -			{"distance", required_argument, NULL, 'd'},
> -			{"fork", optional_argument, NULL, 'f'},
> -			{"interval", required_argument, NULL, 'i'},
> -			{"loops", required_argument, NULL, 'l'},
> -			{"duration", required_argument, NULL, 'D'},
> -			{"priority", required_argument, NULL, 'p'},
> -			{"smp", no_argument, NULL, 'S'},
> -			{"threads", optional_argument, NULL, 't'},
> -			{"help", no_argument, NULL, '?'},
> +			{"affinity",		optional_argument,	NULL, 'a'},
> +			{"breaktrace",		required_argument,	NULL, 'b'},
> +			{"distance",		required_argument,	NULL, 'd'},
> +			{"duration",		required_argument,	NULL, 'D'},
> +			{"fork",		optional_argument,	NULL, 'f'},
> +			{"help",		no_argument,		NULL, 'h'},
> +			{"interval",		required_argument,	NULL, 'i'},
> +			{"loops",		required_argument,	NULL, 'l'},
> +			{"priority",		required_argument,	NULL, 'p'},
> +			{"smp",			no_argument,		NULL, 'S'},
> +			{"threads",		optional_argument,	NULL, 't'},
>  			{NULL, 0, NULL, 0}
>  		};
> -		int c = getopt_long (argc, argv, "a::b:d:f::i:l:D:p:St::h",
> +		int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:St::",
>  			long_options, &option_index);
>  		if (c == -1)
>  			break;
> @@ -301,6 +302,7 @@ static void process_options (int argc, char *argv[])
>  			break;
>  		case 'b': thistracelimit = atoi(optarg); break;
>  		case 'd': distance = atoi(optarg); break;
> +		case 'D': duration = parse_time_string(optarg); break;
>  		case 'f':
>  			if (optarg != NULL) {
>  				wasforked = 1;
> @@ -312,9 +314,9 @@ static void process_options (int argc, char *argv[])
>  			} else
>  				mustfork = 1;
>  			break;
> +		case 'h': display_help(0); break;
>  		case 'i': interval = atoi(optarg); break;
>  		case 'l': max_cycles = atoi(optarg); break;
> -		case 'D': duration = parse_time_string(optarg); break;
>  		case 'p': priority = atoi(optarg); break;
>  		case 'S':
>  			smp = 1;
> @@ -333,8 +335,9 @@ static void process_options (int argc, char *argv[])
>  			else
>  				num_threads = max_cpus;
>  			break;
> -		case 'h': error = 1; break;
> -		case '?': error = 1; break;
> +		default:
> +			display_help(1);
> +			break;
>  		}
>  	}
>  
> @@ -365,7 +368,7 @@ static void process_options (int argc, char *argv[])
>  		tracelimit = thistracelimit;
>  	}
>  	if (error)
> -		display_help ();
> +		display_help(error);
>  }
>  
>  
> -- 
> 2.28.0
> 
> 
Signed-off-by: John Kacur <jkacur@redhat.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 18/18] hackbench: Streamline usage and man page
  2020-10-07  8:56 ` [rt-tests v2 18/18] hackbench: " Daniel Wagner
@ 2020-10-23 19:03   ` John Kacur
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-23 19:03 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, linux-rt-users



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>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 01/18] rt-util: Move parse_cpumask from cyclictest
  2020-10-23 15:46   ` John Kacur
@ 2020-10-26 18:34     ` Daniel Wagner
  2020-10-29 15:45       ` John Kacur
  0 siblings, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2020-10-26 18:34 UTC (permalink / raw)
  To: John Kacur; +Cc: Daniel Wagner, Clark Williams, linux-rt-users

Hi John,

On Fri, Oct 23, 2020 at 11:46:54AM -0400, John Kacur wrote:
> >  TARGETS = $(sources:.c=)
> >  LIBS	= -lrt -lpthread
> > -RTTESTLIB = -lrttest -L$(OBJDIR)
> > +RTTESTLIB = -lrttest -L$(OBJDIR) $(NUMA_LIBS)
> 
> Currently only cyclictest was compiled with NUMA_LIBS, this change will 
> compile everything with NUMA_LIBS. I checked the size of the programs, and 
> they don't grow that much with this change, but they are small programs to
> begin with, do we want to keep this functionality separate?

My thinking is, that the most important program for testing seems to be
cyclictest. Everyone will run cyclictest on the target platform. Thus
libnuma will be available. So there wont be any new unresolved
dependencies.

I traded the size increase for simplification in the code base and build
setup. Looking at the actual increase (x86_64, stripped) is not too bad:


program                 old      new     diff
---------------------------------------------------
cyclicdeadline          35488    35552     64 0.18%
cyclictest              57632    57632      0 0.0%
deadline_test           43712    43776     64 0.15%
hackbench               19168    19168      0 0.0%
oslat                   36040    36072     32 0.089%
pip_stress              27296    27360     64 0.23%
pi_stress               44296    48456   4160 9.4%
pmqtest                 31864    31928     64 0.2%
ptsematest              31752    31816     64 0.2%
queuelat                14600    14600      0 0.0%
rt-migrate-test         31696    31728     32 0.1%
signaltest              31712    31776     64 0.2%
sigwaittest             31792    31856     64 0.2%
ssdd                    14744    14744      0 0.0%
svsematest              31856    31920     64 0.2%


pi_stress is a bit odd though. Not sure what's happening there. Will
look into it.

So I would prefer to go this route and makes things simpler in the code
base.

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 04/18] cyclicdeadline: Add long command line options
  2020-10-23 16:07   ` John Kacur
@ 2020-10-27  8:07     ` Daniel Wagner
  0 siblings, 0 replies; 49+ messages in thread
From: Daniel Wagner @ 2020-10-27  8:07 UTC (permalink / raw)
  To: John Kacur; +Cc: Daniel Wagner, Clark Williams, linux-rt-users

On Fri, Oct 23, 2020 at 12:07:18PM -0400, John Kacur wrote:
> Go ahead and send me a patch to remove the -c option
> no need to retain this for silent backwards compatibility.

As I said, the reason I left the -c option is my attempt not to break
existing setups. It's usually a bit annoying as user if tools change
interfaces while keeping the same major version number.

But then there are properly not many users anyway and those are capable
to handle the change. I'll send a patch.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 07/18] oslat: Use string parser utilies
  2020-10-23 17:25   ` John Kacur
@ 2020-10-27  8:09     ` Daniel Wagner
  0 siblings, 0 replies; 49+ messages in thread
From: Daniel Wagner @ 2020-10-27  8:09 UTC (permalink / raw)
  To: John Kacur; +Cc: Daniel Wagner, Clark Williams, linux-rt-users

On Fri, Oct 23, 2020 at 01:25:56PM -0400, John Kacur wrote:
> This one is pending either your changes that I requested to the first 
> patch, or an argument as to why I should accept the first patch.

Ok. Let me know what you think about my argument in my reply to the
first patch.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 08/18] pip_stress: Add command line parser
  2020-10-23 17:33   ` John Kacur
@ 2020-10-27  8:09     ` Daniel Wagner
  0 siblings, 0 replies; 49+ messages in thread
From: Daniel Wagner @ 2020-10-27  8:09 UTC (permalink / raw)
  To: John Kacur; +Cc: Daniel Wagner, Clark Williams, linux-rt-users

On Fri, Oct 23, 2020 at 01:33:42PM -0400, John Kacur wrote:
> Uglifying my beautiful program in the name conformity?

But now it can say 'help' :)

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 01/18] rt-util: Move parse_cpumask from cyclictest
  2020-10-26 18:34     ` Daniel Wagner
@ 2020-10-29 15:45       ` John Kacur
  0 siblings, 0 replies; 49+ messages in thread
From: John Kacur @ 2020-10-29 15:45 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Daniel Wagner, Clark Williams, linux-rt-users



On Mon, 26 Oct 2020, Daniel Wagner wrote:

> Hi John,
> 
> On Fri, Oct 23, 2020 at 11:46:54AM -0400, John Kacur wrote:
> > >  TARGETS = $(sources:.c=)
> > >  LIBS	= -lrt -lpthread
> > > -RTTESTLIB = -lrttest -L$(OBJDIR)
> > > +RTTESTLIB = -lrttest -L$(OBJDIR) $(NUMA_LIBS)
> > 
> > Currently only cyclictest was compiled with NUMA_LIBS, this change will 
> > compile everything with NUMA_LIBS. I checked the size of the programs, and 
> > they don't grow that much with this change, but they are small programs to
> > begin with, do we want to keep this functionality separate?
> 
> My thinking is, that the most important program for testing seems to be
> cyclictest. Everyone will run cyclictest on the target platform. Thus
> libnuma will be available. So there wont be any new unresolved
> dependencies.
> 
> I traded the size increase for simplification in the code base and build
> setup. Looking at the actual increase (x86_64, stripped) is not too bad:
> 
> 
> program                 old      new     diff
> ---------------------------------------------------
> cyclicdeadline          35488    35552     64 0.18%
> cyclictest              57632    57632      0 0.0%
> deadline_test           43712    43776     64 0.15%
> hackbench               19168    19168      0 0.0%
> oslat                   36040    36072     32 0.089%
> pip_stress              27296    27360     64 0.23%
> pi_stress               44296    48456   4160 9.4%
> pmqtest                 31864    31928     64 0.2%
> ptsematest              31752    31816     64 0.2%
> queuelat                14600    14600      0 0.0%
> rt-migrate-test         31696    31728     32 0.1%
> signaltest              31712    31776     64 0.2%
> sigwaittest             31792    31856     64 0.2%
> ssdd                    14744    14744      0 0.0%
> svsematest              31856    31920     64 0.2%
> 
> 
> pi_stress is a bit odd though. Not sure what's happening there. Will
> look into it.
> 
> So I would prefer to go this route and makes things simpler in the code
> base.
> 
> Thanks,
> Daniel
> 

You're really just simplifying the Makefile, not the code. :)
Well, that and I guess this means I'm asking you to separate any common
numa functionality into a separate lib. If you want you can just pull out
parse_time_string(), and parse_mem_string() for now until we hash out
what we want to do with the numa functionality later.

Does that work for you?

John 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 11/18] ptsematest: Streamline usage output and man page
  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
  1 sibling, 1 reply; 49+ messages in thread
From: Peter Xu @ 2021-02-10 16:08 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, John Kacur, linux-rt-users

On Wed, Oct 07, 2020 at 10:56:46AM +0200, Daniel Wagner wrote:
> Signed-off-by: Daniel Wagner <dwagner@suse.de>

Hi, Daniel,

This seems to have broken oslat with "oslat -v".  Would you help recover the
old behavior somehow?

Thanks,

-- 
Peter Xu


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 11/18] ptsematest: Streamline usage output and man page
  2021-02-10 16:08   ` Peter Xu
@ 2021-02-10 16:25     ` Peter Xu
  2021-02-10 16:30       ` Daniel Wagner
  0 siblings, 1 reply; 49+ messages in thread
From: Peter Xu @ 2021-02-10 16:25 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, John Kacur, linux-rt-users

On Wed, Feb 10, 2021 at 11:08:47AM -0500, Peter Xu wrote:
> On Wed, Oct 07, 2020 at 10:56:46AM +0200, Daniel Wagner wrote:
> > Signed-off-by: Daniel Wagner <dwagner@suse.de>
> 
> Hi, Daniel,
> 
> This seems to have broken oslat with "oslat -v".  Would you help recover the
> old behavior somehow?

To be explicit, I didn't mean only "oslat -v".  It dumps nothing now which
definitely is not right..  Also I explicitly dump version for every oslat run
because I wanted that to be with the output, so when user reports issue with
oslat we'll always know which version is it.  So besides the "oslat -v"
breakage, I'd really appreciate if you can add the version dump back with every
oslat run, too.

Thanks,

-- 
Peter Xu


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 11/18] ptsematest: Streamline usage output and man page
  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
  0 siblings, 2 replies; 49+ messages in thread
From: Daniel Wagner @ 2021-02-10 16:30 UTC (permalink / raw)
  To: Peter Xu; +Cc: Clark Williams, John Kacur, linux-rt-users

So this is only about oslat, right? I ask because you respone to the
email for ptsematest.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 11/18] ptsematest: Streamline usage output and man page
  2021-02-10 16:30       ` Daniel Wagner
@ 2021-02-10 16:33         ` Peter Xu
  2021-02-10 16:35         ` Daniel Wagner
  1 sibling, 0 replies; 49+ messages in thread
From: Peter Xu @ 2021-02-10 16:33 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, John Kacur, linux-rt-users

On Wed, Feb 10, 2021 at 05:30:57PM +0100, Daniel Wagner wrote:
> So this is only about oslat, right? I ask because you respone to the
> email for ptsematest.

Sorry I replied to the wrong subject - yes it's about oslat, only.

Thanks,

-- 
Peter Xu


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 11/18] ptsematest: Streamline usage output and man page
  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
  1 sibling, 1 reply; 49+ messages in thread
From: Daniel Wagner @ 2021-02-10 16:35 UTC (permalink / raw)
  To: Peter Xu; +Cc: Clark Williams, John Kacur, linux-rt-users

--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -655,16 +655,10 @@ static void parse_options(int argc, char *argv[])
                         */
                        g.single_preheat_thread = true;
                        break;
-               case 'v':
-                       /*
-                        * Because we always dump the version even before parsing options,
-                        * what we need to do is to quit..
-                        */
-                       exit(0);
-                       break;
                case 'z':
                        g.output_omit_zero_buckets = 1;
                        break;
+               case 'v':
                case 'h':
                        usage(0);
                        break;



$ ./oslat -v
oslat V 1.10
Usage:
oslat <options>

This is an OS latency detector by running busy loops on specified cores.
Please run this tool using root.

Available options:

-b, --bucket-size      Specify the number of the buckets (4-1024)
-B, --bias             Add a bias to all the buckets using the estimated mininum
-c, --cpu-list         Specify CPUs to run on, e.g. '1,3,5,7-15'
-C, --cpu-main-thread  Specify which CPU the main thread runs on.  Default is cpu0.
-D, --duration         Specify test duration, e.g., 60, 20m, 2H
                       (m/M: minutes, h/H: hours, d/D: days)
-f, --rtprio           Using SCHED_FIFO priority (1-99)
-m, --workload-mem     Size of the memory to use for the workload (e.g., 4K, 1M).
                       Total memory usage will be this value multiplies 2*N,
                       because there will be src/dst buffers for each thread, and
                       N is the number of processors for testing.
-s, --single-preheat   Use a single thread when measuring latency at preheat stage
                       NOTE: please make sure the CPU frequency on all testing cores
                       are locked before using this parmater.  If you don't know how
                       to lock the freq then please don't use this parameter.
-T, --trace-threshold  Stop the test when threshold triggered (in us),
                       print a marker in ftrace and stop ftrace too.
-v, --version          Display the version of the software.
-w, --workload         Specify a kind of workload, default is no workload
                       (options: no, memmove)
-z, --zero-omit        Don't display buckets in the output histogram if all zeros.



The other tests print also the usage text which included the version if
you provided '--version'. So this would make it behave in the same way.
Good enough?

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 11/18] ptsematest: Streamline usage output and man page
  2021-02-10 16:35         ` Daniel Wagner
@ 2021-02-10 17:00           ` Peter Xu
  2021-02-10 17:24             ` Daniel Wagner
  0 siblings, 1 reply; 49+ messages in thread
From: Peter Xu @ 2021-02-10 17:00 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Clark Williams, John Kacur, linux-rt-users

On Wed, Feb 10, 2021 at 05:35:37PM +0100, Daniel Wagner wrote:
> --- a/src/oslat/oslat.c
> +++ b/src/oslat/oslat.c
> @@ -655,16 +655,10 @@ static void parse_options(int argc, char *argv[])
>                          */
>                         g.single_preheat_thread = true;
>                         break;
> -               case 'v':
> -                       /*
> -                        * Because we always dump the version even before parsing options,
> -                        * what we need to do is to quit..
> -                        */
> -                       exit(0);
> -                       break;
>                 case 'z':
>                         g.output_omit_zero_buckets = 1;
>                         break;
> +               case 'v':
>                 case 'h':
>                         usage(0);
>                         break;
> 
> 
> 
> $ ./oslat -v
> oslat V 1.10
> Usage:
> oslat <options>
> 
> This is an OS latency detector by running busy loops on specified cores.
> Please run this tool using root.
> 
> Available options:
> 
> -b, --bucket-size      Specify the number of the buckets (4-1024)
> -B, --bias             Add a bias to all the buckets using the estimated mininum
> -c, --cpu-list         Specify CPUs to run on, e.g. '1,3,5,7-15'
> -C, --cpu-main-thread  Specify which CPU the main thread runs on.  Default is cpu0.
> -D, --duration         Specify test duration, e.g., 60, 20m, 2H
>                        (m/M: minutes, h/H: hours, d/D: days)
> -f, --rtprio           Using SCHED_FIFO priority (1-99)
> -m, --workload-mem     Size of the memory to use for the workload (e.g., 4K, 1M).
>                        Total memory usage will be this value multiplies 2*N,
>                        because there will be src/dst buffers for each thread, and
>                        N is the number of processors for testing.
> -s, --single-preheat   Use a single thread when measuring latency at preheat stage
>                        NOTE: please make sure the CPU frequency on all testing cores
>                        are locked before using this parmater.  If you don't know how
>                        to lock the freq then please don't use this parameter.
> -T, --trace-threshold  Stop the test when threshold triggered (in us),
>                        print a marker in ftrace and stop ftrace too.
> -v, --version          Display the version of the software.
> -w, --workload         Specify a kind of workload, default is no workload
>                        (options: no, memmove)
> -z, --zero-omit        Don't display buckets in the output histogram if all zeros.
> 
> 
> 
> The other tests print also the usage text which included the version if
> you provided '--version'. So this would make it behave in the same way.
> Good enough?

It makes sense to make all binaries in rt-tests behave similarly, so regarding
"oslat -v" even if it's not my preference, it's fine to me.

Again - Would you consider also dump the version in the output as before even
for a normal run?

-- 
Peter Xu


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [rt-tests v2 11/18] ptsematest: Streamline usage output and man page
  2021-02-10 17:00           ` Peter Xu
@ 2021-02-10 17:24             ` Daniel Wagner
  0 siblings, 0 replies; 49+ messages in thread
From: Daniel Wagner @ 2021-02-10 17:24 UTC (permalink / raw)
  To: Peter Xu; +Cc: Clark Williams, John Kacur, linux-rt-users

> It makes sense to make all binaries in rt-tests behave similarly, so regarding
> "oslat -v" even if it's not my preference, it's fine to me.

We could also update all other tools to just print the version string
for '--version'. I don't have a strong preference. My main concern is
that I don't want the tools to differ in the usage pattern. BTW, I think
I would drop '-v' as short command line option as for example cyclictest
uses '-v' for verbose.

> Again - Would you consider also dump the version in the output as before even
> for a normal run?

Again, I don't have a strong opinion here. Just the same argument as
before, all tools should behave in the same way.

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2021-02-10 17:25 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).