From patchwork Wed Feb 10 13:34:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 380572 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 C0042C433E6 for ; Wed, 10 Feb 2021 13:35:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9159A64D73 for ; Wed, 10 Feb 2021 13:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231307AbhBJNfn (ORCPT ); Wed, 10 Feb 2021 08:35:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:50086 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbhBJNfi (ORCPT ); Wed, 10 Feb 2021 08:35:38 -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 10EB4AC97; Wed, 10 Feb 2021 13:34:55 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 01/16] cyclictest: Use numa API directly Date: Wed, 10 Feb 2021 14:34:35 +0100 Message-Id: <20210210133450.6991-2-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-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 for small libnuma wrappers functions as we always use libnuma. Remove them and get rid of rt_numa.h, so there is no confusion with rt-numa.h anymore. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 43 +++++++++-------- src/cyclictest/rt_numa.h | 96 ------------------------------------- 2 files changed, 24 insertions(+), 115 deletions(-) delete mode 100644 src/cyclictest/rt_numa.h diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 99846e78526f..6009ff2a83bc 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -33,10 +33,10 @@ #include #include #include -#include "rt_numa.h" #include "rt-utils.h" #include "rt-numa.h" +#include "error.h" #include @@ -514,9 +514,9 @@ static void *timerthread(void *param) memset(&stop, 0, sizeof(stop)); - /* if we're running in numa mode, set our memory node */ - if (par->node != -1) - rt_numa_set_numa_run_on_node(par->node, par->cpu); + if (numa_run_on_node(par->node)) + warn("Could not set NUMA node %d for thread %d: %s\n", + par->node, par->cpu, strerror(errno)); if (par->cpu != -1) { CPU_ZERO(&mask); @@ -1251,7 +1251,7 @@ static void process_options(int argc, char *argv[], int max_cpus) } if (error) { if (affinity_mask) - rt_bitmask_free(affinity_mask); + numa_bitmask_free(affinity_mask); display_help(1); } } @@ -1907,7 +1907,9 @@ int main(int argc, char **argv) printf("Thread %d using cpu %d.\n", i, cpu); /* find the memory node associated with the cpu i */ - node = rt_numa_numa_node_of_cpu(cpu); + node = numa_node_of_cpu(cpu); + if (node == -1) + fatal("Invalid NUMA node selected via affinity mask\n"); /* get the stack size set for this thread */ if (pthread_attr_getstack(&attr, &currstk, &stksize)) @@ -1918,7 +1920,10 @@ int main(int argc, char **argv) stksize = PTHREAD_STACK_MIN * 2; /* allocate memory for a stack on appropriate node */ - stack = rt_numa_numa_alloc_onnode(stksize, node, cpu); + stack = numa_alloc_onnode(stksize, node); + if (!stack) + fatal("failed to allocate %d bytes on node %d for cpu %d\n", + stksize, node, cpu); /* touch the stack pages to pre-fault them in */ memset(stack, 0, stksize); @@ -1929,13 +1934,13 @@ int main(int argc, char **argv) i, stack+stksize); /* allocate the thread's parameter block */ - parameters[i] = par = threadalloc(sizeof(struct thread_param), node); + parameters[i] = par = numa_alloc_onnode(sizeof(struct thread_param), node); if (par == NULL) fatal("error allocating thread_param struct for thread %d\n", i); memset(par, 0, sizeof(struct thread_param)); /* allocate the thread's statistics block */ - statistics[i] = stat = threadalloc(sizeof(struct thread_stat), node); + statistics[i] = stat = numa_alloc_onnode(sizeof(struct thread_stat), node); if (stat == NULL) fatal("error allocating thread status struct for thread %d\n", i); memset(stat, 0, sizeof(struct thread_stat)); @@ -1944,8 +1949,8 @@ int main(int argc, char **argv) if (histogram) { int bufsize = histogram * sizeof(long); - stat->hist_array = threadalloc(bufsize, node); - stat->outliers = threadalloc(bufsize, node); + stat->hist_array = numa_alloc_onnode(bufsize, node); + stat->outliers = numa_alloc_onnode(bufsize, node); if (stat->hist_array == NULL || stat->outliers == NULL) fatal("failed to allocate histogram of size %d on node %d\n", histogram, i); @@ -1955,14 +1960,14 @@ int main(int argc, char **argv) if (verbose) { int bufsize = VALBUF_SIZE * sizeof(long); - stat->values = threadalloc(bufsize, node); + stat->values = numa_alloc_onnode(bufsize, node); if (!stat->values) goto outall; memset(stat->values, 0, bufsize); par->bufmsk = VALBUF_SIZE - 1; if (smi) { int bufsize = VALBUF_SIZE * sizeof(long); - stat->smis = threadalloc(bufsize, node); + stat->smis = numa_alloc_onnode(bufsize, node); if (!stat->smis) goto outall; memset(stat->smis, 0, bufsize); @@ -2077,7 +2082,7 @@ int main(int argc, char **argv) print_stat(stdout, parameters[i], i, 0, 0); } if (statistics[i]->values) - threadfree(statistics[i]->values, VALBUF_SIZE*sizeof(long), parameters[i]->node); + numa_free(statistics[i]->values, VALBUF_SIZE*sizeof(long)); } if (trigger) @@ -2086,8 +2091,8 @@ int main(int argc, char **argv) if (histogram) { print_hist(parameters, num_threads); for (i = 0; i < num_threads; i++) { - threadfree(statistics[i]->hist_array, histogram*sizeof(long), parameters[i]->node); - threadfree(statistics[i]->outliers, histogram*sizeof(long), parameters[i]->node); + numa_free(statistics[i]->hist_array, histogram*sizeof(long)); + numa_free(statistics[i]->outliers, histogram*sizeof(long)); } } @@ -2103,14 +2108,14 @@ int main(int argc, char **argv) for (i=0; i < num_threads; i++) { if (!statistics[i]) continue; - threadfree(statistics[i], sizeof(struct thread_stat), parameters[i]->node); + numa_free(statistics[i], sizeof(struct thread_stat)); } outpar: for (i = 0; i < num_threads; i++) { if (!parameters[i]) continue; - threadfree(parameters[i], sizeof(struct thread_param), parameters[i]->node); + numa_free(parameters[i], sizeof(struct thread_param)); } out: /* close any tracer file descriptors */ @@ -2125,7 +2130,7 @@ int main(int argc, char **argv) close(latency_target_fd); if (affinity_mask) - rt_bitmask_free(affinity_mask); + numa_bitmask_free(affinity_mask); /* Remove running status shared memory file if it exists */ if (rstat_fd >= 0) diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h deleted file mode 100644 index 8d02f419ed6d..000000000000 --- a/src/cyclictest/rt_numa.h +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * A numa library for cyclictest. - * - * (C) 2010 John Kacur - * (C) 2010 Clark Williams - * - */ - -#ifndef _RT_NUMA_H -#define _RT_NUMA_H - -#include "rt-utils.h" -#include "error.h" - -#include - -static void * -threadalloc(size_t size, int node) -{ - if (node == -1) - return malloc(size); - return numa_alloc_onnode(size, node); -} - -static void -threadfree(void *ptr, size_t size, int node) -{ - if (node == -1) - free(ptr); - else - numa_free(ptr, size); -} - -static void rt_numa_set_numa_run_on_node(int node, int cpu) -{ - int res; - res = numa_run_on_node(node); - if (res) - warn("Could not set NUMA node %d for thread %d: %s\n", - node, cpu, strerror(errno)); - return; -} - -static void *rt_numa_numa_alloc_onnode(size_t size, int node, int cpu) -{ - void *stack; - stack = numa_alloc_onnode(size, node); - if (stack == NULL) - fatal("failed to allocate %d bytes on node %d for cpu %d\n", - size, node, cpu); - return stack; -} - -/* - * Use new bit mask CPU affinity behavior - */ -static int rt_numa_numa_node_of_cpu(int cpu) -{ - int node; - node = numa_node_of_cpu(cpu); - if (node == -1) - fatal("invalid cpu passed to numa_node_of_cpu(%d)\n", cpu); - return node; -} - -static inline unsigned int rt_numa_bitmask_isbitset( const struct bitmask *mask, - unsigned long i) -{ - return numa_bitmask_isbitset(mask,i); -} - -static inline struct bitmask* rt_numa_parse_cpustring(const char* s, - int max_cpus) -{ - return numa_parse_cpustring_all(s); -} - -static inline void rt_bitmask_free(struct bitmask *mask) -{ - numa_bitmask_free(mask); -} - -/** Returns number of bits set in mask. */ -static inline unsigned int rt_numa_bitmask_count(const struct bitmask *mask) -{ - unsigned int num_bits = 0, i; - for (i = 0; i < mask->size; i++) { - if (rt_numa_bitmask_isbitset(mask, i)) - num_bits++; - } - /* Could stash this instead of recomputing every time. */ - return num_bits; -} - -#endif /* _RT_NUMA_H */ From patchwork Wed Feb 10 13:34:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 381420 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 0345EC433E9 for ; Wed, 10 Feb 2021 13:36:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C229564E87 for ; Wed, 10 Feb 2021 13:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231208AbhBJNfi (ORCPT ); Wed, 10 Feb 2021 08:35:38 -0500 Received: from mx2.suse.de ([195.135.220.15]:50098 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbhBJNfh (ORCPT ); Wed, 10 Feb 2021 08:35:37 -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 5AA55AEB9; Wed, 10 Feb 2021 13:34:55 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 02/16] cyclictest: Mimic --smp behavior with --affinity Date: Wed, 10 Feb 2021 14:34:36 +0100 Message-Id: <20210210133450.6991-3-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Let --affinity without an argument behave in the same way as --smp. Run a thread on each CPU. This makes cyclictest behave as the rest of the rt-tests when --affinity is used. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 6009ff2a83bc..4c02f067fbad 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1019,6 +1019,8 @@ 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': From patchwork Wed Feb 10 13:34:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 381419 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 32B57C4332D for ; Wed, 10 Feb 2021 13:36:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 007F364E7A for ; Wed, 10 Feb 2021 13:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbhBJNfp (ORCPT ); Wed, 10 Feb 2021 08:35:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:50110 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbhBJNfi (ORCPT ); Wed, 10 Feb 2021 08:35:38 -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 A3BB9AFC6; Wed, 10 Feb 2021 13:34:55 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 03/16] cyclictest: Simplify --smp vs --affinity vs --threads argument logic Date: Wed, 10 Feb 2021 14:34:37 +0100 Message-Id: <20210210133450.6991-4-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-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 Wed Feb 10 13:34:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 380570 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 975E4C433E0 for ; Wed, 10 Feb 2021 13:36:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66CDA64E15 for ; Wed, 10 Feb 2021 13:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbhBJNfq (ORCPT ); Wed, 10 Feb 2021 08:35:46 -0500 Received: from mx2.suse.de ([195.135.220.15]:50122 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230347AbhBJNfi (ORCPT ); Wed, 10 Feb 2021 08:35:38 -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 EECDEAFCE; Wed, 10 Feb 2021 13:34:55 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 04/16] signaltest: Use affinity_mask for steering thread placement Date: Wed, 10 Feb 2021 14:34:38 +0100 Message-Id: <20210210133450.6991-5-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org We don't need an extra variable to track the state if a bitmask is available or not. Check directly if the mask is usable. Signed-off-by: Daniel Wagner --- src/signaltest/signaltest.c | 44 ++++++++----------------------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index b3a82f8c4f65..e19fc9a740a9 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -205,15 +205,13 @@ static int verbose; static int quiet; static int lockall; static struct bitmask *affinity_mask = NULL; -static int smp = 0; -static int setaffinity = AFFINITY_UNSPECIFIED; /* Process commandline options */ static void process_options(int argc, char *argv[], unsigned int max_cpus) { - int option_affinity = 0; int error = 0; int numa = 0; + int smp = 0; for (;;) { int option_index = 0; @@ -238,26 +236,19 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus) break; switch (c) { case 'a': - option_affinity = 1; /* smp sets AFFINITY_USEALL in OPT_SMP */ if (smp) break; numa = 1; if (optarg) { parse_cpumask(optarg, max_cpus, &affinity_mask); - setaffinity = AFFINITY_SPECIFIED; } else if (optind < argc && (atoi(argv[optind]) || argv[optind][0] == '0' || argv[optind][0] == '!')) { parse_cpumask(argv[optind], max_cpus, &affinity_mask); - setaffinity = AFFINITY_SPECIFIED; - } else { - setaffinity = AFFINITY_USEALL; } - if (setaffinity == AFFINITY_SPECIFIED && !affinity_mask) - display_help(1); if (verbose) printf("Using %u cpus.\n", numa_bitmask_weight(affinity_mask)); @@ -275,7 +266,6 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus) fatal("numa and smp options are mutually exclusive\n"); smp = 1; num_threads = -1; /* update after parsing */ - setaffinity = AFFINITY_USEALL; break; case 't': num_threads = atoi(optarg); break; case 'v': verbose = 1; break; @@ -294,16 +284,8 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus) if (num_threads < 2) error = 1; - /* if smp wasn't requested, test for numa automatically */ - if (!smp) { - if (setaffinity == AFFINITY_UNSPECIFIED) - setaffinity = AFFINITY_USEALL; - } - - if (option_affinity) { - if (smp) - warn("-a ignored due to smp mode\n"); - } + if (smp && affinity_mask) + warn("-a ignored due to smp mode\n"); if (error) { if (affinity_mask) @@ -365,7 +347,7 @@ int main(int argc, char **argv) } /* Restrict the main pid to the affinity specified by the user */ - if (affinity_mask != NULL) { + if (affinity_mask) { int res; errno = 0; @@ -400,21 +382,13 @@ int main(int argc, char **argv) par[i].bufmsk = VALBUF_SIZE - 1; } - switch (setaffinity) { - case AFFINITY_UNSPECIFIED: - cpu = -1; - break; - case AFFINITY_SPECIFIED: + if (affinity_mask) cpu = cpu_for_thread_sp(i, max_cpus, affinity_mask); - if (verbose) - printf("Thread %d using cpu %d.\n", i, cpu); - break; - case AFFINITY_USEALL: + else cpu = cpu_for_thread_ua(i, max_cpus); - break; - default: - cpu = -1; - } + + if (verbose) + printf("Thread %d using cpu %d.\n", i, cpu); par[i].id = i; par[i].prio = priority; From patchwork Wed Feb 10 13:34:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 380568 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 0B063C433DB for ; Wed, 10 Feb 2021 13:37:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B82AB64E77 for ; Wed, 10 Feb 2021 13:37:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231695AbhBJNgw (ORCPT ); Wed, 10 Feb 2021 08:36:52 -0500 Received: from mx2.suse.de ([195.135.220.15]:50472 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbhBJNgT (ORCPT ); Wed, 10 Feb 2021 08:36:19 -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 436D4AFCF; Wed, 10 Feb 2021 13:34:56 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 05/16] signaltest: Simplify --smp vs --affinity vs --threads argument logic Date: Wed, 10 Feb 2021 14:34:39 +0100 Message-Id: <20210210133450.6991-6-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-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 Wed Feb 10 13:34:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 381417 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 B8BC5C433E6 for ; Wed, 10 Feb 2021 13:36:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7608B64E79 for ; Wed, 10 Feb 2021 13:36:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbhBJNgk (ORCPT ); Wed, 10 Feb 2021 08:36:40 -0500 Received: from mx2.suse.de ([195.135.220.15]:50470 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbhBJNgT (ORCPT ); Wed, 10 Feb 2021 08:36:19 -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 933EFAFF3; Wed, 10 Feb 2021 13:34:56 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 06/16] rt-numa: Remove unused definitions and numa_initialize() Date: Wed, 10 Feb 2021 14:34:40 +0100 Message-Id: <20210210133450.6991-7-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org There is no user left of the AFFINITY_* enum. Remove them. Also there is no need for numa_initialize() to prodect from being called several times. We can safely initialize libnuma at the begin of each program. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 2 +- src/include/rt-numa.h | 8 -------- src/lib/rt-numa.c | 15 --------------- src/signaltest/signaltest.c | 2 +- 4 files changed, 2 insertions(+), 25 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index b5cca3ae166b..3c6773c1dbb5 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1705,7 +1705,7 @@ int main(int argc, char **argv) void *currstk; size_t stksize; - if (numa_initialize()) + if (numa_available() == -1) fatal("Couldn't initialize libnuma"); process_options(argc, argv, max_cpus); diff --git a/src/include/rt-numa.h b/src/include/rt-numa.h index ca86a45dab3a..54f5c3a240e9 100644 --- a/src/include/rt-numa.h +++ b/src/include/rt-numa.h @@ -4,14 +4,6 @@ #include -enum { - AFFINITY_UNSPECIFIED, - AFFINITY_SPECIFIED, - AFFINITY_USEALL -}; - -int numa_initialize(void); - int get_available_cpus(struct bitmask *cpumask); int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask); int cpu_for_thread_ua(int thread_num, int max_cpus); diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c index 33fddba4358e..fa83eae61084 100644 --- a/src/lib/rt-numa.c +++ b/src/lib/rt-numa.c @@ -13,21 +13,6 @@ #include "error.h" #include "rt-numa.h" -/* numa_available() must be called before any other calls to the numa library */ -int numa_initialize(void) -{ - static int is_initialized; - - if (is_initialized == 1) - return 0; - - if (numa_available() == -1) - return -1; - - is_initialized = 1; - return 0; -} - int get_available_cpus(struct bitmask *cpumask) { if (cpumask) diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index 61420fa13347..41ebb2c87a2f 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -322,7 +322,7 @@ int main(int argc, char **argv) int status, cpu; int max_cpus = sysconf(_SC_NPROCESSORS_ONLN); - if (numa_initialize()) + if (numa_available() == -1) fatal("Couldn't initialize libnuma"); process_options(argc, argv, max_cpus); From patchwork Wed Feb 10 13:34:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 380569 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 CDC58C433E9 for ; Wed, 10 Feb 2021 13:36:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9054964E79 for ; Wed, 10 Feb 2021 13:36:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbhBJNgp (ORCPT ); Wed, 10 Feb 2021 08:36:45 -0500 Received: from mx2.suse.de ([195.135.220.15]:50474 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231428AbhBJNgT (ORCPT ); Wed, 10 Feb 2021 08:36:19 -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 DFEAAAFFD; Wed, 10 Feb 2021 13:34:56 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 07/16] rt-numa: Add generic cpu_for_thread() helper Date: Wed, 10 Feb 2021 14:34:41 +0100 Message-Id: <20210210133450.6991-8-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org Add an simpler wrapper which calls the right implementation depending on if the cpumask is valid or not. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 6 +----- src/include/rt-numa.h | 3 +-- src/lib/rt-numa.c | 13 ++++++++++--- src/signaltest/signaltest.c | 6 +----- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 3c6773c1dbb5..4e30abbe6035 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1882,11 +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)); - if (affinity_mask) - cpu = cpu_for_thread_sp(i, max_cpus, affinity_mask); - else - cpu = cpu_for_thread_ua(i, max_cpus); - + cpu = cpu_for_thread(i, max_cpus, 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 54f5c3a240e9..189da3a804e1 100644 --- a/src/include/rt-numa.h +++ b/src/include/rt-numa.h @@ -5,8 +5,7 @@ #include int get_available_cpus(struct bitmask *cpumask); -int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask); -int cpu_for_thread_ua(int thread_num, int max_cpus); +int cpu_for_thread(int thread_num, int max_cpus, struct bitmask *cpumask); int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask); diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c index fa83eae61084..7e99eab60681 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(); } -int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask) +static int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask) { unsigned int m, cpu, i, num_cpus; @@ -44,8 +44,7 @@ int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask) return 0; } -/* cpu_for_thread AFFINITY_USEALL */ -int cpu_for_thread_ua(int thread_num, int max_cpus) +static int cpu_for_thread_ua(int thread_num, int max_cpus) { int res, num_cpus, i, m, cpu; pthread_t thread; @@ -73,6 +72,14 @@ 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) +{ + if (cpumask) + return cpu_for_thread_sp(thread_num, max_cpus, cpumask); + else + return cpu_for_thread_ua(thread_num, max_cpus); +} + /* * After this function is called, affinity_mask is the intersection of * the user supplied affinity mask and the affinity mask from the run diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index 41ebb2c87a2f..2ea5e6b58946 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -373,11 +373,7 @@ int main(int argc, char **argv) par[i].bufmsk = VALBUF_SIZE - 1; } - if (affinity_mask) - cpu = cpu_for_thread_sp(i, max_cpus, affinity_mask); - else - cpu = cpu_for_thread_ua(i, max_cpus); - + cpu = cpu_for_thread(i, max_cpus, affinity_mask); if (verbose) printf("Thread %d using cpu %d.\n", i, cpu); From patchwork Wed Feb 10 13:34:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 381418 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 97E72C433DB for ; Wed, 10 Feb 2021 13:36:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DD7D64E16 for ; Wed, 10 Feb 2021 13:36:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231626AbhBJNgh (ORCPT ); Wed, 10 Feb 2021 08:36:37 -0500 Received: from mx2.suse.de ([195.135.220.15]:50476 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231438AbhBJNgT (ORCPT ); Wed, 10 Feb 2021 08:36:19 -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 363BCB009; Wed, 10 Feb 2021 13:34:57 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 08/16] rt-numa: Use mask size for iterator limit Date: Wed, 10 Feb 2021 14:34:42 +0100 Message-Id: <20210210133450.6991-9-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org The bitmask structure knows its size use, thus use it as upper limit in the loop. Signed-off-by: Daniel Wagner --- src/lib/rt-numa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c index 7e99eab60681..b1bbb8c8052c 100644 --- a/src/lib/rt-numa.c +++ b/src/lib/rt-numa.c @@ -33,7 +33,7 @@ static int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpuma m = thread_num % num_cpus; /* there are num_cpus bits set, we want position of m'th one */ - for (i = 0, cpu = 0; i < max_cpus; i++) { + for (i = 0, cpu = 0; i < cpumask->size; i++) { if (numa_bitmask_isbitset(cpumask, i)) { if (cpu == m) return i; @@ -97,7 +97,7 @@ static void use_current_cpuset(int max_cpus, struct bitmask *cpumask) * Clear bits that are not set in both the cpuset from the * environment, and in the user specified affinity. */ - for (i = 0; i < max_cpus; i++) { + for (i = 0; i < cpumask->size; i++) { if ((!numa_bitmask_isbitset(cpumask, i)) || (!numa_bitmask_isbitset(curmask, i))) numa_bitmask_clearbit(cpumask, i); From patchwork Wed Feb 10 13:34:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 381414 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 1B9D9C433E0 for ; Wed, 10 Feb 2021 13:37:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E75E564E77 for ; Wed, 10 Feb 2021 13:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231708AbhBJNhQ (ORCPT ); Wed, 10 Feb 2021 08:37:16 -0500 Received: from mx2.suse.de ([195.135.220.15]:50630 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231481AbhBJNgX (ORCPT ); Wed, 10 Feb 2021 08:36:23 -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 801B2B023; Wed, 10 Feb 2021 13:34:57 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 09/16] rt-numa: Remove max_cpus argument from parse_cpusmask Date: Wed, 10 Feb 2021 14:34:43 +0100 Message-Id: <20210210133450.6991-10-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-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 Wed Feb 10 13:34:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 381416 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 1822FC433DB for ; Wed, 10 Feb 2021 13:37:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5F2E64E79 for ; Wed, 10 Feb 2021 13:37:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbhBJNhB (ORCPT ); Wed, 10 Feb 2021 08:37:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:50632 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231466AbhBJNgX (ORCPT ); Wed, 10 Feb 2021 08:36:23 -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 C7B7DB061; Wed, 10 Feb 2021 13:34:57 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 10/16] signaltest: Remove unused max_cpus argument from process_options Date: Wed, 10 Feb 2021 14:34:44 +0100 Message-Id: <20210210133450.6991-11-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org There is no use of this argument. Remove it. Signed-off-by: Daniel Wagner --- src/signaltest/signaltest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c index 0d189483753d..3ca26fb373bb 100644 --- a/src/signaltest/signaltest.c +++ b/src/signaltest/signaltest.c @@ -207,7 +207,7 @@ static int lockall; static struct bitmask *affinity_mask = NULL; /* Process commandline options */ -static void process_options(int argc, char *argv[], unsigned int max_cpus) +static void process_options(int argc, char *argv[]) { int error = 0; int smp = 0; @@ -325,7 +325,7 @@ int main(int argc, char **argv) if (numa_available() == -1) fatal("Couldn't initialize libnuma"); - process_options(argc, argv, max_cpus); + process_options(argc, argv); if (check_privs()) exit(1); From patchwork Wed Feb 10 13:34:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 381415 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 B5DAEC433DB for ; Wed, 10 Feb 2021 13:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BA3864E77 for ; Wed, 10 Feb 2021 13:37:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231643AbhBJNhG (ORCPT ); Wed, 10 Feb 2021 08:37:06 -0500 Received: from mx2.suse.de ([195.135.220.15]:50636 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231511AbhBJNgX (ORCPT ); Wed, 10 Feb 2021 08:36:23 -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 1DD09B062; Wed, 10 Feb 2021 13:34:58 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 11/16] cyclictest: Remove unused max_cpus argument from process_options Date: Wed, 10 Feb 2021 14:34:45 +0100 Message-Id: <20210210133450.6991-12-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org There is no use of this argument. Remove it. Signed-off-by: Daniel Wagner --- src/cyclictest/cyclictest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index acd456bd4c4d..366b2aaaa9f8 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -949,7 +949,7 @@ enum option_values { }; /* Process commandline options */ -static void process_options(int argc, char *argv[], int max_cpus) +static void process_options(int argc, char *argv[]) { int error = 0; int smp = 0; @@ -1708,7 +1708,7 @@ int main(int argc, char **argv) if (numa_available() == -1) fatal("Couldn't initialize libnuma"); - process_options(argc, argv, max_cpus); + process_options(argc, argv); if (check_privs()) exit(EXIT_FAILURE); From patchwork Wed Feb 10 13:34:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 380567 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 737E0C433DB for ; Wed, 10 Feb 2021 13:37:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4464864E77 for ; Wed, 10 Feb 2021 13:37:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231466AbhBJNhE (ORCPT ); Wed, 10 Feb 2021 08:37:04 -0500 Received: from mx2.suse.de ([195.135.220.15]:50634 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231489AbhBJNgX (ORCPT ); Wed, 10 Feb 2021 08:36:23 -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 6B3E5B066; Wed, 10 Feb 2021 13:34:58 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 12/16] rt-numa: Use CPU_SETSIZE as upper loop limit Date: Wed, 10 Feb 2021 14:34:46 +0100 Message-Id: <20210210133450.6991-13-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-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 Wed Feb 10 13:34: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: 380565 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 3DEB1C433E0 for ; Wed, 10 Feb 2021 13:37:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A27C64E77 for ; Wed, 10 Feb 2021 13:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230259AbhBJNhT (ORCPT ); Wed, 10 Feb 2021 08:37:19 -0500 Received: from mx2.suse.de ([195.135.220.15]:50638 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231518AbhBJNgY (ORCPT ); Wed, 10 Feb 2021 08:36:24 -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 BA5C4B06A; Wed, 10 Feb 2021 13:34:58 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 13/16] rt-numa: Remove used max_cpus argument from cpu_for_thread() Date: Wed, 10 Feb 2021 14:34:47 +0100 Message-Id: <20210210133450.6991-14-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-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 Wed Feb 10 13:34:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 380566 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 C6C38C433E0 for ; Wed, 10 Feb 2021 13:37:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A22A064E77 for ; Wed, 10 Feb 2021 13:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231668AbhBJNhN (ORCPT ); Wed, 10 Feb 2021 08:37:13 -0500 Received: from mx2.suse.de ([195.135.220.15]:50640 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231520AbhBJNgX (ORCPT ); Wed, 10 Feb 2021 08:36:23 -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 14A99B07D; Wed, 10 Feb 2021 13:34:59 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 14/16] cyclictest: Remove max cpus used verbose information Date: Wed, 10 Feb 2021 14:34:48 +0100 Message-Id: <20210210133450.6991-15-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-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 Wed Feb 10 13:34: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: 381413 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 12E8FC433E0 for ; Wed, 10 Feb 2021 13:37:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D797E64E77 for ; Wed, 10 Feb 2021 13:37:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbhBJNhY (ORCPT ); Wed, 10 Feb 2021 08:37:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:50476 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231636AbhBJNgl (ORCPT ); Wed, 10 Feb 2021 08:36:41 -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 618DCB087; Wed, 10 Feb 2021 13:34:59 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 15/16] cyclictest: Remove unecessary local variable Date: Wed, 10 Feb 2021 14:34:49 +0100 Message-Id: <20210210133450.6991-16-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-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 Wed Feb 10 13:34:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 380564 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 21431C433DB for ; Wed, 10 Feb 2021 13:37:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC9F964E77 for ; Wed, 10 Feb 2021 13:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231691AbhBJNh3 (ORCPT ); Wed, 10 Feb 2021 08:37:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:50914 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbhBJNhH (ORCPT ); Wed, 10 Feb 2021 08:37:07 -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 B061EB0B3; Wed, 10 Feb 2021 13:34:59 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [PATCH rt-tests v4 16/16] rt-tests: Rename error.h to rt-error.h Date: Wed, 10 Feb 2021 14:34:50 +0100 Message-Id: <20210210133450.6991-17-dwagner@suse.de> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210133450.6991-1-dwagner@suse.de> References: <20210210133450.6991-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 --- Makefile | 2 +- src/cyclictest/cyclictest.c | 2 +- src/include/pip_stress.h | 5 +++-- src/include/{error.h => rt-error.h} | 0 src/lib/{error.c => rt-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 ++- 15 files changed, 24 insertions(+), 22 deletions(-) rename src/include/{error.h => rt-error.h} (100%) rename src/lib/{error.c => rt-error.c} (98%) diff --git a/Makefile b/Makefile index 636f1914a777..b17ac0957adc 100644 --- a/Makefile +++ b/Makefile @@ -177,7 +177,7 @@ oslat: $(OBJDIR)/oslat.o $(OBJDIR)/librttest.a $(OBJDIR)/librttestnuma.a %.8.bz2: %.8 bzip2 -c $< > $@ -LIBOBJS =$(addprefix $(OBJDIR)/,error.o rt-get_cpu.o rt-sched.o rt-utils.o) +LIBOBJS =$(addprefix $(OBJDIR)/,rt-error.o rt-get_cpu.o rt-sched.o rt-utils.o) $(OBJDIR)/librttest.a: $(LIBOBJS) $(AR) rcs $@ $^ 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/rt-error.c similarity index 98% rename from src/lib/error.c rename to src/lib/rt-error.c index 4434a842da17..616f70b044e0 100644 --- a/src/lib/error.c +++ b/src/lib/rt-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