From patchwork Wed Nov 18 19:06:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 327746 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 9C1B9C6379F for ; Wed, 18 Nov 2020 19:07:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10F832220B for ; Wed, 18 Nov 2020 19:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727158AbgKRTGs (ORCPT ); Wed, 18 Nov 2020 14:06:48 -0500 Received: from mx2.suse.de ([195.135.220.15]:49976 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727123AbgKRTGs (ORCPT ); Wed, 18 Nov 2020 14:06:48 -0500 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 58793BB14; Wed, 18 Nov 2020 19:06:47 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 01/12] cyclicdeadline: Remove dead code Date: Wed, 18 Nov 2020 20:06:31 +0100 Message-Id: <20201118190642.16006-2-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org my_sprintf() is not used, remove it. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- compare.py | 12 ++++++++++++ src/sched_deadline/cyclicdeadline.c | 13 ------------- 2 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 compare.py diff --git a/compare.py b/compare.py new file mode 100644 index 000000000000..7fb6ae818a00 --- /dev/null +++ b/compare.py @@ -0,0 +1,12 @@ +with open('old', 'r') as old: + with open('new', 'r') as new: + for ol in old.readlines(): + new.seek(0) + for nl in new.readlines(): + o = ol.split() + n = nl.split() + + if o[8] == n[8]: + d = int(n[4]) - int(o[4]) + p = d/int(o[4]) * 100 + print('{:20} {:>8} {:>8} {:>6} {:>2.2}%'.format(o[8], o[4], n[4], d, p)) diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index a6309ded3c52..e0db9669f676 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -215,19 +215,6 @@ static int my_vsprintf(char *buf, int size, const char *fmt, va_list ap) return s - buf; } -#if 0 -static int my_sprintf(char *buf, int size, const char *fmt, ...) -{ - va_list ap; - int n; - - va_start(ap, fmt); - n = vsnprintf(buf, size, fmt, ap); - va_end(ap); - return n; -} -#endif - static void ftrace_write(char *buf, const char *fmt, ...) { va_list ap; From patchwork Wed Nov 18 19:06:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 327743 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 94D51C63798 for ; Wed, 18 Nov 2020 19:07:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BF7521D1A for ; Wed, 18 Nov 2020 19:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727186AbgKRTGu (ORCPT ); Wed, 18 Nov 2020 14:06:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:49998 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727139AbgKRTGt (ORCPT ); Wed, 18 Nov 2020 14:06:49 -0500 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 A7CBEBB12; Wed, 18 Nov 2020 19:06:47 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 02/12] cyclicdeadline: Use common error handlers Date: Wed, 18 Nov 2020 20:06:32 +0100 Message-Id: <20201118190642.16006-3-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Use the common error handlers. This will make the fatal, error and debug output consistent with the output from cyclictest. The current normal output is not changed. While at it drop the 'fail' flag and use 'shutdown' flag which does the same thing. Signed-off-by: Daniel Wagner --- src/sched_deadline/cyclicdeadline.c | 165 ++++++++++------------------ 1 file changed, 59 insertions(+), 106 deletions(-) diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index e0db9669f676..7adc91465f44 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -32,6 +32,7 @@ #include #include +#include #define _STR(x) #x #define STR(x) _STR(x) @@ -165,10 +166,8 @@ static int my_vsprintf(char *buf, int size, const char *fmt, va_list ap) p++; switch (*p) { case 's': - if (l) { - fprintf(stderr, "Illegal print format l used with %%s\n"); - exit(-1); - } + if (l) + fatal("Illegal print format l used with %%s\n"); str = va_arg(ap, char *); l = strlen(str); strncpy(s, str, end - s); @@ -184,10 +183,9 @@ static int my_vsprintf(char *buf, int size, const char *fmt, va_list ap) } if (l == 2) lng = va_arg(ap, long long); - else if (l > 2) { - fprintf(stderr, "Illegal print format l=%d\n", l); - exit(-1); - } else + else if (l > 2) + fatal("Illegal print format l=%d\n", l); + else lng = va_arg(ap, int); i = 0; while (lng > 0) { @@ -204,8 +202,7 @@ static int my_vsprintf(char *buf, int size, const char *fmt, va_list ap) } break; default: - fprintf(stderr, "Illegal print format '%c'\n", *p); - exit(-1); + fatal("Illegal print format '%c'\n", *p); } continue; } @@ -397,8 +394,8 @@ enum { CPUSET_FL_CLONE_CHILDREN = (1 << 6), }; -static const char *make_cpuset(const char *name, const char *cpus, - const char *mems, unsigned flags, ...) +static void make_cpuset(const char *name, const char *cpus, + const char *mems, unsigned flags, ...) { struct stat st; char path[MAXPATH]; @@ -413,64 +410,64 @@ static const char *make_cpuset(const char *name, const char *cpus, ret = mount_cpuset(); if (ret < 0) - return "mount_cpuset"; + fatal("mount_cpuset"); ret = stat(path, &st); if (ret < 0) { ret = mkdir(path, 0755); if (ret < 0) - return "mkdir"; + fatal("mkdir"); } fd = open_cpuset(path, "cpuset.cpus"); if (fd < 0) - return "cset"; + fatal("cset"); ret = write(fd, cpus, strlen(cpus)); close(fd); if (ret < 0) - return "write cpus"; + fatal("write cpus"); if (mems) { fd = open_cpuset(path, "cpuset.mems"); if (fd < 0) - return "open mems"; + fatal("open mems"); ret = write(fd, mems, strlen(mems)); close(fd); if (ret < 0) - return "write mems"; + fatal("write mems"); } if (flags & CPUSET_FL_CPU_EXCLUSIVE) { fd = open_cpuset(path, "cpuset.cpu_exclusive"); if (fd < 0) - return "open cpu_exclusive"; + fatal("open cpu_exclusive"); ret = write(fd, "1", 2); close(fd); if (ret < 0) - return "write cpu_exclusive"; + fatal("write cpu_exclusive"); } if (flags & (CPUSET_FL_CLEAR_LOADBALANCE | CPUSET_FL_SET_LOADBALANCE)) { fd = open_cpuset(path, "cpuset.sched_load_balance"); if (fd < 0) - return "open sched_load_balance"; + fatal("open sched_load_balance"); if (flags & CPUSET_FL_SET_LOADBALANCE) ret = write(fd, "1", 2); else ret = write(fd, "0", 2); close(fd); if (ret < 0) - return "write sched_load_balance"; + fatal("write sched_load_balance"); } if (flags & CPUSET_FL_CLONE_CHILDREN) { fd = open_cpuset(path, "cgroup.clone_children"); if (fd < 0) - return "open clone_children"; + fatal("open clone_children"); ret = write(fd, "1", 2); close(fd); if (ret < 0) - return "write clone_children"; + fatal("write clone_children"); } @@ -482,7 +479,7 @@ static const char *make_cpuset(const char *name, const char *cpus, fd = open_cpuset(path, "tasks"); if (fd < 0) - return "open tasks"; + fatal("open tasks"); ret = 0; pids = va_arg(ap, int *); @@ -492,10 +489,8 @@ static const char *make_cpuset(const char *name, const char *cpus, } va_end(ap); close(fd); - if (ret < 0) { - fprintf(stderr, "Failed on task %d\n", pids[i]); - return "write tasks"; - } + if (ret < 0) + fatal("Failed on task %d\n", pids[i]); } if (flags & CPUSET_FL_ALL_TASKS) { @@ -507,7 +502,7 @@ static const char *make_cpuset(const char *name, const char *cpus, snprintf(path, MAXPATH - 1, "%s/tasks", CPUSET_PATH); if ((fp = fopen(path, "r")) == NULL) { close(fd); - return "opening cpuset tasks"; + fatal("opening cpuset tasks"); } while (fscanf(fp, "%d", &pid) == 1) { @@ -521,14 +516,12 @@ static const char *make_cpuset(const char *name, const char *cpus, if (ret < 0 && errno == ENOSPC) { fclose(fp); close(fd); - return "Can not move tasks"; + fatal("Can not move tasks"); } } fclose(fp); close(fd); } - - return NULL; } static void destroy_cpuset(const char *name, int print) @@ -580,16 +573,14 @@ static void destroy_cpuset(const char *name, int print) snprintf(path, MAXPATH - 1, "%s/%s", CPUSET_PATH, name); path[MAXPATH - 1] = 0; -// return; sleep(1); ret = rmdir(path); if (ret < 0) { if (retry++ < 5) goto again; - fprintf(stderr, "Failed to remove %s\n", path); - perror("rmdir"); + err_msg_n(errno, "Failed to remove %s\n", path); if (retry++ < 5) { - fprintf(stderr, "Trying again\n"); + err_msg("Trying again\n"); goto again; } } @@ -640,8 +631,6 @@ static void usage(int error) exit(error); } -static int fail; - static u64 get_time_us(void) { struct timespec ts; @@ -740,9 +729,8 @@ void *run_deadline(void *data) ret = sched_getattr(0, &attr, sizeof(attr), 0); if (ret < 0) { - fprintf(stderr, "[%ld]", tid); - perror("sched_getattr"); - fail = 1; + err_msg_n(errno, "[%ld]", tid); + shutdown = 1; pthread_barrier_wait(&barrier); pthread_exit("Failed sched_getattr"); return NULL; @@ -750,23 +738,19 @@ void *run_deadline(void *data) pthread_barrier_wait(&barrier); - if (fail) - return NULL; - attr.sched_policy = SCHED_DEADLINE; attr.sched_runtime = sd->runtime_us * 1000; attr.sched_deadline = sd->deadline_us * 1000; printf("thread[%d] runtime=%lldus deadline=%lldus\n", - gettid(), sd->runtime_us, sd->deadline_us); + gettid(), sd->runtime_us, sd->deadline_us); pthread_barrier_wait(&barrier); ret = sched_setattr(0, &attr, 0); if (ret < 0) { - fprintf(stderr, "[%ld]", tid); - perror("sched_setattr"); - fail = 1; + err_msg_n(errno, "[%ld]", tid); + shutdown = 1; pthread_barrier_wait(&barrier); pthread_exit("Failed sched_setattr"); return NULL; @@ -774,9 +758,6 @@ void *run_deadline(void *data) pthread_barrier_wait(&barrier); - if (fail) - return NULL; - sched_yield(); period = get_time_us(); @@ -786,7 +767,7 @@ void *run_deadline(void *data) } ret = sched_getattr(0, &attr, sizeof(attr), 0); if (ret < 0) { - perror("sched_getattr"); + err_msg_n(errno, "sched_getattr"); pthread_exit("Failed second sched_getattr"); } @@ -1015,10 +996,8 @@ int main(int argc, char **argv) int c; cpu_count = sysconf(_SC_NPROCESSORS_CONF); - if (cpu_count < 1) { - fprintf(stderr, "Can not calculate number of CPUS\n"); - exit(-1); - } + if (cpu_count < 1) + err_quit("Can not calculate number of CPUS\n"); for (;;) { static struct option options[] = { @@ -1069,10 +1048,8 @@ int main(int argc, char **argv) if (setcpu) { nr_cpus = calc_nr_cpus(setcpu, &setcpu_buf); - if (nr_cpus < 0 || nr_cpus > cpu_count) { - fprintf(stderr, "Invalid cpu input '%s'\n", setcpu); - exit(-1); - } + if (nr_cpus < 0 || nr_cpus > cpu_count) + fatal("Invalid cpu input '%s'\n", setcpu); } else nr_cpus = cpu_count; @@ -1084,10 +1061,8 @@ int main(int argc, char **argv) /* Default cpu to use is the last one */ if (!all_cpus && !setcpu) { setcpu_buf = malloc(10); - if (!setcpu_buf) { - perror("malloc"); - exit(-1); - } + if (!setcpu_buf) + fatal("malloc"); sprintf(setcpu_buf, "%d", cpu_count - 1); } @@ -1097,16 +1072,14 @@ int main(int argc, char **argv) make_other_cpu_list(setcpu, &allcpu_buf); if (mlockall(MCL_CURRENT|MCL_FUTURE) == -1) - perror("mlockall"); + warn("mlockall"); setup_ftrace_marker(); thread = calloc(nr_threads, sizeof(*thread)); sched_data = calloc(nr_threads, sizeof(*sched_data)); - if (!thread || !sched_data) { - perror("allocating threads"); - exit(-1); - } + if (!thread || !sched_data) + fatal("allocating threads"); if (nr_threads > nr_cpus) { /* @@ -1130,11 +1103,9 @@ int main(int argc, char **argv) * If the runtime is less than 2ms, then we better * have HRTICK enabled. */ - if (!setup_hr_tick()) { - fprintf(stderr, "For less than 2ms run times, you need to\n" - "have HRTICK enabled in debugfs/sched_features\n"); - exit(-1); - } + if (!setup_hr_tick()) + fatal("For less than 2ms run times, you need to\n" + "have HRTICK enabled in debugfs/sched_features\n"); } sd->runtime_us = runtime; sd->deadline_us = interval; @@ -1145,11 +1116,9 @@ int main(int argc, char **argv) start_period = get_time_us(); do_runtime(gettid(), sd, start_period); end_period = get_time_us(); - if (end_period - start_period > sd->runtime_us) { - fprintf(stderr, "Failed to perform task within runtime: Missed by %lld us\n", - end_period - start_period - sd->runtime_us); - exit(-1); - } + if (end_period - start_period > sd->runtime_us) + fatal("Failed to perform task within runtime: Missed by %lld us\n", + end_period - start_period - sd->runtime_us); printf(" Tested at %lldus of %lldus\n", end_period - start_period, sd->runtime_us); @@ -1169,42 +1138,29 @@ int main(int argc, char **argv) pthread_barrier_wait(&barrier); - if (fail) { - printf("fail 1\n"); - exit(-1); - } + if (shutdown) + fatal("failed to setup child threads at step 1\n"); if (!all_cpus) { int *pids; - res = make_cpuset(CPUSET_ALL, allcpu_buf, "0", + make_cpuset(CPUSET_ALL, allcpu_buf, "0", CPUSET_FL_SET_LOADBALANCE | CPUSET_FL_CLONE_CHILDREN | CPUSET_FL_ALL_TASKS); - if (res) { - perror(res); - exit(-1); - } pids = calloc(nr_threads + 1, sizeof(int)); - if (!pids) { - perror("Allocating pids"); - exit(-1); - } + if (!pids) + fatal("Allocating pids"); for (i = 0; i < nr_threads; i++) pids[i] = sched_data[i].stat.tid; - res = make_cpuset(CPUSET_LOCAL, setcpu, "0", + make_cpuset(CPUSET_LOCAL, setcpu, "0", CPUSET_FL_CPU_EXCLUSIVE | CPUSET_FL_SET_LOADBALANCE | CPUSET_FL_CLONE_CHILDREN | CPUSET_FL_TASKS, pids); - free(pids); - if (res) { - perror(res); - exit(-1); - } system("cat /sys/fs/cgroup/cpuset/my_cpuset/tasks"); } @@ -1213,10 +1169,8 @@ int main(int argc, char **argv) pthread_barrier_wait(&barrier); - if (fail) { - printf("fail 2\n"); - exit(-1); - } + if (shutdown) + fatal("failed to setup child threads at step 2"); pthread_barrier_wait(&barrier); @@ -1227,8 +1181,7 @@ int main(int argc, char **argv) if (duration) alarm(duration); - if (!fail) - loop(sched_data, nr_threads); + loop(sched_data, nr_threads); for (i = 0; i < nr_threads; i++) { @@ -1236,7 +1189,7 @@ int main(int argc, char **argv) res = join_thread(&thread[i]); if (res) { - printf("Thread %d failed: %s\n", i, res); + warn("Thread %d failed: %s\n", i, res); continue; } } From patchwork Wed Nov 18 19:06:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 328839 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 79BCFC56201 for ; Wed, 18 Nov 2020 19:07:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3341520B1F for ; Wed, 18 Nov 2020 19:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727175AbgKRTGu (ORCPT ); Wed, 18 Nov 2020 14:06:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:50036 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727147AbgKRTGt (ORCPT ); Wed, 18 Nov 2020 14:06:49 -0500 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 F4017BB1A; Wed, 18 Nov 2020 19:06:47 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 03/12] cyclicdeadline: Add quiet command line option Date: Wed, 18 Nov 2020 20:06:33 +0100 Message-Id: <20201118190642.16006-4-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The quiet option is useful for automated test setups where only the final result of the run is interesting. This avoids to fill up the logs. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/sched_deadline/cyclicdeadline.8 | 6 +++++- src/sched_deadline/cyclicdeadline.c | 22 +++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/sched_deadline/cyclicdeadline.8 b/src/sched_deadline/cyclicdeadline.8 index def42f77044a..59b60ca7bd31 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 "[-a [CPUSET]] [-D TIME] [-h] [-i INTV] [-s STEP] [-t NUM]" +.RI "[-a [CPUSET]] [-D TIME] [-h] [-i INTV] [-s STEP] [-t NUM] [-q]" .PP .SH DESCRIPTION .B cyclicdeadline @@ -43,6 +43,10 @@ The amount to increase the deadline for each task in us. (default 500us) .TP .B \-t \-\-threads NUM The number of threads to run as deadline (default 1) +.TP +.B \-q, \-\-quiet +Print a summary only on exit. Useful for automated tests, where only +the summary output needs to be captured. .br .SH AUTHOR cyclicdeadline was written by Steven Rostedt diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index 7adc91465f44..40b514c5e7e0 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -108,6 +108,8 @@ static int use_nsecs; static int mark_fd; +static int quiet; + static int find_mount(const char *mount, char *debugfs) { char type[100]; @@ -627,6 +629,7 @@ static void usage(int error) "-s STEP --step The amount to increase the deadline for each task in us\n" " (default 500us).\n" "-t NUM --threads The number of threads to run as deadline (default 1).\n" + "-q --quiet print a summary only on exit\n" ); exit(error); } @@ -966,13 +969,18 @@ static void loop(struct sched_data *sched_data, int nr_threads) while (!shutdown) { for (i = 0; i < nr_threads; i++) - print_stat(stdout, &sched_data[i], i, 0, 0); + print_stat(stdout, &sched_data[i], i, 0, quiet); usleep(10000); - printf("\033[%dA", nr_threads); + if (!quiet) + printf("\033[%dA", nr_threads); } usleep(10000); - for (i = 0; i < nr_threads; i++) - printf("\n"); + if (!quiet) { + printf("\033[%dB", nr_threads + 2); + } else { + for (i = 0; i < nr_threads; ++i) + print_stat(stdout, &sched_data[i], i, 0, 0); + } } int main(int argc, char **argv) @@ -1006,9 +1014,10 @@ int main(int argc, char **argv) { "help", no_argument, NULL, 'h' }, { "interval", required_argument, NULL, 'i' }, { "threads", required_argument, NULL, 't' }, + { "quiet", no_argument, NULL, 'q' }, { NULL, 0, NULL, 0 }, }; - c = getopt_long(argc, argv, "a::c:D:hi:t:", options, NULL); + c = getopt_long(argc, argv, "a::c:D:hi:t:q", options, NULL); if (c == -1) break; switch (c) { @@ -1035,6 +1044,9 @@ int main(int argc, char **argv) case 'D': duration = parse_time_string(optarg); break; + case 'q': + quiet = 1; + break; case 'h': usage(0); break; From patchwork Wed Nov 18 19:06:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 328834 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 8F236C64E8A for ; Wed, 18 Nov 2020 19:07:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A3FD21D1A for ; Wed, 18 Nov 2020 19:07:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727206AbgKRTGx (ORCPT ); Wed, 18 Nov 2020 14:06:53 -0500 Received: from mx2.suse.de ([195.135.220.15]:50062 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727123AbgKRTGu (ORCPT ); Wed, 18 Nov 2020 14:06:50 -0500 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 48EB8BB1D; Wed, 18 Nov 2020 19:06:48 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 04/12] pmqtest: Move statictic output into print_stat() Date: Wed, 18 Nov 2020 20:06:34 +0100 Message-Id: <20201118190642.16006-5-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Prepare the code to introduce the quiet command line option by moving the statistic output code into print_stat(). We follow here the pattern from cyclictest. While at it replace the rather sophisticated error printing code with a fatal(). Just fail if something is not working. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/pmqtest/pmqtest.c | 64 ++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c index a1e487b85d2c..b0a2cbede4a0 100644 --- a/src/pmqtest/pmqtest.c +++ b/src/pmqtest/pmqtest.c @@ -64,7 +64,6 @@ struct params { char recvsyncmsg[MSG_SIZE]; char recvtestmsg[MSG_SIZE]; struct params *neighbor; - char error[MAX_PATH * 2]; }; void *pmqthread(void *param) @@ -192,9 +191,7 @@ void *pmqthread(void *param) write(tracing_enabled, "0", 1); close(tracing_enabled); } else - snprintf(par->error, sizeof(par->error), - "Could not access %s\n", - tracing_enabled_file); + fatal("Could not access %s\n", tracing_enabled_file); par->shutdown = 1; par->neighbor->shutdown = 1; } @@ -376,6 +373,27 @@ static void sighand(int sig) shutdown = 1; } +static void print_stat(FILE *fp, struct params *receiver, struct params *sender, + int verbose, int quiet) +{ + int i; + + for (i = 0; i < num_threads; i++) { + printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: ID%d, P%d, CPU%d, TO %d, Cycles %d\n", + i*2, receiver[i].tid, receiver[i].priority, receiver[i].cpu, + receiver[i].delay.tv_nsec / 1000, + i*2+1, sender[i].tid, sender[i].priority, sender[i].cpu, + receiver[i].timeoutcount, sender[i].samples); + } + for (i = 0; i < num_threads; i++) { + printf("#%d -> #%d, Min %4d, Cur %4d, Avg %4d, Max %4d\n", + i*2+1, i*2, + receiver[i].mindiff, (int) receiver[i].diff.tv_usec, + (int) ((receiver[i].sumdiff / receiver[i].samples) + 0.5), + receiver[i].maxdiff); + } +} + int main(int argc, char *argv[]) { int i; @@ -385,8 +403,6 @@ int main(int argc, char *argv[]) sigset_t sigset; int oldsamples = INT_MAX; int oldtimeoutcount = INT_MAX; - int first = 1; - int errorlines = 0; struct timespec maindelay; int oflag = O_CREAT|O_RDWR; struct mq_attr mqstat; @@ -489,38 +505,8 @@ int main(int argc, char *argv[]) if (minsamples > 1 && (shutdown || newsamples > oldsamples || newtimeoutcount > oldtimeoutcount)) { - - if (!first) - printf("\033[%dA", num_threads*2 + errorlines); - first = 0; - - for (i = 0; i < num_threads; i++) { - printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: ID%d, P%d, CPU%d, TO %d, Cycles %d \n", - i*2, receiver[i].tid, receiver[i].priority, receiver[i].cpu, - receiver[i].delay.tv_nsec / 1000, - i*2+1, sender[i].tid, sender[i].priority, sender[i].cpu, - receiver[i].timeoutcount, sender[i].samples); - } - for (i = 0; i < num_threads; i++) { - printf("#%d -> #%d, Min %4d, Cur %4d, Avg %4d, Max %4d\n", - i*2+1, i*2, - receiver[i].mindiff, (int) receiver[i].diff.tv_usec, - (int) ((receiver[i].sumdiff / receiver[i].samples) + 0.5), - receiver[i].maxdiff); - if (receiver[i].error[0] != '\0') { - printf("%s", receiver[i].error); - errorlines++; - receiver[i].error[0] = '\0'; - } - if (sender[i].error[0] != '\0') { - printf("%s", sender[i].error); - errorlines++; - receiver[i].error[0] = '\0'; - } - } - } else { - if (minsamples < 1) - printf("Collecting ...\n\033[1A"); + print_stat(stdout, receiver, sender, 0, 0); + printf("\033[%dA", num_threads*2); } fflush(NULL); @@ -539,6 +525,8 @@ int main(int argc, char *argv[]) } while (!shutdown); + printf("\033[%dB", num_threads*2 + 2); + for (i = 0; i < num_threads; i++) { receiver[i].shutdown = 1; sender[i].shutdown = 1; From patchwork Wed Nov 18 19:06:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 327741 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 5D4EEC64E90 for ; Wed, 18 Nov 2020 19:07:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D2E122228 for ; Wed, 18 Nov 2020 19:07:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727182AbgKRTGu (ORCPT ); Wed, 18 Nov 2020 14:06:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:50086 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727159AbgKRTGt (ORCPT ); Wed, 18 Nov 2020 14:06:49 -0500 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 8AE3EBB1C; Wed, 18 Nov 2020 19:06:48 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 05/12] pmqtest: Add quiet command line option Date: Wed, 18 Nov 2020 20:06:35 +0100 Message-Id: <20201118190642.16006-6-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The quiet option is useful for automated test setups where only the final result of the run is interesting. This avoids to fill up the logs. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/pmqtest/pmqtest.8 | 5 ++++- src/pmqtest/pmqtest.c | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/pmqtest/pmqtest.8 b/src/pmqtest/pmqtest.8 index e44411ce0ef3..36678d0c5026 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] [-D TIME] [-f TO] [-h] [-i INTV] [-l LOOPS] [-p PRIO] [-S] [-t|-t NUM] +pmqtest [-a|-a PROC] [-b USEC] [-d DIST] [-D TIME] [-f TO] [-h] [-i INTV] [-l LOOPS] [-p PRIO] [-q] [-S] [-t|-t NUM] .br .SH "DESCRIPTION" .LP @@ -41,6 +41,9 @@ Set the number of loops. The default is 0 (endless). This option is useful for a .B \-p, \-\-prio=PRIO Set the priority of the process. .TP +.B \-q, \-\-quiet +Print a summary only on exit. Useful for automated tests, where only the summary output needs to be captured. +.TP .B \-S, \-\-smp Test mode for symmetric multi-processing, implies -a and -t and uses the same priority on all threads. .TP diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c index b0a2cbede4a0..5f7a24d55db6 100644 --- a/src/pmqtest/pmqtest.c +++ b/src/pmqtest/pmqtest.c @@ -232,6 +232,7 @@ static void display_help(int error) "-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" + "-q --quiet print a summary only on exit\n" "-S --smp SMP testing: options -a -t and same priority\n" " of all threads\n" "-t --threads one thread per available processor\n" @@ -256,6 +257,7 @@ static int smp; static int sameprio; static int timeout; static int forcetimeout; +static int quiet; static void process_options(int argc, char *argv[]) { @@ -275,12 +277,13 @@ static void process_options(int argc, char *argv[]) {"interval", required_argument, NULL, 'i'}, {"loops", required_argument, NULL, 'l'}, {"priority", required_argument, NULL, 'p'}, + {"quiet", no_argument, NULL, 'q'}, {"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:D:f:i:l:p:St::T:", + int c = getopt_long (argc, argv, "a::b:d:D:f:i:l:p:qSt::T:", long_options, &option_index); if (c == -1) break; @@ -309,6 +312,7 @@ static void process_options(int argc, char *argv[]) case 'i': interval = atoi(optarg); break; case 'l': max_cycles = atoi(optarg); break; case 'p': priority = atoi(optarg); break; + case 'q': quiet = 1; break; case 'S': smp = 1; num_threads = max_cpus; @@ -378,6 +382,9 @@ static void print_stat(FILE *fp, struct params *receiver, struct params *sender, { int i; + if (quiet) + return; + for (i = 0; i < num_threads; i++) { printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: ID%d, P%d, CPU%d, TO %d, Cycles %d\n", i*2, receiver[i].tid, receiver[i].priority, receiver[i].cpu, @@ -505,8 +512,9 @@ int main(int argc, char *argv[]) if (minsamples > 1 && (shutdown || newsamples > oldsamples || newtimeoutcount > oldtimeoutcount)) { - print_stat(stdout, receiver, sender, 0, 0); - printf("\033[%dA", num_threads*2); + print_stat(stdout, receiver, sender, 0, quiet); + if (!quiet) + printf("\033[%dA", num_threads*2); } fflush(NULL); @@ -525,7 +533,10 @@ int main(int argc, char *argv[]) } while (!shutdown); - printf("\033[%dB", num_threads*2 + 2); + if (!quiet) + printf("\033[%dB", num_threads*2 + 2); + else + print_stat(stdout, receiver, sender, 0, 0); for (i = 0; i < num_threads; i++) { receiver[i].shutdown = 1; From patchwork Wed Nov 18 19:06:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 328836 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 1F91DC64E7D for ; Wed, 18 Nov 2020 19:07:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E62242225B for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727193AbgKRTGu (ORCPT ); Wed, 18 Nov 2020 14:06:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:50118 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727167AbgKRTGu (ORCPT ); Wed, 18 Nov 2020 14:06:50 -0500 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 D589CBB1E; Wed, 18 Nov 2020 19:06:48 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 06/12] ptsematest: Move statictic output into print_stat() Date: Wed, 18 Nov 2020 20:06:36 +0100 Message-Id: <20201118190642.16006-7-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Prepare the code to introduce the quiet command line option by moving the statistic output code into print_stat(). We follow here the pattern from cyclictest. While at it replace the rather sophisticated error printing code with a fatal(). Just fail if something is not working. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/ptsematest/ptsematest.c | 65 ++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c index 9cd5f34509a8..69b4e1221361 100644 --- a/src/ptsematest/ptsematest.c +++ b/src/ptsematest/ptsematest.c @@ -52,7 +52,6 @@ struct params { struct timeval unblocked, received, diff; pthread_t threadid; struct params *neighbor; - char error[MAX_PATH * 2]; }; void *semathread(void *param) @@ -121,9 +120,8 @@ void *semathread(void *param) write(tracing_enabled, "0", 1); close(tracing_enabled); } else - snprintf(par->error, sizeof(par->error), - "Could not access %s\n", - tracing_enabled_file); + fatal("Could not access %s\n", + tracing_enabled_file); par->shutdown = 1; par->neighbor->shutdown = 1; } @@ -290,6 +288,28 @@ static void sighand(int sig) shutdown = 1; } +static void print_stat(FILE *fp, struct params *receiver, struct params *sender, + int verbose, int quiet) +{ + int i; + + for (i = 0; i < num_threads; i++) { + printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: ID%d, P%d, CPU%d, Cycles %d\n", + i*2, receiver[i].tid, receiver[i].priority, receiver[i].cpu, + receiver[i].delay.tv_nsec / 1000, + i*2+1, sender[i].tid, sender[i].priority, sender[i].cpu, + sender[i].samples); + } + for (i = 0; i < num_threads; i++) { + printf("#%d -> #%d, Min %4d, Cur %4d, Avg %4d, Max %4d\n", + i*2+1, i*2, + receiver[i].mindiff, (int) receiver[i].diff.tv_usec, + (int) ((receiver[i].sumdiff / receiver[i].samples) + 0.5), + receiver[i].maxdiff); + } +} + + int main(int argc, char *argv[]) { int i; @@ -367,40 +387,13 @@ int main(int argc, char *argv[]) maindelay.tv_nsec = 50000000; /* 50 ms */ while (!shutdown) { - int printed; - int errorlines = 0; - for (i = 0; i < num_threads; i++) shutdown |= receiver[i].shutdown | sender[i].shutdown; if (receiver[0].samples > oldsamples || shutdown) { - for (i = 0; i < num_threads; i++) { - printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: ID%d, P%d, CPU%d, Cycles %d\n", - i*2, receiver[i].tid, receiver[i].priority, receiver[i].cpu, - receiver[i].delay.tv_nsec / 1000, - i*2+1, sender[i].tid, sender[i].priority, sender[i].cpu, - sender[i].samples); - } - for (i = 0; i < num_threads; i++) { - printf("#%d -> #%d, Min %4d, Cur %4d, Avg %4d, Max %4d\n", - i*2+1, i*2, - receiver[i].mindiff, (int) receiver[i].diff.tv_usec, - (int) ((receiver[i].sumdiff / receiver[i].samples) + 0.5), - receiver[i].maxdiff); - if (receiver[i].error[0] != '\0') { - printf("%s", receiver[i].error); - errorlines++; - receiver[i].error[0] = '\0'; - } - if (sender[i].error[0] != '\0') { - printf("%s", sender[i].error); - errorlines++; - receiver[i].error[0] = '\0'; - } - } - printed = 1; - } else - printed = 0; + print_stat(stdout, receiver, sender, 0, 0); + printf("\033[%dA", num_threads*2); + } sigemptyset(&sigset); sigaddset(&sigset, SIGTERM); @@ -411,10 +404,8 @@ int main(int argc, char *argv[]) sigemptyset(&sigset); pthread_sigmask(SIG_SETMASK, &sigset, NULL); - - if (printed && !shutdown) - printf("\033[%dA", num_threads*2 + errorlines); } + printf("\033[%dB", num_threads*2 + 2); for (i = 0; i < num_threads; i++) { receiver[i].shutdown = 1; From patchwork Wed Nov 18 19:06:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 327745 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 EE8B9C6379D for ; Wed, 18 Nov 2020 19:07:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92CD522227 for ; Wed, 18 Nov 2020 19:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727195AbgKRTGv (ORCPT ); Wed, 18 Nov 2020 14:06:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:50144 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727171AbgKRTGu (ORCPT ); Wed, 18 Nov 2020 14:06:50 -0500 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 33990BB23; Wed, 18 Nov 2020 19:06:49 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 07/12] ptsematest: Add quiet command line option Date: Wed, 18 Nov 2020 20:06:37 +0100 Message-Id: <20201118190642.16006-8-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The quiet option is useful for automated test setups where only the final result of the run is interesting. This avoids to fill up the logs. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/ptsematest/ptsematest.8 | 5 ++++- src/ptsematest/ptsematest.c | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/ptsematest/ptsematest.8 b/src/ptsematest/ptsematest.8 index 05a0cdfd3657..a435e7a6221c 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] [-h|--help] [-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] [-q|--quiet] [-S|--smp] [-t|--threads [NUM]] .br .SH "DESCRIPTION" .LP @@ -38,6 +38,9 @@ Set the number of loops. The default is 0 (endless). This option is useful for a .B \-p, \-\-prio=PRIO Set the priority of the process. .TP +.B \-q, \-\-quiet +Print a summary only on exit. Useful for automated tests, where only the summary output needs to be captured. +.TP .B \-S, \-\-smp SMP testing: options -a -t and same priority .TP diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c index 69b4e1221361..2e392299fdc4 100644 --- a/src/ptsematest/ptsematest.c +++ b/src/ptsematest/ptsematest.c @@ -156,6 +156,7 @@ static void display_help(int error) "-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" + "-q --quiet print a summary only on exit\n" "-S --smp SMP testing: options -a -t and same priority\n" " of all threads\n" "-t --threads one thread per available processor\n" @@ -178,6 +179,7 @@ static int interval = 1000; static int distance = 500; static int smp; static int sameprio; +static int quiet; static void process_options(int argc, char *argv[]) { @@ -196,11 +198,12 @@ static void process_options(int argc, char *argv[]) {"interval", required_argument, NULL, 'i'}, {"loops", required_argument, NULL, 'l'}, {"priority", required_argument, NULL, 'p'}, + {"quiet", no_argument , NULL, 'q'}, {"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", + int c = getopt_long (argc, argv, "a::b:d:i:l:D:p:qSt::h", long_options, &option_index); if (c == -1) break; @@ -228,6 +231,7 @@ static void process_options(int argc, char *argv[]) case 'h': display_help(0); break; case 'l': max_cycles = atoi(optarg); break; case 'p': priority = atoi(optarg); break; + case 'q': quiet = 1; break; case 'S': smp = 1; num_threads = max_cpus; @@ -293,6 +297,9 @@ static void print_stat(FILE *fp, struct params *receiver, struct params *sender, { int i; + if (quiet) + return; + for (i = 0; i < num_threads; i++) { printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: ID%d, P%d, CPU%d, Cycles %d\n", i*2, receiver[i].tid, receiver[i].priority, receiver[i].cpu, @@ -391,8 +398,9 @@ int main(int argc, char *argv[]) shutdown |= receiver[i].shutdown | sender[i].shutdown; if (receiver[0].samples > oldsamples || shutdown) { - print_stat(stdout, receiver, sender, 0, 0); - printf("\033[%dA", num_threads*2); + print_stat(stdout, receiver, sender, 0, quiet); + if (!quiet) + printf("\033[%dA", num_threads*2); } sigemptyset(&sigset); @@ -405,7 +413,11 @@ int main(int argc, char *argv[]) sigemptyset(&sigset); pthread_sigmask(SIG_SETMASK, &sigset, NULL); } - printf("\033[%dB", num_threads*2 + 2); + + if (!quiet) + printf("\033[%dB", num_threads*2 + 2); + else + print_stat(stdout, receiver, sender, 0, 0); for (i = 0; i < num_threads; i++) { receiver[i].shutdown = 1; From patchwork Wed Nov 18 19:06: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: 328838 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 56488C64E69 for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05C7B20B1F for ; Wed, 18 Nov 2020 19:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727202AbgKRTGv (ORCPT ); Wed, 18 Nov 2020 14:06:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:50174 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727179AbgKRTGv (ORCPT ); Wed, 18 Nov 2020 14:06:51 -0500 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 7EA20BB27; Wed, 18 Nov 2020 19:06:49 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 08/12] svsematest: Move statictic output into print_stat() Date: Wed, 18 Nov 2020 20:06:38 +0100 Message-Id: <20201118190642.16006-9-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Prepare the code to introduce the quiet command line option by moving the statistic output code into print_stat(). We follow here the pattern from cyclictest. While at it replace the rather sophisticated error printing code with a fatal(). Just fail if something is not working. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/svsematest/svsematest.c | 101 ++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 56 deletions(-) diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c index 98efd930e63f..7de20dc65445 100644 --- a/src/svsematest/svsematest.c +++ b/src/svsematest/svsematest.c @@ -65,7 +65,6 @@ struct params { struct timeval unblocked, received, diff; pthread_t threadid; struct params *neighbor; - char error[MAX_PATH * 2]; }; static int mustfork; @@ -95,9 +94,8 @@ void *semathread(void *param) CPU_ZERO(&mask); CPU_SET(par->cpu, &mask); if (sched_setaffinity(0, sizeof(mask), &mask) == -1) - snprintf(par->error, sizeof(par->error), - "WARNING: Could not set CPU affinity " - "to CPU #%d\n", par->cpu); + fatal("Could not set CPU affinity " + "to CPU #%d\n", par->cpu); } else { int max_cpus = sysconf(_SC_NPROCESSORS_CONF); @@ -178,9 +176,8 @@ void *semathread(void *param) write(tracing_enabled, "0", 1); close(tracing_enabled); } else - snprintf(par->error, sizeof(par->error), - "Could not access %s\n", - tracing_enabled_file); + fatal("Could not access %s\n", + tracing_enabled_file); par->shutdown = 1; neighbor->shutdown = 1; } @@ -379,6 +376,42 @@ static void sighand(int sig) mustshutdown = 1; } +static void print_stat(FILE *fp, struct params *receiver, struct params *sender, + int verbose, int quiet) +{ + int i; + + for (i = 0; i < num_threads; i++) { + int receiver_pid, sender_pid; + + if (mustfork) { + receiver_pid = receiver[i].pid; + sender_pid = sender[i].pid; + } else { + receiver_pid = receiver[i].tid; + sender_pid = sender[i].tid; + } + printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: ID%d, P%d, CPU%d, Cycles %d\n", + i*2, receiver_pid, receiver[i].priority, + receiver[i].cpu, receiver[i].delay.tv_nsec / + 1000, i*2+1, sender_pid, sender[i].priority, + sender[i].cpu, sender[i].samples); + } + + for (i = 0; i < num_threads; i++) { + if (receiver[i].mindiff == -1) + printf("#%d -> #%d (not yet ready)\n", + i*2+1, i*2); + else + printf("#%d -> #%d, Min %4d, Cur %4d, Avg %4d, Max %4d\n", + i*2+1, i*2, receiver[i].mindiff, + (int) receiver[i].diff.tv_usec, + (int) ((receiver[i].sumdiff / + receiver[i].samples) + 0.5), + receiver[i].maxdiff); + } +} + int main(int argc, char *argv[]) { char *myfile; @@ -608,57 +641,14 @@ int main(int argc, char *argv[]) } while (!mustshutdown) { - int printed; - int errorlines = 0; - for (i = 0; i < num_threads; i++) mustshutdown |= receiver[i].shutdown | sender[i].shutdown; if (receiver[0].samples > oldsamples || mustshutdown) { - for (i = 0; i < num_threads; i++) { - int receiver_pid, sender_pid; - - if (mustfork) { - receiver_pid = receiver[i].pid; - sender_pid = sender[i].pid; - } else { - receiver_pid = receiver[i].tid; - sender_pid = sender[i].tid; - } - printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: " - "ID%d, P%d, CPU%d, Cycles %d\n", - i*2, receiver_pid, receiver[i].priority, - receiver[i].cpu, receiver[i].delay.tv_nsec / - 1000, i*2+1, sender_pid, sender[i].priority, - sender[i].cpu, sender[i].samples); - } - for (i = 0; i < num_threads; i++) { - if (receiver[i].mindiff == -1) - printf("#%d -> #%d (not yet ready)\n", - i*2+1, i*2); - else - printf("#%d -> #%d, Min %4d, Cur %4d, " - "Avg %4d, Max %4d\n", - i*2+1, i*2, receiver[i].mindiff, - (int) receiver[i].diff.tv_usec, - (int) ((receiver[i].sumdiff / - receiver[i].samples) + 0.5), - receiver[i].maxdiff); - if (receiver[i].error[0] != '\0') { - printf("%s", receiver[i].error); - receiver[i].error[0] = '\0'; - errorlines++; - } - if (sender[i].error[0] != '\0') { - printf("%s", sender[i].error); - sender[i].error[0] = '\0'; - errorlines++; - } - } - printed = 1; - } else - printed = 0; + print_stat(stdout, receiver, sender, 0, 0); + printf("\033[%dA", num_threads*2); + } sigemptyset(&sigset); sigaddset(&sigset, SIGTERM); @@ -670,11 +660,10 @@ int main(int argc, char *argv[]) sigemptyset(&sigset); pthread_sigmask(SIG_SETMASK, &sigset, NULL); - - if (printed && !mustshutdown) - printf("\033[%dA", num_threads*2 + errorlines); } + printf("\033[%dB", num_threads*2 + 2); + for (i = 0; i < num_threads; i++) { receiver[i].shutdown = 1; sender[i].shutdown = 1; From patchwork Wed Nov 18 19:06: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: 328837 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 BF2C5C64E7A for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E02322244 for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727196AbgKRTGv (ORCPT ); Wed, 18 Nov 2020 14:06:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:50086 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727147AbgKRTGv (ORCPT ); Wed, 18 Nov 2020 14:06:51 -0500 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 CB8C7BB06; Wed, 18 Nov 2020 19:06:49 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 09/12] svsematest: Add quiet command line option Date: Wed, 18 Nov 2020 20:06:39 +0100 Message-Id: <20201118190642.16006-10-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The quiet option is useful for automated test setups where only the final result of the run is interesting. This avoids to fill up the logs. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/svsematest/svsematest.8 | 5 ++++- src/svsematest/svsematest.c | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/svsematest/svsematest.8 b/src/svsematest/svsematest.8 index 5fcb96149bdd..828f9154e974 100644 --- a/src/svsematest/svsematest.8 +++ b/src/svsematest/svsematest.8 @@ -4,7 +4,7 @@ \fBsvsematest\fR \- Start two threads or fork two processes and measure the latency of SYSV semaphores .SH "SYNTAX" .LP -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]] +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] [-q|--quiet] [-S|--smp] [-t|--threads [NUM]] .br .SH "DESCRIPTION" .LP @@ -38,6 +38,9 @@ Set the number of loops. The default is 0 (endless). This option is useful for a .B \-p, \-\-prio=PRIO Set the priority of the process. .TP +.B \-q, \-\-quiet +Print a summary only on exit. Useful for automated tests, where only the summary output needs to be captured. +.TP .B \-S, \-\-smp SMP testing: options -a -t and same priority of all threads .TP diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c index 7de20dc65445..7388efb3f488 100644 --- a/src/svsematest/svsematest.c +++ b/src/svsematest/svsematest.c @@ -253,6 +253,7 @@ static int interval = 1000; static int distance = 500; static int smp; static int sameprio; +static int quiet; static void process_options(int argc, char *argv[]) { @@ -273,11 +274,12 @@ static void process_options(int argc, char *argv[]) {"interval", required_argument, NULL, 'i'}, {"loops", required_argument, NULL, 'l'}, {"priority", required_argument, NULL, 'p'}, + {"quiet", no_argument, NULL, 'q'}, {"smp", no_argument, NULL, 'S'}, {"threads", optional_argument, NULL, 't'}, {NULL, 0, NULL, 0} }; - int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:St::", + int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:qSt::", long_options, &option_index); if (c == -1) break; @@ -315,6 +317,7 @@ static void process_options(int argc, char *argv[]) case 'i': interval = atoi(optarg); break; case 'l': max_cycles = atoi(optarg); break; case 'p': priority = atoi(optarg); break; + case 'q': quiet = 1; break; case 'S': smp = 1; num_threads = max_cpus; @@ -381,6 +384,9 @@ static void print_stat(FILE *fp, struct params *receiver, struct params *sender, { int i; + if (quiet) + return; + for (i = 0; i < num_threads; i++) { int receiver_pid, sender_pid; @@ -646,8 +652,9 @@ int main(int argc, char *argv[]) sender[i].shutdown; if (receiver[0].samples > oldsamples || mustshutdown) { - print_stat(stdout, receiver, sender, 0, 0); - printf("\033[%dA", num_threads*2); + print_stat(stdout, receiver, sender, 0, quiet); + if (!quiet) + printf("\033[%dA", num_threads*2); } sigemptyset(&sigset); @@ -662,7 +669,10 @@ int main(int argc, char *argv[]) pthread_sigmask(SIG_SETMASK, &sigset, NULL); } - printf("\033[%dB", num_threads*2 + 2); + if (!quiet) + printf("\033[%dB", num_threads*2 + 2); + else + print_stat(stdout, receiver, sender, 0, 0); for (i = 0; i < num_threads; i++) { receiver[i].shutdown = 1; From patchwork Wed Nov 18 19:06:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 328835 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 EB01BC64E7C for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9E1222228 for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727205AbgKRTGx (ORCPT ); Wed, 18 Nov 2020 14:06:53 -0500 Received: from mx2.suse.de ([195.135.220.15]:50254 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727187AbgKRTGv (ORCPT ); Wed, 18 Nov 2020 14:06:51 -0500 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 1E105BB29; Wed, 18 Nov 2020 19:06:50 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 10/12] sigwaittest: Move statictic output into print_stat() Date: Wed, 18 Nov 2020 20:06:40 +0100 Message-Id: <20201118190642.16006-11-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Prepare the code to introduce the quiet command line option by moving the statistic output code into print_stat(). We follow here the pattern from cyclictest. While at it replace the rather sophisticated error printing code with a fatal(). Just fail if something is not working. Also reorder the include headers so that project local headers follow the system include headers. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/sigwaittest/sigwaittest.c | 97 ++++++++++++++++------------------- 1 file changed, 43 insertions(+), 54 deletions(-) diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c index 8a5d73b14fc2..d3be2fd9508c 100644 --- a/src/sigwaittest/sigwaittest.c +++ b/src/sigwaittest/sigwaittest.c @@ -38,10 +38,11 @@ #include #include #include +#include + #include "rt-utils.h" #include "rt-get_cpu.h" - -#include +#include "error.h" enum { AFFINITY_UNSPECIFIED, @@ -69,7 +70,6 @@ struct params { struct timeval unblocked, received, diff; pthread_t threadid; struct params *neighbor; - char error[MAX_PATH * 2]; }; static int mustfork; @@ -184,9 +184,8 @@ void *semathread(void *param) write(tracing_enabled, "0", 1); close(tracing_enabled); } else - snprintf(par->error, sizeof(par->error), - "Could not access %s\n", - tracing_enabled_file); + fatal("Could not access %s\n", + tracing_enabled_file); par->shutdown = 1; neighbor->shutdown = 1; } @@ -348,6 +347,39 @@ static void sighand(int sig) mustshutdown = 1; } +static void print_stat(FILE *fp, struct params *receiver, struct params *sender, + int verbose, int quiet) +{ + int i; + + for (i = 0; i < num_threads; i++) { + int receiver_pid, sender_pid; + if (mustfork) { + receiver_pid = receiver[i].pid; + sender_pid = sender[i].pid; + } else { + receiver_pid = receiver[i].tid; + sender_pid = sender[i].tid; + } + printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: ID%d, P%d, CPU%d, Cycles %d\n", + i*2, receiver_pid, receiver[i].priority, + receiver[i].cpu, receiver[i].delay.tv_nsec / + 1000, i*2+1, sender_pid, sender[i].priority, + sender[i].cpu, sender[i].samples); + } + + for (i = 0; i < num_threads; i++) { + if (receiver[i].mindiff == -1) + printf("#%d -> #%d (not yet ready)\n", i*2+1, i*2); + else + printf("#%d -> #%d, Min %4d, Cur %4d, Avg %4d, Max %4d\n", + i*2+1, i*2, receiver[i].mindiff, + (int) receiver[i].diff.tv_usec, + (int) ((receiver[i].sumdiff / + receiver[i].samples) + 0.5), + receiver[i].maxdiff); + } +} int main(int argc, char *argv[]) { @@ -540,56 +572,14 @@ int main(int argc, char *argv[]) } while (!mustshutdown) { - int printed; - int errorlines = 0; - for (i = 0; i < num_threads; i++) mustshutdown |= receiver[i].shutdown | sender[i].shutdown; if (receiver[0].samples > oldsamples || mustshutdown) { - for (i = 0; i < num_threads; i++) { - int receiver_pid, sender_pid; - if (mustfork) { - receiver_pid = receiver[i].pid; - sender_pid = sender[i].pid; - } else { - receiver_pid = receiver[i].tid; - sender_pid = sender[i].tid; - } - printf("#%1d: ID%d, P%d, CPU%d, I%ld; #%1d: " - "ID%d, P%d, CPU%d, Cycles %d\n", - i*2, receiver_pid, receiver[i].priority, - receiver[i].cpu, receiver[i].delay.tv_nsec / - 1000, i*2+1, sender_pid, sender[i].priority, - sender[i].cpu, sender[i].samples); - } - for (i = 0; i < num_threads; i++) { - if (receiver[i].mindiff == -1) - printf("#%d -> #%d (not yet ready)\n", - i*2+1, i*2); - else - printf("#%d -> #%d, Min %4d, Cur %4d, " - "Avg %4d, Max %4d\n", - i*2+1, i*2, receiver[i].mindiff, - (int) receiver[i].diff.tv_usec, - (int) ((receiver[i].sumdiff / - receiver[i].samples) + 0.5), - receiver[i].maxdiff); - if (receiver[i].error[0] != '\0') { - printf("%s", receiver[i].error); - receiver[i].error[0] = '\0'; - errorlines++; - } - if (sender[i].error[0] != '\0') { - printf("%s", sender[i].error); - sender[i].error[0] = '\0'; - errorlines++; - } - } - printed = 1; - } else - printed = 0; + print_stat(stdout, receiver, sender, 0, 0); + printf("\033[%dA", num_threads*2); + } sigemptyset(&sigset); sigaddset(&sigset, SIGTERM); @@ -601,11 +591,10 @@ int main(int argc, char *argv[]) sigemptyset(&sigset); pthread_sigmask(SIG_SETMASK, &sigset, NULL); - - if (printed && !mustshutdown) - printf("\033[%dA", num_threads*2 + errorlines); } + printf("\033[%dB", num_threads*2 + 2); + for (i = 0; i < num_threads; i++) { receiver[i].shutdown = 1; sender[i].shutdown = 1; From patchwork Wed Nov 18 19:06:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 327744 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 7FA5DC64E75 for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3534222228 for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727199AbgKRTGv (ORCPT ); Wed, 18 Nov 2020 14:06:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:50062 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727139AbgKRTGv (ORCPT ); Wed, 18 Nov 2020 14:06:51 -0500 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 64CCABB12; Wed, 18 Nov 2020 19:06:50 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 11/12] sigwaittest: Add quiet command line option Date: Wed, 18 Nov 2020 20:06:41 +0100 Message-Id: <20201118190642.16006-12-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The quiet option is useful for automated test setups where only the final result of the run is interesting. This avoids to fill up the logs. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/sigwaittest/sigwaittest.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c index d3be2fd9508c..7e287bd2424f 100644 --- a/src/sigwaittest/sigwaittest.c +++ b/src/sigwaittest/sigwaittest.c @@ -221,6 +221,7 @@ static void display_help(int error) "-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" + "-q --quiet print a summary only on exit\n" "-t --threads one thread per available processor\n" "-t [NUM] --threads=NUM number of threads:\n" " without NUM, threads = max_cpus\n" @@ -238,6 +239,7 @@ static int max_cycles; static int duration; static int interval = 1000; static int distance = 500; +static int quiet; static void process_options(int argc, char *argv[]) { @@ -258,10 +260,11 @@ static void process_options(int argc, char *argv[]) {"interval", required_argument, NULL, 'i'}, {"loops", required_argument, NULL, 'l'}, {"priority", required_argument, NULL, 'p'}, + {"quiet", no_argument, NULL, 'q'}, {"threads", optional_argument, NULL, 't'}, {NULL, 0, NULL, 0} }; - int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:t::", + int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:qt::", long_options, &option_index); if (c == -1) break; @@ -298,6 +301,7 @@ static void process_options(int argc, char *argv[]) case 'i': interval = atoi(optarg); break; case 'l': max_cycles = atoi(optarg); break; case 'p': priority = atoi(optarg); break; + case 'q': quiet = 1; break; case 't': if (optarg != NULL) num_threads = atoi(optarg); @@ -352,6 +356,9 @@ static void print_stat(FILE *fp, struct params *receiver, struct params *sender, { int i; + if (quiet) + return; + for (i = 0; i < num_threads; i++) { int receiver_pid, sender_pid; if (mustfork) { @@ -577,8 +584,9 @@ int main(int argc, char *argv[]) sender[i].shutdown; if (receiver[0].samples > oldsamples || mustshutdown) { - print_stat(stdout, receiver, sender, 0, 0); - printf("\033[%dA", num_threads*2); + print_stat(stdout, receiver, sender, 0, quiet); + if (!quiet) + printf("\033[%dA", num_threads*2); } sigemptyset(&sigset); @@ -593,7 +601,10 @@ int main(int argc, char *argv[]) pthread_sigmask(SIG_SETMASK, &sigset, NULL); } - printf("\033[%dB", num_threads*2 + 2); + if (!quiet) + printf("\033[%dB", num_threads*2 + 2); + else + print_stat(stdout, receiver, sender, 0, 0); for (i = 0; i < num_threads; i++) { receiver[i].shutdown = 1; From patchwork Wed Nov 18 19:06:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 327742 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 94B77C64E7B for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 613172222C for ; Wed, 18 Nov 2020 19:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727204AbgKRTGw (ORCPT ); Wed, 18 Nov 2020 14:06:52 -0500 Received: from mx2.suse.de ([195.135.220.15]:50144 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727194AbgKRTGw (ORCPT ); Wed, 18 Nov 2020 14:06:52 -0500 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 A4CFDBB2D; Wed, 18 Nov 2020 19:06:50 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v1 12/12] rt-migrate-test: Add quiet command line option Date: Wed, 18 Nov 2020 20:06:42 +0100 Message-Id: <20201118190642.16006-13-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201118190642.16006-1-dwagner@suse.de> References: <20201118190642.16006-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The quiet option is useful for automated test setups where only the final result of the run is interesting. This avoids to fill up the logs. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/rt-migrate-test/rt-migrate-test.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/rt-migrate-test/rt-migrate-test.c b/src/rt-migrate-test/rt-migrate-test.c index f1b7e5e4fe8c..9bf716c9178c 100644 --- a/src/rt-migrate-test/rt-migrate-test.c +++ b/src/rt-migrate-test/rt-migrate-test.c @@ -98,6 +98,7 @@ static unsigned long long now; static int done; static int loop; static int duration; +static int quiet; static pthread_barrier_t start_barrier; static pthread_barrier_t end_barrier; @@ -160,6 +161,7 @@ static void usage(int error) "-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" + "-q --quiet print a summary only on exit\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" @@ -180,11 +182,12 @@ static void parse_options(int argc, char *argv[]) {"loops", required_argument, NULL, 'l'}, {"maxerr", required_argument, NULL, 'm'}, {"prio", required_argument, NULL, 'p'}, + {"quiet", no_argument, NULL, 'q'}, {"run-time", required_argument, NULL, 'r'}, {"sleep-time", required_argument, NULL, 's'}, {NULL, 0, NULL, 0} }; - int c = getopt_long(argc, argv, "cD:ehl:m:p:r:s:", + int c = getopt_long(argc, argv, "cD:ehl:m:p:qr:s:", long_options, &option_index); if (c == -1) break; @@ -199,6 +202,7 @@ static void parse_options(int argc, char *argv[]) case 'l': nr_runs = atoi(optarg); break; case 'm': max_err = usec2nano(atoi(optarg)); break; case 'p': prio_start = atoi(optarg); break; + case 'q': quiet = 1; break; case 'r': run_interval = atoi(optarg); break; @@ -532,7 +536,8 @@ int main (int argc, char **argv) intv.tv_sec = nano2sec(INTERVAL); intv.tv_nsec = INTERVAL % sec2nano(1); - print_progress_bar(0); + if (!quiet) + print_progress_bar(0); setup_ftrace_marker(); @@ -552,7 +557,8 @@ int main (int argc, char **argv) nanosleep(&intv, NULL); - print_progress_bar((loop * 100)/nr_runs); + if (!quiet) + print_progress_bar((loop * 100)/nr_runs); end = get_time(); ftrace_write("Loop %d end now=%lld diff=%lld\n", loop, end, end - now);