From patchwork Fri Jan 15 19:09:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 364236 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.8 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 CB56AC433E6 for ; Fri, 15 Jan 2021 19:10:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AFFF23A75 for ; Fri, 15 Jan 2021 19:10:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729560AbhAOTKV (ORCPT ); Fri, 15 Jan 2021 14:10:21 -0500 Received: from mx2.suse.de ([195.135.220.15]:43272 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728565AbhAOTKV (ORCPT ); Fri, 15 Jan 2021 14:10:21 -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 DE7A5ACAC; Fri, 15 Jan 2021 19:09:39 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC v3 03/19] rt-tests: Rename error.h to rt-error.h Date: Fri, 15 Jan 2021 20:09:20 +0100 Message-Id: <20210115190936.26148-4-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115190936.26148-1-dwagner@suse.de> References: <20210115190936.26148-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Avoid confusion with the system header called error.h. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 2 +- src/include/pip_stress.h | 5 +++-- src/include/{error.h => rt-error.h} | 0 src/lib/error.c | 2 +- src/lib/rt-numa.c | 2 +- src/lib/rt-utils.c | 3 ++- src/oslat/oslat.c | 2 +- src/pi_tests/pi_stress.c | 3 +-- src/pmqtest/pmqtest.c | 6 +++--- src/ptsematest/ptsematest.c | 6 +++--- src/sched_deadline/cyclicdeadline.c | 6 +++--- src/signaltest/signaltest.c | 2 +- src/sigwaittest/sigwaittest.c | 2 +- src/svsematest/svsematest.c | 3 ++- 14 files changed, 23 insertions(+), 21 deletions(-) rename src/include/{error.h => rt-error.h} (100%) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 5c738005f778..9225e52aa982 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -36,7 +36,7 @@ #include "rt-utils.h" #include "rt-numa.h" -#include "error.h" +#include "rt-error.h" #include diff --git a/src/include/pip_stress.h b/src/include/pip_stress.h index ee8b545ab117..f03aaf397897 100644 --- a/src/include/pip_stress.h +++ b/src/include/pip_stress.h @@ -14,8 +14,9 @@ #include #include #include -#include -#include "error.h" + +#include "rt-utils.h" +#include "rt-error.h" void low(pid_t pid); /* low priority process */ void medium(void); /* medium priority process */ diff --git a/src/include/error.h b/src/include/rt-error.h similarity index 100% rename from src/include/error.h rename to src/include/rt-error.h diff --git a/src/lib/error.c b/src/lib/error.c index 4434a842da17..616f70b044e0 100644 --- a/src/lib/error.c +++ b/src/lib/error.c @@ -5,7 +5,7 @@ * error routines, similar to those found in * Advanced Programming in the UNIX Environment 2nd ed. */ -#include "error.h" +#include "rt-error.h" /* Print an error message, plus a message for err and exit with error err */ void err_exit(int err, char *fmt, ...) diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c index 04f2e9adb4b1..4a0865715141 100644 --- a/src/lib/rt-numa.c +++ b/src/lib/rt-numa.c @@ -10,7 +10,7 @@ #include #include -#include "error.h" +#include "rt-error.h" #include "rt-numa.h" int get_available_cpus(struct bitmask *cpumask) diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c index 2d68d62cd875..321a11b1172d 100644 --- a/src/lib/rt-utils.c +++ b/src/lib/rt-utils.c @@ -20,9 +20,10 @@ #include #include #include /* For SYS_gettid definitions */ + #include "rt-utils.h" #include "rt-sched.h" -#include "error.h" +#include "rt-error.h" #define TRACEBUFSIZ 1024 diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c index 0811079d9f04..9e6f70600830 100644 --- a/src/oslat/oslat.c +++ b/src/oslat/oslat.c @@ -43,7 +43,7 @@ #include "rt-utils.h" #include "rt-numa.h" -#include "error.h" +#include "rt-error.h" #ifdef __GNUC__ # define atomic_inc(ptr) __sync_add_and_fetch((ptr), 1) diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c index 538d12c975aa..49f89b7b0136 100644 --- a/src/pi_tests/pi_stress.c +++ b/src/pi_tests/pi_stress.c @@ -47,8 +47,7 @@ #include "rt-sched.h" #include "rt-utils.h" - -#include "error.h" +#include "rt-error.h" /* test timeout */ #define TIMEOUT 2 diff --git a/src/pmqtest/pmqtest.c b/src/pmqtest/pmqtest.c index 5f7a24d55db6..349b47741003 100644 --- a/src/pmqtest/pmqtest.c +++ b/src/pmqtest/pmqtest.c @@ -21,11 +21,11 @@ #include #include #include +#include + #include "rt-utils.h" #include "rt-get_cpu.h" -#include "error.h" - -#include +#include "rt-error.h" #define SYNCMQ_NAME "/syncmsg%d" #define TESTMQ_NAME "/testmsg%d" diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c index f8f075591f4b..7d4ca97773d6 100644 --- a/src/ptsematest/ptsematest.c +++ b/src/ptsematest/ptsematest.c @@ -19,11 +19,11 @@ #include #include #include +#include + #include "rt-utils.h" #include "rt-get_cpu.h" -#include "error.h" - -#include +#include "rt-error.h" enum { AFFINITY_UNSPECIFIED, diff --git a/src/sched_deadline/cyclicdeadline.c b/src/sched_deadline/cyclicdeadline.c index 98eb367248ac..19a7fcb6c488 100644 --- a/src/sched_deadline/cyclicdeadline.c +++ b/src/sched_deadline/cyclicdeadline.c @@ -30,9 +30,9 @@ #include #include -#include -#include -#include +#include "rt-utils.h" +#include "rt-sched.h" +#include "rt-error.h" #define _STR(x) #x #define STR(x) _STR(x) diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index 5427db7f8d85..c34bc994d886 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -31,7 +31,7 @@ #include #include -#include "error.h" +#include "rt-error.h" #include "rt-utils.h" #include "rt-numa.h" diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c index 7e287bd2424f..f10c24914d4a 100644 --- a/src/sigwaittest/sigwaittest.c +++ b/src/sigwaittest/sigwaittest.c @@ -42,7 +42,7 @@ #include "rt-utils.h" #include "rt-get_cpu.h" -#include "error.h" +#include "rt-error.h" enum { AFFINITY_UNSPECIFIED, diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c index 7388efb3f488..7a298e0dea8c 100644 --- a/src/svsematest/svsematest.c +++ b/src/svsematest/svsematest.c @@ -28,9 +28,10 @@ #include #include #include + #include "rt-utils.h" #include "rt-get_cpu.h" -#include "error.h" +#include "rt-error.h" #define SEM_WAIT_FOR_RECEIVER 0 #define SEM_WAIT_FOR_SENDER 1 From patchwork Fri Jan 15 19:09:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 364234 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.8 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 61A3CC433DB for ; Fri, 15 Jan 2021 19:11:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3385923A5E for ; Fri, 15 Jan 2021 19:11:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387453AbhAOTLB (ORCPT ); Fri, 15 Jan 2021 14:11:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:43850 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733203AbhAOTLB (ORCPT ); Fri, 15 Jan 2021 14:11:01 -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 7D756AE89; Fri, 15 Jan 2021 19:09:40 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC v3 05/19] cyclictest: Remove libnuma API version 1 support Date: Fri, 15 Jan 2021 20:09:22 +0100 Message-Id: <20210115190936.26148-6-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115190936.26148-1-dwagner@suse.de> References: <20210115190936.26148-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The code depends on libnuma API version 2 or higher. Remove the leftover. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/cyclictest/cyclictest.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index c0e7600b4740..245752dae2af 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -807,17 +807,12 @@ static void display_help(int error) printf("cyclictest V %1.2f\n", VERSION); printf("Usage:\n" "cyclictest \n\n" -#if LIBNUMA_API_VERSION >= 2 "-a [CPUSET] --affinity Run thread #N on processor #N, if possible, or if CPUSET\n" " given, pin threads to that set of processors in round-\n" " robin order. E.g. -a 2 pins all threads to CPU 2,\n" " but -a 3-5,0 -t 5 will run the first and fifth\n" " threads on CPU (0),thread #2 on CPU 3, thread #3\n" " on CPU 4, and thread #5 on CPU 5.\n" -#else - "-a [NUM] --affinity run thread #N on processor #N, if possible\n" - " with NUM pin all threads to the processor NUM\n" -#endif "-A USEC --aligned=USEC align thread wakeups to a specific offset\n" "-b USEC --breaktrace=USEC send break trace command when latency > USEC\n" "-c CLOCK --clock=CLOCK select clock\n" From patchwork Fri Jan 15 19:09:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 364232 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.8 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 10AD2C43381 for ; Fri, 15 Jan 2021 19:11:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1DF023A5E for ; Fri, 15 Jan 2021 19:11:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387777AbhAOTLD (ORCPT ); Fri, 15 Jan 2021 14:11:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:43848 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733214AbhAOTLC (ORCPT ); Fri, 15 Jan 2021 14:11:02 -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 0EB96AE91; Fri, 15 Jan 2021 19:09:41 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC v3 06/19] signaltest: Move thread data to struct thread_param Date: Fri, 15 Jan 2021 20:09:23 +0100 Message-Id: <20210115190936.26148-7-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115190936.26148-1-dwagner@suse.de> References: <20210115190936.26148-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Group thread realated data such as thread ID to struct thread_param. Signed-off-by: Daniel Wagner --- src/signaltest/signaltest.c | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index c34bc994d886..dd5633d5fc51 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -40,6 +40,10 @@ /* Struct to transfer parameters to the thread */ struct thread_param { + pthread_t thread; + pthread_t tothread; + int threadstarted; + int tid; int id; int prio; int signal; @@ -47,6 +51,7 @@ struct thread_param { struct thread_stat *stats; int bufmsk; int cpu; + int interrupted; }; /* Struct for statistics */ @@ -58,11 +63,6 @@ struct thread_stat { long act; double avg; long *values; - pthread_t thread; - pthread_t tothread; - int threadstarted; - int tid; - int interrupted; }; static int shutdown; @@ -86,7 +86,7 @@ void *signalthread(void *param) pthread_t thread; cpu_set_t mask; - stat->tid = gettid(); + par->tid = gettid(); if (par->cpu != -1) { CPU_ZERO(&mask); @@ -105,7 +105,7 @@ void *signalthread(void *param) schedp.sched_priority = par->prio; sched_setscheduler(0, policy, &schedp); - stat->threadstarted++; + par->threadstarted++; clock_gettime(CLOCK_MONOTONIC, &before); @@ -128,7 +128,7 @@ void *signalthread(void *param) /* Get current time */ clock_gettime(CLOCK_MONOTONIC, &now); - pthread_kill(stat->tothread, SIGUSR1); + pthread_kill(par->tothread, SIGUSR1); /* Skip the first cycle */ if (first) { @@ -148,7 +148,7 @@ void *signalthread(void *param) if (!stopped && tracelimit && !par->id && (diff > tracelimit)) { stat->act = diff; - stat->interrupted = 1; + par->interrupted = 1; stopped++; shutdown++; } @@ -167,7 +167,7 @@ void *signalthread(void *param) schedp.sched_priority = 0; sched_setscheduler(0, SCHED_OTHER, &schedp); - stat->threadstarted = -1; + par->threadstarted = -1; return NULL; } @@ -298,7 +298,7 @@ static void print_stat(struct thread_param *par, int index, int verbose) if (quiet != 1) { printf("T:%2d (%5d) P:%2d C:%7lu " "Min:%7ld Act:%5ld Avg:%5ld Max:%8ld\n", - index, stat->tid, par->prio, + index, par->tid, par->prio, stat->cycles, stat->min, stat->act, stat->cycles ? (long)(stat->avg/stat->cycles) : 0, stat->max); @@ -389,8 +389,8 @@ int main(int argc, char **argv) stat[i].min = 1000000; stat[i].max = -1000000; stat[i].avg = 0.0; - stat[i].threadstarted = 1; - status = pthread_create(&stat[i].thread, NULL, signalthread, + par[i].threadstarted = 1; + status = pthread_create(&par[i].thread, NULL, signalthread, &par[i]); if (status) fatal("failed to create thread %d: %s\n", i, @@ -401,18 +401,18 @@ int main(int argc, char **argv) int allstarted = 1; for (i = 0; i < num_threads; i++) { - if (stat[i].threadstarted != 2) + if (par[i].threadstarted != 2) allstarted = 0; } if (!allstarted) continue; for (i = 0; i < num_threads - 1; i++) - stat[i].tothread = stat[i+1].thread; - stat[i].tothread = stat[0].thread; + par[i].tothread = par[i+1].thread; + par[i].tothread = par[0].thread; break; } - pthread_kill(stat[0].thread, signum); + pthread_kill(par[0].thread, signum); while (!shutdown) { char lavg[256]; @@ -443,12 +443,12 @@ int main(int argc, char **argv) if (quiet) quiet = 2; for (i = 0; i < num_threads; i++) { - if (stat[i].threadstarted > 0) - pthread_kill(stat[i].thread, SIGUSR1); - if (stat[i].interrupted) + if (par[i].threadstarted > 0) + pthread_kill(par[i].thread, SIGUSR1); + if (par[i].interrupted) printf("Thread %d exceeded trace limit.\n", i); - if (stat[i].threadstarted) { - pthread_join(stat[i].thread, NULL); + if (par[i].threadstarted) { + pthread_join(par[i].thread, NULL); print_stat(&par[i], i, 0); } if (stat[i].values) From patchwork Fri Jan 15 19:09:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 364233 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.8 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 AB25AC433E9 for ; Fri, 15 Jan 2021 19:11:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F00023A5E for ; Fri, 15 Jan 2021 19:11:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387667AbhAOTLC (ORCPT ); Fri, 15 Jan 2021 14:11:02 -0500 Received: from mx2.suse.de ([195.135.220.15]:43860 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733251AbhAOTLC (ORCPT ); Fri, 15 Jan 2021 14:11:02 -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 4AC5CAEBA; Fri, 15 Jan 2021 19:09:42 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC v3 10/19] rt-utils: Add JSON common header output helper Date: Fri, 15 Jan 2021 20:09:27 +0100 Message-Id: <20210115190936.26148-11-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115190936.26148-1-dwagner@suse.de> References: <20210115190936.26148-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org rt_write_json writes the common system information header of the rt-test currently executed. Signed-off-by: Daniel Wagner --- src/include/rt-utils.h | 4 +++ src/lib/rt-utils.c | 70 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/src/include/rt-utils.h b/src/include/rt-utils.h index 39ddbd9eae29..36af92b170df 100644 --- a/src/include/rt-utils.h +++ b/src/include/rt-utils.h @@ -80,4 +80,8 @@ static inline int64_t calctime(struct timespec t) return time; } +void rt_write_json(const char *filename, int argc, char *argv[], + void (*cb)(FILE *, void *), + void *data); + #endif /* __RT_UTILS.H */ diff --git a/src/lib/rt-utils.c b/src/lib/rt-utils.c index 321a11b1172d..a679bab8c595 100644 --- a/src/lib/rt-utils.c +++ b/src/lib/rt-utils.c @@ -20,6 +20,7 @@ #include #include #include /* For SYS_gettid definitions */ +#include #include "rt-utils.h" #include "rt-sched.h" @@ -482,3 +483,72 @@ void disable_trace_mark(void) { close_tracemark_fd(); } + +static char *get_cmdline(int argc, char *argv[]) +{ + char *cmdline; + int len, i; + + len = 0; + for (i = 0; i < argc; i++) + len += strlen(argv[i]) + 1; + + cmdline = malloc(len); + if (!cmdline) + err_exit(ENOMEM, "Could not copy cmdline"); + + memset(cmdline, 0, len); + for (i = 0; i < argc;) { + cmdline = strcat(cmdline, argv[i]); + i++; + if (i < argc) + cmdline = strcat(cmdline, " "); + } + + return cmdline; +} + +void rt_write_json(const char *filename, int argc, char *argv[], + void (*cb)(FILE *, void *), + void *data) +{ + struct utsname buf; + char *cmdline; + FILE *f; + + if (!strcmp("-", filename)) { + f = stdout; + } else { + f = fopen(filename, "w"); + if (!f) + err_exit(errno, "Failed to open '%s'\n", filename); + } + + cmdline = get_cmdline(argc, argv); + if (!cmdline) + err_exit(ENOMEM, "get_cmdline()"); + + if (uname(&buf)) + err_exit(errno, "Could not retrieve system information"); + + fprintf(f, "{\n"); + fprintf(f, " \"file_version\": 1,\n"); + fprintf(f, " \"cmdline:\": \"%s\",\n", cmdline); + fprintf(f, " \"rt_test_version:\": \"%1.2f\",\n", VERSION); + fprintf(f, " \"sysinfo\": {\n"); + fprintf(f, " \"sysname\": \"%s\",\n", buf.sysname); + fprintf(f, " \"nodename\": \"%s\",\n", buf.nodename); + fprintf(f, " \"release\": \"%s\",\n", buf.release); + fprintf(f, " \"version\": \"%s\",\n", buf.version); + fprintf(f, " \"machine\": \"%s\"\n", buf.machine); + fprintf(f, " },\n"); + + (cb)(f, data); + + fprintf(f, "}\n"); + + free(cmdline); + + if (strcmp("-", filename)) + fclose(f); +} From patchwork Fri Jan 15 19:09:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 364231 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=-13.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, 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 C9E92C433DB for ; Fri, 15 Jan 2021 19:11:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A0FCD23A5E for ; Fri, 15 Jan 2021 19:11:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387813AbhAOTLD (ORCPT ); Fri, 15 Jan 2021 14:11:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:43864 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387490AbhAOTLD (ORCPT ); Fri, 15 Jan 2021 14:11:03 -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 952E6AEBE; Fri, 15 Jan 2021 19:09:42 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC v3 11/19] cyclictest: Add JSON output feature Date: Fri, 15 Jan 2021 20:09:28 +0100 Message-Id: <20210115190936.26148-12-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115190936.26148-1-dwagner@suse.de> References: <20210115190936.26148-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Write the test results as JSON output to a file. This allows to simplifies any parsing later on. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 46 ++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 245752dae2af..5e88213eeb13 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -217,6 +218,7 @@ static struct timespec globalt; static char fifopath[MAX_PATH]; static char histfile[MAX_PATH]; +static char outfile[MAX_PATH]; static struct thread_param **parameters; static struct thread_stat **statistics; @@ -838,6 +840,7 @@ static void display_help(int error) " latency is hit. Useful for low bandwidth.\n" "-N --nsecs print results in ns instead of us (default us)\n" "-o RED --oscope=RED oscilloscope mode, reduce verbose output by RED\n" + " --output=FILENAME write final results into FILENAME, JSON formatted\n" "-p PRIO --priority=PRIO priority of highest prio thread\n" " --policy=NAME policy of measurement thread, where NAME may be one\n" " of: other, normal, batch, idle, fifo or rr.\n" @@ -945,7 +948,7 @@ enum option_values { OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS, OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP, OPT_SMI, - OPT_TRACEMARK, OPT_POSIX_TIMERS, + OPT_TRACEMARK, OPT_POSIX_TIMERS, OPT_OUTPUT }; /* Process commandline options */ @@ -979,6 +982,7 @@ static void process_options(int argc, char *argv[]) {"refresh_on_max", no_argument, NULL, OPT_REFRESH }, {"nsecs", no_argument, NULL, OPT_NSECS }, {"oscope", required_argument, NULL, OPT_OSCOPE }, + {"output", required_argument, NULL, OPT_OUTPUT }, {"priority", required_argument, NULL, OPT_PRIORITY }, {"quiet", no_argument, NULL, OPT_QUIET }, {"priospread", no_argument, NULL, OPT_PRIOSPREAD }, @@ -1073,6 +1077,9 @@ static void process_options(int argc, char *argv[]) case 'o': case OPT_OSCOPE: oscope_reduction = atoi(optarg); break; + case OPT_OUTPUT: + strncpy(outfile, optarg, strnlen(optarg, MAX_PATH-1)); + break; case 'p': case OPT_PRIORITY: priority = atoi(optarg); @@ -1690,6 +1697,40 @@ static void rstat_setup(void) return; } +static void write_stats(FILE *f, void *data) +{ + struct thread_param **par = parameters; + unsigned int i, j, comma; + struct thread_stat *s; + + fprintf(f, " \"num_threads\": %d,\n", num_threads); + fprintf(f, " \"resolution_in_ns\": %u,\n", use_nsecs); + fprintf(f, " \"thread\": {\n"); + for (i = 0; i < num_threads; i++) { + fprintf(f, " \"%u\": {\n", i); + + fprintf(f, " \"histogram\": {"); + s = par[i]->stats; + for (j = 0, comma = 0; j < histogram; j++) { + if (s->hist_array[j] == 0) + continue; + fprintf(f, "%s", comma ? ",\n" : "\n"); + fprintf(f, " \"%u\": %" PRIu64,j, s->hist_array[j]); + comma = 1; + } + if (comma) + fprintf(f, "\n"); + fprintf(f, " },\n"); + fprintf(f, " \"cycles\": %" PRIu64 ",\n", s->cycles); + fprintf(f, " \"min\": %" PRIu64 ",\n", s->min); + fprintf(f, " \"max\": %" PRIu64 ",\n", s->max); + fprintf(f, " \"avg\": %.2f,\n", s->avg/s->cycles); + fprintf(f, " \"cpu\": %d,\n", par[i]->cpu); + fprintf(f, " \"node\": %d\n", par[i]->node); + fprintf(f, " }%s\n", i == num_threads - 1 ? "" : ","); + } + fprintf(f, " }\n"); +} int main(int argc, char **argv) { @@ -2033,6 +2074,9 @@ int main(int argc, char **argv) if (!verbose && !quiet && refresh_on_max) printf("\033[%dB", num_threads + 2); + if (strlen(outfile) != 0) + rt_write_json(outfile, argc, argv, write_stats, NULL); + if (quiet) quiet = 2; for (i = 0; i < num_threads; i++) { From patchwork Fri Jan 15 19:09:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 364229 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.8 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 AA9DCC433DB for ; Fri, 15 Jan 2021 19:11:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82C6423A5E for ; Fri, 15 Jan 2021 19:11:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387814AbhAOTLS (ORCPT ); Fri, 15 Jan 2021 14:11:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:43850 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733221AbhAOTLR (ORCPT ); Fri, 15 Jan 2021 14:11:17 -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 E66F7AEE0; Fri, 15 Jan 2021 19:09:43 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC v3 12/19] signaltest: Add JSON output feature Date: Fri, 15 Jan 2021 20:09:29 +0100 Message-Id: <20210115190936.26148-13-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115190936.26148-1-dwagner@suse.de> References: <20210115190936.26148-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Write the test results as JSON output to a file. This allows to simplifies any parsing later on. Signed-off-by: Daniel Wagner --- src/signaltest/signaltest.c | 109 +++++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 21 deletions(-) diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index dd5633d5fc51..340fd55517d4 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -205,6 +206,14 @@ static int verbose; static int quiet; static int lockall; static struct bitmask *affinity_mask = NULL; +static char outfile[MAX_PATH]; + +enum option_values { + OPT_AFFINITY=1, OPT_BREAKTRACE, + OPT_DURATION, OPT_HELP, OPT_LOOPS, + OPT_MLOCKALL, OPT_OUTPUT, OPT_PRIORITY, + OPT_QUIET, OPT_SMP, OPT_THREADS, OPT_VERBOSE +}; /* Process commandline options */ static void process_options(int argc, char *argv[]) @@ -216,17 +225,18 @@ 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'}, - {"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'}, - {"smp", no_argument, NULL, 'S'}, - {"threads", required_argument, NULL, 't'}, - {"verbose", no_argument, NULL, 'v'}, + {"affinity", optional_argument, NULL, OPT_AFFINITY}, + {"breaktrace", required_argument, NULL, OPT_BREAKTRACE}, + {"duration", required_argument, NULL, OPT_DURATION}, + {"help", no_argument, NULL, OPT_HELP}, + {"loops", required_argument, NULL, OPT_LOOPS}, + {"mlockall", no_argument, NULL, OPT_MLOCKALL}, + {"output", required_argument, NULL, OPT_OUTPUT}, + {"priority", required_argument, NULL, OPT_PRIORITY}, + {"quiet", no_argument, NULL, OPT_QUIET}, + {"smp", no_argument, NULL, OPT_SMP}, + {"threads", required_argument, NULL, OPT_THREADS}, + {"verbose", no_argument, NULL, OPT_VERBOSE}, {NULL, 0, NULL, 0} }; int c = getopt_long(argc, argv, "a::b:D:hl:mp:qSt:v", @@ -234,6 +244,7 @@ static void process_options(int argc, char *argv[]) if (c == -1) break; switch (c) { + case OPT_AFFINITY: case 'a': if (optarg) { parse_cpumask(optarg, &affinity_mask); @@ -248,17 +259,49 @@ static void process_options(int argc, char *argv[]) printf("Using %u cpus.\n", numa_bitmask_weight(affinity_mask)); break; - case 'b': tracelimit = atoi(optarg); break; - case 'D': duration = parse_time_string(optarg); break; + case OPT_BREAKTRACE: + case 'b': + tracelimit = atoi(optarg); + break; + case OPT_DURATION: + case 'D': + duration = parse_time_string(optarg); + break; + case OPT_HELP: 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 'S': smp = 1; break; - case 't': num_threads = atoi(optarg); break; - case 'v': verbose = 1; break; + case 'h': + display_help(0); + break; + case OPT_LOOPS: + case 'l': + max_cycles = atoi(optarg); + break; + case OPT_MLOCKALL: + case 'm': + lockall = 1; + break; + case OPT_OUTPUT: + strncpy(outfile, optarg, strnlen(optarg, MAX_PATH-1)); + break; + case OPT_PRIORITY: + case 'p': + priority = atoi(optarg); + break; + case OPT_QUIET: + case 'q': + quiet = 1; + break; + case OPT_SMP: + case 'S': + smp = 1; + break; + case OPT_THREADS: + case 't': + num_threads = atoi(optarg); + break; + case OPT_VERBOSE: + case 'v': verbose = 1; + break; } } @@ -312,6 +355,27 @@ static void print_stat(struct thread_param *par, int index, int verbose) } } +static void write_stats(FILE *f, void *data) +{ + struct thread_param *par = data; + struct thread_stat *s; + unsigned int i; + + fprintf(f, " \"thread\": {\n"); + for (i = 0; i < num_threads; i++) { + fprintf(f, " \"%u\": {\n", i); + s = &par->stats[i]; + fprintf(f, " \"cycles\": %" PRIu64 ",\n", s->cycles); + fprintf(f, " \"min\": %" PRIu64 ",\n", s->min); + fprintf(f, " \"max\": %" PRIu64 ",\n", s->max); + fprintf(f, " \"avg\": %.2f,\n", s->avg/s->cycles); + fprintf(f, " \"cpu\": %d,\n", par->cpu); + fprintf(f, " }%s\n", i == num_threads - 1 ? "" : ","); + + } + fprintf(f, " }\n"); +} + int main(int argc, char **argv) { sigset_t sigset; @@ -454,6 +518,9 @@ int main(int argc, char **argv) if (stat[i].values) free(stat[i].values); } + if (strlen(outfile) != 0) + rt_write_json(outfile, argc, argv, write_stats, par); + free(stat); outpar: free(par); From patchwork Fri Jan 15 19:09:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 364230 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.8 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 60FBFC4332E for ; Fri, 15 Jan 2021 19:11:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3A92623A5E for ; Fri, 15 Jan 2021 19:11:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387686AbhAOTLE (ORCPT ); Fri, 15 Jan 2021 14:11:04 -0500 Received: from mx2.suse.de ([195.135.220.15]:43872 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733265AbhAOTLE (ORCPT ); Fri, 15 Jan 2021 14:11:04 -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 CFB9FAED7; Fri, 15 Jan 2021 19:09:43 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC v3 15/19] ptsematest: Add JSON output feature Date: Fri, 15 Jan 2021 20:09:32 +0100 Message-Id: <20210115190936.26148-16-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115190936.26148-1-dwagner@suse.de> References: <20210115190936.26148-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Write the test results as JSON output to a file. This allows to simplifies any parsing later on. Signed-off-by: Daniel Wagner --- src/ptsematest/ptsematest.c | 120 ++++++++++++++++++++++++++++++------ 1 file changed, 101 insertions(+), 19 deletions(-) diff --git a/src/ptsematest/ptsematest.c b/src/ptsematest/ptsematest.c index 7d4ca97773d6..2755bfde5210 100644 --- a/src/ptsematest/ptsematest.c +++ b/src/ptsematest/ptsematest.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "rt-utils.h" #include "rt-get_cpu.h" @@ -155,6 +156,7 @@ static void display_help(int error) " days.\n" "-i INTV --interval=INTV base interval of thread in us default=1000\n" "-l LOOPS --loops=LOOPS number of loops: default=0(endless)\n" + " --output=FILENAME write final results into FILENAME, JSON formatted\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" @@ -180,6 +182,13 @@ static int distance = 500; static int smp; static int sameprio; static int quiet; +static char outfile[MAX_PATH]; + +enum option_value { + OPT_AFFINITY=1, OPT_BREAKTRACE, OPT_DISTANCE, OPT_DURATION, + OPT_HELP, OPT_INTERVAL, OPT_LOOPS, OPT_OUTPUT, OPT_PRIORITY, + OPT_QUIET, OPT_SMP, OPT_THREADS +}; static void process_options(int argc, char *argv[]) { @@ -190,17 +199,18 @@ 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'}, - {"duration", required_argument, NULL, 'D'}, - {"help", no_argument, NULL, 'h'}, - {"interval", required_argument, NULL, 'i'}, - {"loops", required_argument, NULL, 'l'}, - {"priority", required_argument, NULL, 'p'}, - {"quiet", no_argument , NULL, 'q'}, - {"smp", no_argument, NULL, 'S'}, - {"threads", optional_argument, NULL, 't'}, + {"affinity", optional_argument, NULL, OPT_AFFINITY}, + {"breaktrace", required_argument, NULL, OPT_BREAKTRACE}, + {"distance", required_argument, NULL, OPT_DISTANCE}, + {"duration", required_argument, NULL, OPT_DURATION}, + {"help", no_argument, NULL, OPT_HELP}, + {"interval", required_argument, NULL, OPT_INTERVAL}, + {"loops", required_argument, NULL, OPT_LOOPS}, + {"output", required_argument, NULL, OPT_OUTPUT }, + {"priority", required_argument, NULL, OPT_PRIORITY}, + {"quiet", no_argument , NULL, OPT_QUIET}, + {"smp", no_argument, NULL, OPT_SMP}, + {"threads", optional_argument, NULL, OPT_THREADS}, {NULL, 0, NULL, 0} }; int c = getopt_long (argc, argv, "a::b:d:i:l:D:p:qSt::h", @@ -208,6 +218,7 @@ static void process_options(int argc, char *argv[]) if (c == -1) break; switch (c) { + case OPT_AFFINITY: case 'a': if (smp) { warn("-a ignored due to --smp\n"); @@ -223,20 +234,49 @@ static void process_options(int argc, char *argv[]) setaffinity = AFFINITY_USEALL; } break; - case 'b': tracelimit = atoi(optarg); break; - case 'd': distance = atoi(optarg); break; - case 'D': duration = parse_time_string(optarg); break; - case 'i': interval = atoi(optarg); break; + case OPT_BREAKTRACE: + case 'b': + tracelimit = atoi(optarg); + break; + case OPT_DISTANCE: + case 'd': + distance = atoi(optarg); + break; + case OPT_DURATION: + case 'D': + duration = parse_time_string(optarg); + break; + case OPT_INTERVAL: + case 'i': + interval = atoi(optarg); + break; + case OPT_HELP: case '?': - 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 'h': + display_help(0); + break; + case OPT_LOOPS: + case 'l': + max_cycles = atoi(optarg); + break; + case OPT_OUTPUT: + strncpy(outfile, optarg, strnlen(optarg, MAX_PATH-1)); + break; + case OPT_PRIORITY: + case 'p': + priority = atoi(optarg); + break; + case OPT_QUIET: + case 'q': + quiet = 1; + break; + case OPT_SMP: case 'S': smp = 1; num_threads = max_cpus; setaffinity = AFFINITY_USEALL; break; + case OPT_THREADS: case 't': if (smp) { warn("-t ignored due to --smp\n"); @@ -316,6 +356,40 @@ static void print_stat(FILE *fp, struct params *receiver, struct params *sender, } } +struct params_stats { + struct params *receiver; + struct params *sender; +}; + +static void write_stats(FILE *f, void *data) +{ + struct params_stats *ps = data; + struct params *s, *r; + unsigned int i; + + fprintf(f, " \"num_threads\": %d,\n", num_threads); + fprintf(f, " \"thread\": {\n"); + for (i = 0; i < num_threads; i++) { + s = &ps->sender[i]; + r = &ps->receiver[i]; + fprintf(f, " \"%u\": {\n", i); + fprintf(f, " \"sender\": {\n"); + fprintf(f, " \"cpu\": %d,\n", s->cpu); + fprintf(f, " \"priority\": %d,\n", s->priority); + fprintf(f, " \"samples\": %d,\n", s->samples); + fprintf(f, " \"interval\": %ld\n", r->delay.tv_nsec/1000); + fprintf(f, " },\n"); + fprintf(f, " \"receiver\": {\n"); + fprintf(f, " \"cpu\": %d,\n", r->cpu); + fprintf(f, " \"priority\": %d,\n", r->priority); + fprintf(f, " \"min\": %d,\n", r->mindiff); + fprintf(f, " \"avg\": %.2f,\n", r->sumdiff/r->samples); + fprintf(f, " \"max\": %d\n", r->maxdiff); + fprintf(f, " }\n"); + fprintf(f, " }%s\n", i == num_threads - 1 ? "" : ","); + } + fprintf(f, " }\n"); +} int main(int argc, char *argv[]) { @@ -439,6 +513,14 @@ int main(int argc, char *argv[]) pthread_mutex_destroy(&syncmutex[i]); } + if (strlen(outfile) != 0) { + struct params_stats ps = { + .receiver = receiver, + .sender = sender, + }; + rt_write_json(outfile, argc, argv, write_stats, &ps); + } + nomem: return 0; From patchwork Fri Jan 15 19:09:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 364227 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.8 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 DE9D1C433E0 for ; Fri, 15 Jan 2021 19:11:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB20823A5E for ; Fri, 15 Jan 2021 19:11:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733150AbhAOTLo (ORCPT ); Fri, 15 Jan 2021 14:11:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:44234 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726065AbhAOTLn (ORCPT ); Fri, 15 Jan 2021 14:11:43 -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 299EBAEE6; Fri, 15 Jan 2021 19:09:44 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC v3 16/19] sigwaittest: Add JSON output feature Date: Fri, 15 Jan 2021 20:09:33 +0100 Message-Id: <20210115190936.26148-17-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115190936.26148-1-dwagner@suse.de> References: <20210115190936.26148-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Write the test results as JSON output to a file. This allows to simplifies any parsing later on. Signed-off-by: Daniel Wagner --- src/sigwaittest/sigwaittest.c | 117 ++++++++++++++++++++++++++++------ 1 file changed, 99 insertions(+), 18 deletions(-) diff --git a/src/sigwaittest/sigwaittest.c b/src/sigwaittest/sigwaittest.c index f10c24914d4a..0cdf30a6a769 100644 --- a/src/sigwaittest/sigwaittest.c +++ b/src/sigwaittest/sigwaittest.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "rt-utils.h" #include "rt-get_cpu.h" @@ -220,6 +221,7 @@ static void display_help(int error) "-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" + " --output=FILENAME write final results into FILENAME, JSON formatted\n" "-p PRIO --prio=PRIO priority\n" "-q --quiet print a summary only on exit\n" "-t --threads one thread per available processor\n" @@ -240,6 +242,13 @@ static int duration; static int interval = 1000; static int distance = 500; static int quiet; +static char outfile[MAX_PATH]; + +enum option_value { + OPT_AFFINITY=1, OPT_BREAKTRACE, OPT_DISTANCE, OPT_DURATION, + OPT_FORK, OPT_HELP, OPT_INTERVAL, OPT_LOOPS, OPT_OUTPUT, + OPT_PRIORITY, OPT_QUIET, OPT_THREADS +}; static void process_options(int argc, char *argv[]) { @@ -251,17 +260,18 @@ 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'}, - {"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'}, - {"quiet", no_argument, NULL, 'q'}, - {"threads", optional_argument, NULL, 't'}, + {"affinity", optional_argument, NULL, OPT_AFFINITY}, + {"breaktrace", required_argument, NULL, OPT_BREAKTRACE}, + {"distance", required_argument, NULL, OPT_DISTANCE}, + {"duration", required_argument, NULL, OPT_DURATION}, + {"fork", optional_argument, NULL, OPT_FORK}, + {"help", no_argument, NULL, OPT_HELP}, + {"interval", required_argument, NULL, OPT_INTERVAL}, + {"loops", required_argument, NULL, OPT_LOOPS}, + {"output", required_argument, NULL, OPT_OUTPUT }, + {"priority", required_argument, NULL, OPT_PRIORITY}, + {"quiet", no_argument, NULL, OPT_QUIET}, + {"threads", optional_argument, NULL, OPT_THREADS}, {NULL, 0, NULL, 0} }; int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:qt::", @@ -269,6 +279,7 @@ static void process_options(int argc, char *argv[]) if (c == -1) break; switch (c) { + case OPT_AFFINITY: case 'a': if (optarg != NULL) { affinity = atoi(optarg); @@ -280,9 +291,19 @@ static void process_options(int argc, char *argv[]) setaffinity = AFFINITY_USEALL; } break; - case 'b': thistracelimit = atoi(optarg); break; - case 'd': distance = atoi(optarg); break; - case 'D': duration = parse_time_string(optarg); break; + case OPT_BREAKTRACE: + case 'b': + thistracelimit = atoi(optarg); + break; + case OPT_DISTANCE: + case 'd': + distance = atoi(optarg); + break; + case OPT_DURATION: + case 'D': + duration = parse_time_string(optarg); + break; + case OPT_FORK: case 'f': if (optarg != NULL) { wasforked = 1; @@ -294,14 +315,31 @@ static void process_options(int argc, char *argv[]) } else mustfork = 1; break; + case OPT_HELP: case '?': case 'h': display_help(0); break; - 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 OPT_INTERVAL: + case 'i': + interval = atoi(optarg); + break; + case OPT_LOOPS: + case 'l': + max_cycles = atoi(optarg); + break; + case OPT_OUTPUT: + strncpy(outfile, optarg, strnlen(optarg, MAX_PATH-1)); + break; + case OPT_PRIORITY: + case 'p': + priority = atoi(optarg); + break; + case OPT_QUIET: + case 'q': + quiet = 1; + break; + case OPT_THREADS: case 't': if (optarg != NULL) num_threads = atoi(optarg); @@ -388,6 +426,41 @@ static void print_stat(FILE *fp, struct params *receiver, struct params *sender, } } +struct params_stats { + struct params *receiver; + struct params *sender; +}; + +static void write_stats(FILE *f, void *data) +{ + struct params_stats *ps = data; + struct params *s, *r; + unsigned int i; + + fprintf(f, " \"num_threads\": %d,\n", num_threads); + fprintf(f, " \"thread\": {\n"); + for (i = 0; i < num_threads; i++) { + s = &ps->sender[i]; + r = &ps->receiver[i]; + fprintf(f, " \"%u\": {\n", i); + fprintf(f, " \"sender\": {\n"); + fprintf(f, " \"cpu\": %d,\n", s->cpu); + fprintf(f, " \"priority\": %d,\n", s->priority); + fprintf(f, " \"samples\": %d,\n", s->samples); + fprintf(f, " \"interval\": %ld\n", r->delay.tv_nsec/1000); + fprintf(f, " },\n"); + fprintf(f, " \"receiver\": {\n"); + fprintf(f, " \"cpu\": %d,\n", r->cpu); + fprintf(f, " \"priority\": %d,\n", r->priority); + fprintf(f, " \"min\": %d,\n", r->mindiff); + fprintf(f, " \"avg\": %.2f,\n", r->sumdiff/r->samples); + fprintf(f, " \"max\": %d\n", r->maxdiff); + fprintf(f, " }\n"); + fprintf(f, " }%s\n", i == num_threads - 1 ? "" : ","); + } + fprintf(f, " }\n"); +} + int main(int argc, char *argv[]) { int i, totalsize = 0; @@ -627,6 +700,14 @@ int main(int argc, char *argv[]) } } + if (strlen(outfile) != 0) { + struct params_stats ps = { + .receiver = receiver, + .sender = sender, + }; + rt_write_json(outfile, argc, argv, write_stats, &ps); + } + nomem: if (mustfork) { munmap(param, totalsize); From patchwork Fri Jan 15 19:09:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 364228 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.8 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 B12DEC433E0 for ; Fri, 15 Jan 2021 19:11:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80BFA23A6C for ; Fri, 15 Jan 2021 19:11:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387848AbhAOTLT (ORCPT ); Fri, 15 Jan 2021 14:11:19 -0500 Received: from mx2.suse.de ([195.135.220.15]:43856 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387662AbhAOTLS (ORCPT ); Fri, 15 Jan 2021 14:11:18 -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 790BFAF26; Fri, 15 Jan 2021 19:09:44 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC v3 17/19] svsematest: Add JSON output feature Date: Fri, 15 Jan 2021 20:09:34 +0100 Message-Id: <20210115190936.26148-18-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210115190936.26148-1-dwagner@suse.de> References: <20210115190936.26148-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Write the test results as JSON output to a file. This allows to simplifies any parsing later on. Signed-off-by: Daniel Wagner --- src/svsematest/svsematest.c | 124 ++++++++++++++++++++++++++++++------ 1 file changed, 104 insertions(+), 20 deletions(-) diff --git a/src/svsematest/svsematest.c b/src/svsematest/svsematest.c index 7a298e0dea8c..23f84bcbd3dc 100644 --- a/src/svsematest/svsematest.c +++ b/src/svsematest/svsematest.c @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -233,6 +234,7 @@ static void display_help(int error) "-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" + " --output=FILENAME write final results into FILENAME, JSON formatted\n" "-p PRIO --prio=PRIO priority\n" "-S --smp SMP testing: options -a -t and same priority\n" " of all threads\n" @@ -255,6 +257,13 @@ static int distance = 500; static int smp; static int sameprio; static int quiet; +static char outfile[MAX_PATH]; + +enum option_value { + OPT_AFFINITY=1, OPT_BREAKTRACE, OPT_DISTANCE, OPT_DURATION, + OPT_FORK, OPT_HELP, OPT_INTERVAL, OPT_LOOPS, OPT_OUTPUT, + OPT_PRIORITY, OPT_QUIET, OPT_SMP, OPT_THREADS +}; static void process_options(int argc, char *argv[]) { @@ -266,18 +275,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'}, - {"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'}, - {"quiet", no_argument, NULL, 'q'}, - {"smp", no_argument, NULL, 'S'}, - {"threads", optional_argument, NULL, 't'}, + {"affinity", optional_argument, NULL, OPT_AFFINITY}, + {"breaktrace", required_argument, NULL, OPT_BREAKTRACE}, + {"distance", required_argument, NULL, OPT_DISTANCE}, + {"duration", required_argument, NULL, OPT_DURATION}, + {"fork", optional_argument, NULL, OPT_FORK}, + {"help", no_argument, NULL, OPT_HELP}, + {"interval", required_argument, NULL, OPT_INTERVAL}, + {"loops", required_argument, NULL, OPT_LOOPS}, + {"output", required_argument, NULL, OPT_OUTPUT}, + {"priority", required_argument, NULL, OPT_PRIORITY}, + {"quiet", no_argument, NULL, OPT_QUIET}, + {"smp", no_argument, NULL, OPT_SMP}, + {"threads", optional_argument, NULL, OPT_THREADS}, {NULL, 0, NULL, 0} }; int c = getopt_long (argc, argv, "a::b:d:D:f::hi:l:p:qSt::", @@ -285,6 +295,7 @@ static void process_options(int argc, char *argv[]) if (c == -1) break; switch (c) { + case OPT_AFFINITY: case 'a': if (smp) { warn("-a ignored due to --smp\n"); @@ -300,9 +311,19 @@ static void process_options(int argc, char *argv[]) setaffinity = AFFINITY_USEALL; } break; - case 'b': thistracelimit = atoi(optarg); break; - case 'd': distance = atoi(optarg); break; - case 'D': duration = parse_time_string(optarg); break; + case OPT_BREAKTRACE: + case 'b': + thistracelimit = atoi(optarg); + break; + case OPT_DISTANCE: + case 'd': + distance = atoi(optarg); + break; + case OPT_DURATION: + case 'D': + duration = parse_time_string(optarg); + break; + case OPT_FORK: case 'f': if (optarg != NULL) { wasforked = 1; @@ -314,16 +335,36 @@ 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 'p': priority = atoi(optarg); break; - case 'q': quiet = 1; break; + case OPT_HELP: + case 'h': + display_help(0); + break; + case OPT_INTERVAL: + case 'i': + interval = atoi(optarg); + break; + case OPT_LOOPS: + case 'l': + max_cycles = atoi(optarg); + break; + case OPT_OUTPUT: + strncpy(outfile, optarg, strnlen(optarg, MAX_PATH-1)); + break; + case OPT_PRIORITY: + case 'p': + priority = atoi(optarg); + break; + case OPT_QUIET: + case 'q': + quiet = 1; + break; + case OPT_SMP: case 'S': smp = 1; num_threads = max_cpus; setaffinity = AFFINITY_USEALL; break; + case OPT_THREADS: case 't': if (smp) { warn("-t ignored due to --smp\n"); @@ -380,6 +421,41 @@ static void sighand(int sig) mustshutdown = 1; } +struct params_stats { + struct params *receiver; + struct params *sender; +}; + +static void write_stats(FILE *f, void *data) +{ + struct params_stats *ps = data; + struct params *s, *r; + unsigned int i; + + fprintf(f, " \"num_threads\": %d,\n", num_threads); + fprintf(f, " \"thread\": {\n"); + for (i = 0; i < num_threads; i++) { + s = &ps->sender[i]; + r = &ps->receiver[i]; + fprintf(f, " \"%u\": {\n", i); + fprintf(f, " \"sender\": {\n"); + fprintf(f, " \"cpu\": %d,\n", s->cpu); + fprintf(f, " \"priority\": %d,\n", s->priority); + fprintf(f, " \"samples\": %d,\n", s->samples); + fprintf(f, " \"interval\": %ld\n", r->delay.tv_nsec/1000); + fprintf(f, " },\n"); + fprintf(f, " \"receiver\": {\n"); + fprintf(f, " \"cpu\": %d,\n", r->cpu); + fprintf(f, " \"priority\": %d,\n", r->priority); + fprintf(f, " \"min\": %d,\n", r->mindiff); + fprintf(f, " \"avg\": %.2f,\n", r->sumdiff/r->samples); + fprintf(f, " \"max\": %d\n", r->maxdiff); + fprintf(f, " }\n"); + fprintf(f, " }%s\n", i == num_threads - 1 ? "" : ","); + } + fprintf(f, " }\n"); +} + static void print_stat(FILE *fp, struct params *receiver, struct params *sender, int verbose, int quiet) { @@ -696,6 +772,14 @@ int main(int argc, char *argv[]) } } + if (strlen(outfile) != 0) { + struct params_stats ps = { + .receiver = receiver, + .sender = sender, + }; + rt_write_json(outfile, argc, argv, write_stats, &ps); + } + nosem: for (i = 0; i < num_threads; i++) semctl(receiver[i].semid, -1, IPC_RMID);