From patchwork Tue Jan 26 09:14:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 371029 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 37507C433DB for ; Tue, 26 Jan 2021 18:43:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 152D222A84 for ; Tue, 26 Jan 2021 18:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390758AbhAZRUN (ORCPT ); Tue, 26 Jan 2021 12:20:13 -0500 Received: from mx2.suse.de ([195.135.220.15]:56108 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390860AbhAZJPx (ORCPT ); Tue, 26 Jan 2021 04:15:53 -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 7A5CFB27F; Tue, 26 Jan 2021 09:15:03 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v3 03/16] cyclictest: Simplify --smp vs --affinity vs --threads argument logic Date: Tue, 26 Jan 2021 10:14:47 +0100 Message-Id: <20210126091500.31735-4-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126091500.31735-1-dwagner@suse.de> References: <20210126091500.31735-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Allow each command line only to update one variable and do the final decission at the end of the parsing step. With this the order of the command line is not important. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 4c02f067fbad..b5cca3ae166b 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -880,14 +880,13 @@ static int timermode = TIMER_ABSTIME; static int use_system; static int priority; static int policy = SCHED_OTHER; /* default policy if not specified */ -static int num_threads = 1; +static int num_threads = -1; static int max_cycles; static int clocksel = 0; static int quiet; static int interval = DEFAULT_INTERVAL; static int distance = -1; static struct bitmask *affinity_mask = NULL; -static int smp = 0; static int clocksources[] = { CLOCK_MONOTONIC, @@ -953,7 +952,7 @@ enum option_values { static void process_options(int argc, char *argv[], int max_cpus) { int error = 0; - int option_affinity = 0; + int smp = 0; for (;;) { int option_index = 0; @@ -1008,10 +1007,6 @@ static void process_options(int argc, char *argv[], int max_cpus) switch (c) { case 'a': case OPT_AFFINITY: - option_affinity = 1; - /* smp sets AFFINITY_USEALL in OPT_SMP */ - if (smp) - break; if (optarg) { parse_cpumask(optarg, max_cpus, &affinity_mask); } else if (optind < argc && @@ -1019,8 +1014,6 @@ static void process_options(int argc, char *argv[], int max_cpus) argv[optind][0] == '0' || argv[optind][0] == '!')) { parse_cpumask(argv[optind], max_cpus, &affinity_mask); - } else { - num_threads = -1; } break; case 'A': @@ -1108,22 +1101,14 @@ static void process_options(int argc, char *argv[], int max_cpus) case OPT_SYSTEM: use_system = MODE_SYS_OFFSET; break; case 'S': - case OPT_SMP: /* SMP testing */ - smp = 1; - num_threads = -1; /* update after parsing */ - break; + case OPT_SMP: + smp = 1; break; case 't': case OPT_THREADS: - if (smp) { - warn("-t ignored due to smp mode\n"); - break; - } if (optarg != NULL) num_threads = atoi(optarg); else if (optind < argc && atoi(argv[optind])) num_threads = atoi(argv[optind]); - else - num_threads = -1; /* update after parsing */ break; case OPT_TRIGGER: trigger = atoi(optarg); @@ -1179,13 +1164,10 @@ static void process_options(int argc, char *argv[], int max_cpus) use_nanosleep = MODE_CLOCK_NANOSLEEP; } - if (option_affinity && smp) { - warn("-a ignored due to smp mode\n"); - if (affinity_mask) { - numa_bitmask_free(affinity_mask); - affinity_mask = NULL; - } - } + if (smp && num_threads != -1) + warn("--threads overwrites smp mode\n"); + if (smp && affinity_mask) + warn("--affinity overwrites smp mode\n"); if (smi) { if (affinity_mask) From patchwork Tue Jan 26 09:14:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 371030 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 AF10CC433E6 for ; Tue, 26 Jan 2021 18:42:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7329822B3B for ; Tue, 26 Jan 2021 18:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390831AbhAZRUU (ORCPT ); Tue, 26 Jan 2021 12:20:20 -0500 Received: from mx2.suse.de ([195.135.220.15]:57472 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728846AbhAZJRZ (ORCPT ); Tue, 26 Jan 2021 04:17:25 -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 356FDB7DB; Tue, 26 Jan 2021 09:15:04 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v3 05/16] signaltest: Simplify --smp vs --affinity vs --threads argument logic Date: Tue, 26 Jan 2021 10:14:49 +0100 Message-Id: <20210126091500.31735-6-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126091500.31735-1-dwagner@suse.de> References: <20210126091500.31735-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Allow each command line only to update one variable and do the final decission at the end of the parsing step. With this the order of the command line is not important. Signed-off-by: Daniel Wagner --- src/signaltest/signaltest.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index e19fc9a740a9..61420fa13347 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -210,7 +210,6 @@ static struct bitmask *affinity_mask = NULL; static void process_options(int argc, char *argv[], unsigned int max_cpus) { int error = 0; - int numa = 0; int smp = 0; for (;;) { @@ -236,10 +235,6 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus) break; switch (c) { case 'a': - /* smp sets AFFINITY_USEALL in OPT_SMP */ - if (smp) - break; - numa = 1; if (optarg) { parse_cpumask(optarg, max_cpus, &affinity_mask); } else if (optind < argc && @@ -261,12 +256,7 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus) case 'm': lockall = 1; break; case 'p': priority = atoi(optarg); break; case 'q': quiet = 1; break; - case 'S': - if (numa) - fatal("numa and smp options are mutually exclusive\n"); - smp = 1; - num_threads = -1; /* update after parsing */ - break; + case 'S': smp = 1; break; case 't': num_threads = atoi(optarg); break; case 'v': verbose = 1; break; } @@ -278,15 +268,16 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus) if (priority < 0 || priority > 99) error = 1; - if (num_threads == -1) - num_threads = get_available_cpus(affinity_mask); + if (smp) { + if (affinity_mask) + warn("--affinity overwrites smp mode\n"); + else + num_threads = get_available_cpus(affinity_mask); + } if (num_threads < 2) error = 1; - if (smp && affinity_mask) - warn("-a ignored due to smp mode\n"); - if (error) { if (affinity_mask) numa_bitmask_free(affinity_mask); From patchwork Tue Jan 26 09:14:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 371031 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 75F22C433DB for ; Tue, 26 Jan 2021 18:42:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 47FC822A84 for ; Tue, 26 Jan 2021 18:42:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390903AbhAZRUY (ORCPT ); Tue, 26 Jan 2021 12:20:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:57502 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728919AbhAZJRZ (ORCPT ); Tue, 26 Jan 2021 04:17:25 -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 696EDB8F3; Tue, 26 Jan 2021 09:15:05 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v3 09/16] rt-numa: Remove max_cpus argument from parse_cpusmask Date: Tue, 26 Jan 2021 10:14:53 +0100 Message-Id: <20210126091500.31735-10-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126091500.31735-1-dwagner@suse.de> References: <20210126091500.31735-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Remove usused max_cpus argument from parse_cpumask(). Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 4 ++-- src/include/rt-numa.h | 2 +- src/lib/rt-numa.c | 6 +++--- src/oslat/oslat.c | 3 +-- src/signaltest/signaltest.c | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 4e30abbe6035..acd456bd4c4d 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1008,12 +1008,12 @@ static void process_options(int argc, char *argv[], int max_cpus) case 'a': case OPT_AFFINITY: if (optarg) { - parse_cpumask(optarg, max_cpus, &affinity_mask); + parse_cpumask(optarg, &affinity_mask); } else if (optind < argc && (atoi(argv[optind]) || argv[optind][0] == '0' || argv[optind][0] == '!')) { - parse_cpumask(argv[optind], max_cpus, &affinity_mask); + parse_cpumask(argv[optind], &affinity_mask); } break; case 'A': diff --git a/src/include/rt-numa.h b/src/include/rt-numa.h index 189da3a804e1..446ce54a6ba2 100644 --- a/src/include/rt-numa.h +++ b/src/include/rt-numa.h @@ -7,6 +7,6 @@ int get_available_cpus(struct bitmask *cpumask); int cpu_for_thread(int thread_num, int max_cpus, struct bitmask *cpumask); -int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask); +int parse_cpumask(char *str, struct bitmask **cpumask); #endif diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c index b1bbb8c8052c..3a8441d5151c 100644 --- a/src/lib/rt-numa.c +++ b/src/lib/rt-numa.c @@ -85,7 +85,7 @@ int cpu_for_thread(int thread_num, int max_cpus, struct bitmask *cpumask) * the user supplied affinity mask and the affinity mask from the run * time environment */ -static void use_current_cpuset(int max_cpus, struct bitmask *cpumask) +static void use_current_cpuset(struct bitmask *cpumask) { struct bitmask *curmask; int i; @@ -106,7 +106,7 @@ static void use_current_cpuset(int max_cpus, struct bitmask *cpumask) numa_bitmask_free(curmask); } -int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask) +int parse_cpumask(char *str, struct bitmask **cpumask) { struct bitmask *mask; @@ -120,7 +120,7 @@ int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask) return 0; } - use_current_cpuset(max_cpus, mask); + use_current_cpuset(mask); *cpumask = mask; return 0; diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c index 5b7e0d5b5d5c..0811079d9f04 100644 --- a/src/oslat/oslat.c +++ b/src/oslat/oslat.c @@ -716,7 +716,6 @@ int main(int argc, char *argv[]) struct thread *threads; int i, n_cores; struct bitmask *cpu_set = NULL; - int max_cpus = sysconf(_SC_NPROCESSORS_ONLN); #ifdef FRC_MISSING printf("This architecture is not yet supported. " @@ -743,7 +742,7 @@ int main(int argc, char *argv[]) if (!g.cpu_list) g.cpu_list = strdup("all"); - if (parse_cpumask(g.cpu_list, max_cpus, &cpu_set)) + if (parse_cpumask(g.cpu_list, &cpu_set)) exit(1); n_cores = numa_bitmask_weight(cpu_set); diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index 2ea5e6b58946..0d189483753d 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -236,12 +236,12 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus) switch (c) { case 'a': if (optarg) { - parse_cpumask(optarg, max_cpus, &affinity_mask); + parse_cpumask(optarg, &affinity_mask); } else if (optind < argc && (atoi(argv[optind]) || argv[optind][0] == '0' || argv[optind][0] == '!')) { - parse_cpumask(argv[optind], max_cpus, &affinity_mask); + parse_cpumask(argv[optind], &affinity_mask); } if (verbose) From patchwork Tue Jan 26 09:14:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 371033 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 6B390C433DB for ; Tue, 26 Jan 2021 18:41:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 40C8E22286 for ; Tue, 26 Jan 2021 18:41:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391001AbhAZRUm (ORCPT ); Tue, 26 Jan 2021 12:20:42 -0500 Received: from mx2.suse.de ([195.135.220.15]:57548 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731816AbhAZJR0 (ORCPT ); Tue, 26 Jan 2021 04:17:26 -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 55C27B282; Tue, 26 Jan 2021 09:15:06 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v3 12/16] rt-numa: Use CPU_SETSIZE as upper loop limit Date: Tue, 26 Jan 2021 10:14:56 +0100 Message-Id: <20210126091500.31735-13-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126091500.31735-1-dwagner@suse.de> References: <20210126091500.31735-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The cpeset might not be dense, so user the CPU_SETSIZE as upper limit. Signed-off-by: Daniel Wagner --- src/lib/rt-numa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c index 3a8441d5151c..45d4f1193d5f 100644 --- a/src/lib/rt-numa.c +++ b/src/lib/rt-numa.c @@ -60,7 +60,7 @@ static int cpu_for_thread_ua(int thread_num, int max_cpus) num_cpus = CPU_COUNT(&cpuset); m = thread_num % num_cpus; - for (i = 0, cpu = 0; i < max_cpus; i++) { + for (i = 0, cpu = 0; i < CPU_SETSIZE; i++) { if (CPU_ISSET(i, &cpuset)) { if (cpu == m) return i; From patchwork Tue Jan 26 09:14:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 371035 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 255DCC43331 for ; Tue, 26 Jan 2021 17:20:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0C77230FD for ; Tue, 26 Jan 2021 17:20:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390958AbhAZRUe (ORCPT ); Tue, 26 Jan 2021 12:20:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:57552 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731028AbhAZJR0 (ORCPT ); Tue, 26 Jan 2021 04:17:26 -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 A5DB5B284; Tue, 26 Jan 2021 09:15:06 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v3 13/16] rt-numa: Remove used max_cpus argument from cpu_for_thread() Date: Tue, 26 Jan 2021 10:14:57 +0100 Message-Id: <20210126091500.31735-14-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126091500.31735-1-dwagner@suse.de> References: <20210126091500.31735-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org There is no need to pass in the max_cpus anymore. Thus remove the argument. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 2 +- src/include/rt-numa.h | 2 +- src/lib/rt-numa.c | 10 +++++----- src/signaltest/signaltest.c | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 366b2aaaa9f8..7a0501031857 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1882,7 +1882,7 @@ int main(int argc, char **argv) if (status != 0) fatal("error from pthread_attr_init for thread %d: %s\n", i, strerror(status)); - cpu = cpu_for_thread(i, max_cpus, affinity_mask); + cpu = cpu_for_thread(i, affinity_mask); if (verbose) printf("Thread %d using cpu %d.\n", i, cpu); diff --git a/src/include/rt-numa.h b/src/include/rt-numa.h index 446ce54a6ba2..405e57869735 100644 --- a/src/include/rt-numa.h +++ b/src/include/rt-numa.h @@ -5,7 +5,7 @@ #include int get_available_cpus(struct bitmask *cpumask); -int cpu_for_thread(int thread_num, int max_cpus, struct bitmask *cpumask); +int cpu_for_thread(int thread_num, struct bitmask *cpumask); int parse_cpumask(char *str, struct bitmask **cpumask); diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c index 45d4f1193d5f..04f2e9adb4b1 100644 --- a/src/lib/rt-numa.c +++ b/src/lib/rt-numa.c @@ -21,7 +21,7 @@ int get_available_cpus(struct bitmask *cpumask) return numa_num_task_cpus(); } -static int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask) +static int cpu_for_thread_sp(int thread_num, struct bitmask *cpumask) { unsigned int m, cpu, i, num_cpus; @@ -44,7 +44,7 @@ static int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpuma return 0; } -static int cpu_for_thread_ua(int thread_num, int max_cpus) +static int cpu_for_thread_ua(int thread_num) { int res, num_cpus, i, m, cpu; pthread_t thread; @@ -72,12 +72,12 @@ static int cpu_for_thread_ua(int thread_num, int max_cpus) return 0; } -int cpu_for_thread(int thread_num, int max_cpus, struct bitmask *cpumask) +int cpu_for_thread(int thread_num, struct bitmask *cpumask) { if (cpumask) - return cpu_for_thread_sp(thread_num, max_cpus, cpumask); + return cpu_for_thread_sp(thread_num, cpumask); else - return cpu_for_thread_ua(thread_num, max_cpus); + return cpu_for_thread_ua(thread_num); } /* diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index 3ca26fb373bb..5427db7f8d85 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -320,7 +320,6 @@ int main(int argc, char **argv) struct thread_stat *stat; int i, ret = -1; int status, cpu; - int max_cpus = sysconf(_SC_NPROCESSORS_ONLN); if (numa_available() == -1) fatal("Couldn't initialize libnuma"); @@ -373,7 +372,7 @@ int main(int argc, char **argv) par[i].bufmsk = VALBUF_SIZE - 1; } - cpu = cpu_for_thread(i, max_cpus, affinity_mask); + cpu = cpu_for_thread(i, affinity_mask); if (verbose) printf("Thread %d using cpu %d.\n", i, cpu); From patchwork Tue Jan 26 09:14:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 371032 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 B32EDC433E6 for ; Tue, 26 Jan 2021 18:42:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71A1122228 for ; Tue, 26 Jan 2021 18:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390925AbhAZRU0 (ORCPT ); Tue, 26 Jan 2021 12:20:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:57554 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730571AbhAZJR0 (ORCPT ); Tue, 26 Jan 2021 04:17:26 -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 F0D7AB28A; Tue, 26 Jan 2021 09:15:06 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v3 14/16] cyclictest: Remove max cpus used verbose information Date: Tue, 26 Jan 2021 10:14:58 +0100 Message-Id: <20210126091500.31735-15-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126091500.31735-1-dwagner@suse.de> References: <20210126091500.31735-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Since we always print the thread placement in verbose mode now, there is no need to print the max_cpus anymore. With the last of max_cpus gone, we can also remove the sysconf() call. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 7a0501031857..8356786a80bb 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1697,8 +1697,6 @@ int main(int argc, char **argv) int signum = SIGALRM; int mode; int cpu; - int max_cpus = sysconf(_SC_NPROCESSORS_CONF); - int online_cpus = sysconf(_SC_NPROCESSORS_ONLN); int i, ret = -1; int status; void *stack; @@ -1713,11 +1711,6 @@ int main(int argc, char **argv) if (check_privs()) exit(EXIT_FAILURE); - if (verbose) { - printf("Max CPUs = %d\n", max_cpus); - printf("Online CPUs = %d\n", online_cpus); - } - /* Restrict the main pid to the affinity specified by the user */ if (affinity_mask) { int res; @@ -1726,10 +1719,6 @@ int main(int argc, char **argv) res = numa_sched_setaffinity(getpid(), affinity_mask); if (res != 0) warn("Couldn't setaffinity in main thread: %s\n", strerror(errno)); - - if (verbose) - printf("Using %u cpus.\n", - numa_bitmask_weight(affinity_mask)); } if (trigger) { From patchwork Tue Jan 26 09:14:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 371034 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 8C96AC433DB for ; Tue, 26 Jan 2021 17:21:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6406720829 for ; Tue, 26 Jan 2021 17:21:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730571AbhAZRUt (ORCPT ); Tue, 26 Jan 2021 12:20:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:57504 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388227AbhAZJT2 (ORCPT ); Tue, 26 Jan 2021 04:19:28 -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 4906CB291; Tue, 26 Jan 2021 09:15:07 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v3 15/16] cyclictest: Remove unecessary local variable Date: Tue, 26 Jan 2021 10:14:59 +0100 Message-Id: <20210126091500.31735-16-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126091500.31735-1-dwagner@suse.de> References: <20210126091500.31735-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The return value is not used, thus we can avoid the unussed local variable. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 8356786a80bb..f912bcf82def 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1713,18 +1713,13 @@ int main(int argc, char **argv) /* Restrict the main pid to the affinity specified by the user */ if (affinity_mask) { - int res; - errno = 0; - res = numa_sched_setaffinity(getpid(), affinity_mask); - if (res != 0) + if (numa_sched_setaffinity(getpid(), affinity_mask) != 0) warn("Couldn't setaffinity in main thread: %s\n", strerror(errno)); } if (trigger) { - int retval; - retval = trigger_init(); - if (retval != 0) { + if (trigger_init() != 0) { fprintf(stderr, "trigger_init() failed\n"); exit(EXIT_FAILURE); } From patchwork Tue Jan 26 09:15:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 371042 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 D9FD4C433E6 for ; Tue, 26 Jan 2021 09:23:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C3A823104 for ; Tue, 26 Jan 2021 09:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727430AbhAZJXD (ORCPT ); Tue, 26 Jan 2021 04:23:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:58998 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389533AbhAZJT4 (ORCPT ); Tue, 26 Jan 2021 04:19:56 -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 930A3B292; Tue, 26 Jan 2021 09:15:07 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v3 16/16] rt-tests: Rename error.h to rt-error.h Date: Tue, 26 Jan 2021 10:15:00 +0100 Message-Id: <20210126091500.31735-17-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126091500.31735-1-dwagner@suse.de> References: <20210126091500.31735-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 f912bcf82def..c4b2369bee6b 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 6dcfd6074085..71cde5781499 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