From patchwork Fri Dec 18 19:35: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: 345788 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 09AADC3526B for ; Fri, 18 Dec 2020 19:36:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1FAD23B75 for ; Fri, 18 Dec 2020 19:36:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgLRTgd (ORCPT ); Fri, 18 Dec 2020 14:36:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:34970 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbgLRTgc (ORCPT ); Fri, 18 Dec 2020 14:36:32 -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 15FA3AD4D; Fri, 18 Dec 2020 19:35:51 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC rt-tests v1 1/4] rt-tests: Rename error.h to rt-error.h Date: Fri, 18 Dec 2020 20:35:37 +0100 Message-Id: <20201218193540.6168-2-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218193540.6168-1-dwagner@suse.de> References: <20201218193540.6168-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/signaltest/signaltest.c | 2 +- src/sigwaittest/sigwaittest.c | 2 +- src/svsematest/svsematest.c | 3 ++- 13 files changed, 20 insertions(+), 18 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 2e392299fdc4..e41b8af127da 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/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 Dec 18 19:35: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: 345787 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 75065C2BBD5 for ; Fri, 18 Dec 2020 19:36:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40E9523B75 for ; Fri, 18 Dec 2020 19:36:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726365AbgLRTgd (ORCPT ); Fri, 18 Dec 2020 14:36:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:34982 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726241AbgLRTgd (ORCPT ); Fri, 18 Dec 2020 14:36:33 -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 78B8FAD89; Fri, 18 Dec 2020 19:35:51 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [RFC rt-tests v1 2/4] cyclictest: Move thread data to struct thread_param Date: Fri, 18 Dec 2020 20:35:38 +0100 Message-Id: <20201218193540.6168-3-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218193540.6168-1-dwagner@suse.de> References: <20201218193540.6168-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/cyclictest/cyclictest.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 9225e52aa982..c0e7600b4740 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -113,6 +113,9 @@ static char *policyname(int policy); /* Struct to transfer parameters to the thread */ struct thread_param { + pthread_t thread; + int threadstarted; + int tid; int prio; int policy; int mode; @@ -141,9 +144,6 @@ struct thread_stat { long *smis; long *hist_array; long *outliers; - pthread_t thread; - int threadstarted; - int tid; long reduce; long redmax; long cycleofmax; @@ -530,7 +530,7 @@ static void *timerthread(void *param) interval.tv_sec = par->interval / USEC_PER_SEC; interval.tv_nsec = (par->interval % USEC_PER_SEC) * 1000; - stat->tid = gettid(); + par->tid = gettid(); sigemptyset(&sigset); sigaddset(&sigset, par->signal); @@ -539,7 +539,7 @@ static void *timerthread(void *param) if (par->mode == MODE_CYCLIC) { sigev.sigev_notify = SIGEV_THREAD_ID | SIGEV_SIGNAL; sigev.sigev_signo = par->signal; - sigev.sigev_notify_thread_id = stat->tid; + sigev.sigev_notify_thread_id = par->tid; timer_create(par->clock, &sigev, &timer); tspec.it_interval = interval; } @@ -613,7 +613,7 @@ static void *timerthread(void *param) setitimer(ITIMER_REAL, &itimer, NULL); } - stat->threadstarted++; + par->threadstarted++; while (!shutdown) { @@ -719,7 +719,7 @@ static void *timerthread(void *param) shutdown++; pthread_mutex_lock(&break_thread_id_lock); if (break_thread_id == 0) { - break_thread_id = stat->tid; + break_thread_id = par->tid; tracemark("hit latency threshold (%llu > %d)", (unsigned long long) diff, tracelimit); break_thread_value = diff; @@ -795,7 +795,7 @@ static void *timerthread(void *param) /* switch to normal */ schedp.sched_priority = 0; sched_setscheduler(0, SCHED_OTHER, &schedp); - stat->threadstarted = -1; + par->threadstarted = -1; return NULL; } @@ -1298,7 +1298,7 @@ static void print_tids(struct thread_param *par[], int nthreads) printf("# Thread Ids:"); for (i = 0; i < nthreads; i++) - printf(" %05d", par[i]->stats->tid); + printf(" %05d", par[i]->tid); printf("\n"); } @@ -1412,7 +1412,7 @@ static void print_stat(FILE *fp, struct thread_param *par, int index, int verbos fmt = "T:%2d (%5d) P:%2d I:%ld C:%7lu " "Min:%7ld Act:%5ld Avg:%5ld Max:%8ld"; - fprintf(fp, fmt, index, stat->tid, par->prio, + fprintf(fp, fmt, index, par->tid, par->prio, par->interval, stat->cycles, stat->min, stat->act, stat->cycles ? (long)(stat->avg/stat->cycles) : 0, stat->max); @@ -1468,7 +1468,7 @@ static void rstat_print_stat(struct thread_param *par, int index, int verbose, i fmt = "T:%2d (%5d) P:%2d I:%ld C:%7lu " "Min:%7ld Act:%5ld Avg:%5ld Max:%8ld"; - dprintf(fd, fmt, index, stat->tid, par->prio, + dprintf(fd, fmt, index, par->tid, par->prio, par->interval, stat->cycles, stat->min, stat->act, stat->cycles ? (long)(stat->avg/stat->cycles) : 0, stat->max); @@ -1969,9 +1969,9 @@ int main(int argc, char **argv) stat->min = 1000000; stat->max = 0; stat->avg = 0.0; - stat->threadstarted = 1; stat->smi_count = 0; - status = pthread_create(&stat->thread, &attr, timerthread, par); + par->threadstarted = 1; + status = pthread_create(&par->thread, &attr, timerthread, par); if (status) fatal("failed to create thread %d: %s\n", i, strerror(status)); @@ -2041,10 +2041,10 @@ int main(int argc, char **argv) if (quiet) quiet = 2; for (i = 0; i < num_threads; i++) { - if (statistics[i]->threadstarted > 0) - pthread_kill(statistics[i]->thread, SIGTERM); - if (statistics[i]->threadstarted) { - pthread_join(statistics[i]->thread, NULL); + if (parameters[i]->threadstarted > 0) + pthread_kill(parameters[i]->thread, SIGTERM); + if (parameters[i]->threadstarted) { + pthread_join(parameters[i]->thread, NULL); if (quiet && !histogram) print_stat(stdout, parameters[i], i, 0, 0); }