From patchwork Wed Oct 7 08:56:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 268384 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1162C4727E for ; Wed, 7 Oct 2020 08:57:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EE4D20870 for ; Wed, 7 Oct 2020 08:57:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728009AbgJGI5A (ORCPT ); Wed, 7 Oct 2020 04:57:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:57570 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbgJGI47 (ORCPT ); Wed, 7 Oct 2020 04:56:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id DC869ACF5; Wed, 7 Oct 2020 08:56:57 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 03/18] cyclicdeadline: Streamline usage output and man page Date: Wed, 7 Oct 2020 10:56:38 +0200 Message-Id: <20201007085653.11961-4-dwagner@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007085653.11961-1-dwagner@suse.de> References: <20201007085653.11961-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- 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 .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 \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); } } From patchwork Wed Oct 7 08:56:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 268385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0722EC4741F for ; Wed, 7 Oct 2020 08:57:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0F9420797 for ; Wed, 7 Oct 2020 08:57:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727975AbgJGI5A (ORCPT ); Wed, 7 Oct 2020 04:57:00 -0400 Received: from mx2.suse.de ([195.135.220.15]:57582 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727945AbgJGI47 (ORCPT ); Wed, 7 Oct 2020 04:56:59 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4C183B15F; Wed, 7 Oct 2020 08:56:58 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 04/18] cyclicdeadline: Add long command line options Date: Wed, 7 Oct 2020 10:56:39 +0200 Message-Id: <20201007085653.11961-5-dwagner@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007085653.11961-1-dwagner@suse.de> References: <20201007085653.11961-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org 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 Signed-off-by: John Kacur --- 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 #include #include +#include #include #include @@ -635,18 +636,19 @@ static void usage(int error) printf("cyclicdeadline V %1.2f\n", VERSION); printf("Usage:\n" "cyclicdeadline \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); From patchwork Wed Oct 7 08:56:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 268383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41227C47420 for ; Wed, 7 Oct 2020 08:57:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7A1F2083B for ; Wed, 7 Oct 2020 08:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728024AbgJGI5C (ORCPT ); Wed, 7 Oct 2020 04:57:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:57636 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727977AbgJGI5B (ORCPT ); Wed, 7 Oct 2020 04:57:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D87FFB168; Wed, 7 Oct 2020 08:56:59 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 08/18] pip_stress: Add command line parser Date: Wed, 7 Oct 2020 10:56:43 +0200 Message-Id: <20201007085653.11961-9-dwagner@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007085653.11961-1-dwagner@suse.de> References: <20201007085653.11961-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Add a default command line parser to print at least the current version. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- 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 \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()) From patchwork Wed Oct 7 08:56:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 268382 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9974C4363C for ; Wed, 7 Oct 2020 08:57:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91EA92080A for ; Wed, 7 Oct 2020 08:57:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728036AbgJGI5D (ORCPT ); Wed, 7 Oct 2020 04:57:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:57654 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbgJGI5C (ORCPT ); Wed, 7 Oct 2020 04:57:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 44284B174; Wed, 7 Oct 2020 08:57:00 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 09/18] pi_stress: Streamline usage output and man page Date: Wed, 7 Oct 2020 10:56:44 +0200 Message-Id: <20201007085653.11961-10-dwagner@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007085653.11961-1-dwagner@suse.de> References: <20201007085653.11961-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Signed-off-by: Daniel Wagner --- 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=,policy=deadline,runtime=,deadline=,period= -.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 \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=\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=\t\t- SCHED_FIFO or SCHED_RR\n"); - printf("\t\t,policy=deadline,runtime=,deadline=,period=\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 \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; } } From patchwork Wed Oct 7 08:56:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 268377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A223C4727E for ; Wed, 7 Oct 2020 08:57:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF86C20870 for ; Wed, 7 Oct 2020 08:57:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728052AbgJGI5I (ORCPT ); Wed, 7 Oct 2020 04:57:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:57620 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728011AbgJGI5C (ORCPT ); Wed, 7 Oct 2020 04:57:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 9D0A9B176; Wed, 7 Oct 2020 08:57:00 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 10/18] pmqtest: Streamline usage output and man page Date: Wed, 7 Oct 2020 10:56:45 +0200 Message-Id: <20201007085653.11961-11-dwagner@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007085653.11961-1-dwagner@suse.de> References: <20201007085653.11961-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Signed-off-by: Daniel Wagner Signed-off-by: John Kacur Signed-off-by: John Kacur --- 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 "); - 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 \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); } From patchwork Wed Oct 7 08:56:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 268378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D512C47420 for ; Wed, 7 Oct 2020 08:57:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2654020B1F for ; Wed, 7 Oct 2020 08:57:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728051AbgJGI5I (ORCPT ); Wed, 7 Oct 2020 04:57:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:57608 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728020AbgJGI5C (ORCPT ); Wed, 7 Oct 2020 04:57:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 66160B17D; Wed, 7 Oct 2020 08:57:01 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 12/18] queuelat: Streamline usage and man page Date: Wed, 7 Oct 2020 10:56:47 +0200 Message-Id: <20201007085653.11961-13-dwagner@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007085653.11961-1-dwagner@suse.de> References: <20201007085653.11961-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- 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 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 #include #include +#include #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 \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); From patchwork Wed Oct 7 08:56:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 268380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33886C41604 for ; Wed, 7 Oct 2020 08:57:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAF1620870 for ; Wed, 7 Oct 2020 08:57:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728041AbgJGI5E (ORCPT ); Wed, 7 Oct 2020 04:57:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:57728 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728025AbgJGI5D (ORCPT ); Wed, 7 Oct 2020 04:57:03 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 338E7B17A; Wed, 7 Oct 2020 08:57:02 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 14/18] signaltest: Streamline usage and man page Date: Wed, 7 Oct 2020 10:56:49 +0200 Message-Id: <20201007085653.11961-15-dwagner@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007085653.11961-1-dwagner@suse.de> References: <20201007085653.11961-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- 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 . .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 \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) From patchwork Wed Oct 7 08:56:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 268379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73E43C4727F for ; Wed, 7 Oct 2020 08:57:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2972420870 for ; Wed, 7 Oct 2020 08:57:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728042AbgJGI5F (ORCPT ); Wed, 7 Oct 2020 04:57:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:57594 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728028AbgJGI5E (ORCPT ); Wed, 7 Oct 2020 04:57:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 94AD1B28E; Wed, 7 Oct 2020 08:57:02 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 15/18] sigwaittest: Streamline usage and man page Date: Wed, 7 Oct 2020 10:56:50 +0200 Message-Id: <20201007085653.11961-16-dwagner@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007085653.11961-1-dwagner@suse.de> References: <20201007085653.11961-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- 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 "); - 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 \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); } From patchwork Wed Oct 7 08:56:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 268381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1FB6C4727E for ; Wed, 7 Oct 2020 08:57:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77E762083B for ; Wed, 7 Oct 2020 08:57:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728045AbgJGI5F (ORCPT ); Wed, 7 Oct 2020 04:57:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:57608 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728033AbgJGI5E (ORCPT ); Wed, 7 Oct 2020 04:57:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 58B3FB299; Wed, 7 Oct 2020 08:57:03 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 17/18] svsematest: Streamline usage and man page Date: Wed, 7 Oct 2020 10:56:52 +0200 Message-Id: <20201007085653.11961-18-dwagner@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201007085653.11961-1-dwagner@suse.de> References: <20201007085653.11961-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- 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 "); - 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 \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); }