From patchwork Fri Dec 18 16:18:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345800 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 404CBC2D0E4 for ; Fri, 18 Dec 2020 16:19:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 134EF23B76 for ; Fri, 18 Dec 2020 16:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730023AbgLRQTd (ORCPT ); Fri, 18 Dec 2020 11:19:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:36876 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgLRQTc (ORCPT ); Fri, 18 Dec 2020 11:19:32 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D912FAD6A; Fri, 18 Dec 2020 16:18:50 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 01/20] cyclictest: Always use libnuma Date: Fri, 18 Dec 2020 17:18:24 +0100 Message-Id: <20201218161843.1764-2-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org libnuma is hard dependency for cyclictest. Thus we can always call numa_initialize(). This allows us to remove the global 'numa' variable to track if libnuma has been initialized or not. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/cyclictest/cyclictest.c | 63 +++++++++++++++++-------------------- src/cyclictest/rt_numa.h | 2 -- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index f38c453f1975..514ed7b20fdb 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1018,9 +1018,6 @@ static void process_options(int argc, char *argv[], int max_cpus) /* smp sets AFFINITY_USEALL in OPT_SMP */ if (smp) break; - if (numa_initialize()) - fatal("Couldn't initialize libnuma"); - numa = 1; if (optarg) { parse_cpumask(optarg, max_cpus, &affinity_mask); setaffinity = AFFINITY_SPECIFIED; @@ -1126,8 +1123,6 @@ static void process_options(int argc, char *argv[], int max_cpus) use_system = MODE_SYS_OFFSET; break; case 'S': case OPT_SMP: /* SMP testing */ - if (numa) - fatal("numa and smp options are mutually exclusive\n"); smp = 1; num_threads = -1; /* update after parsing */ setaffinity = AFFINITY_USEALL; @@ -1201,16 +1196,17 @@ static void process_options(int argc, char *argv[], int max_cpus) /* if smp wasn't requested, test for numa automatically */ if (!smp) { - if (numa_initialize()) - fatal("Couldn't initialize libnuma"); - numa = 1; if (setaffinity == AFFINITY_UNSPECIFIED) setaffinity = AFFINITY_USEALL; } - if (option_affinity) { - if (smp) - warn("-a ignored due to smp mode\n"); + if (option_affinity && smp) { + warn("-a ignored due to smp mode\n"); + if (affinity_mask) { + numa_bitmask_free(affinity_mask); + affinity_mask = NULL; + } + setaffinity = AFFINITY_USEALL; } if (smi) { @@ -1744,6 +1740,12 @@ int main(int argc, char **argv) int max_cpus = sysconf(_SC_NPROCESSORS_ONLN); int i, ret = -1; int status; + void *stack; + void *currstk; + size_t stksize; + + if (numa_initialize()) + fatal("Couldn't initialize libnuma"); process_options(argc, argv, max_cpus); @@ -1926,34 +1928,27 @@ int main(int argc, char **argv) default: cpu = -1; } - node = -1; - if (numa) { - void *stack; - void *currstk; - size_t stksize; + /* find the memory node associated with the cpu i */ + node = rt_numa_numa_node_of_cpu(cpu); - /* find the memory node associated with the cpu i */ - node = rt_numa_numa_node_of_cpu(cpu); + /* get the stack size set for this thread */ + if (pthread_attr_getstack(&attr, &currstk, &stksize)) + fatal("failed to get stack size for thread %d\n", i); - /* get the stack size set for this thread */ - if (pthread_attr_getstack(&attr, &currstk, &stksize)) - fatal("failed to get stack size for thread %d\n", i); + /* if the stack size is zero, set a default */ + if (stksize == 0) + stksize = PTHREAD_STACK_MIN * 2; - /* if the stack size is zero, set a default */ - if (stksize == 0) - stksize = PTHREAD_STACK_MIN * 2; + /* allocate memory for a stack on appropriate node */ + stack = rt_numa_numa_alloc_onnode(stksize, node, cpu); - /* allocate memory for a stack on appropriate node */ - stack = rt_numa_numa_alloc_onnode(stksize, node, cpu); + /* touch the stack pages to pre-fault them in */ + memset(stack, 0, stksize); - /* touch the stack pages to pre-fault them in */ - memset(stack, 0, stksize); - - /* set the thread's stack */ - if (pthread_attr_setstack(&attr, stack, stksize)) - fatal("failed to set stack addr for thread %d to 0x%x\n", - i, stack+stksize); - } + /* set the thread's stack */ + if (pthread_attr_setstack(&attr, stack, stksize)) + fatal("failed to set stack addr for thread %d to 0x%x\n", + i, stack+stksize); /* allocate the thread's parameter block */ parameters[i] = par = threadalloc(sizeof(struct thread_param), node); diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h index 46690941e0a6..8d02f419ed6d 100644 --- a/src/cyclictest/rt_numa.h +++ b/src/cyclictest/rt_numa.h @@ -13,8 +13,6 @@ #include "rt-utils.h" #include "error.h" -static int numa = 0; - #include static void * From patchwork Fri Dec 18 16:18:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345798 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 7FE28C3526C for ; Fri, 18 Dec 2020 16:19:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57E5F23B6C for ; Fri, 18 Dec 2020 16:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730041AbgLRQTd (ORCPT ); Fri, 18 Dec 2020 11:19:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:36888 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729687AbgLRQTd (ORCPT ); Fri, 18 Dec 2020 11:19:33 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2F81BADD6; Fri, 18 Dec 2020 16:18:51 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 02/20] cyclictest: Use numa API directly Date: Fri, 18 Dec 2020 17:18:25 +0100 Message-Id: <20201218161843.1764-3-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-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 | 41 ++++++++-------- src/cyclictest/rt_numa.h | 96 ------------------------------------- 2 files changed, 22 insertions(+), 115 deletions(-) delete mode 100644 src/cyclictest/rt_numa.h diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 514ed7b20fdb..a5ca764da254 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); @@ -1275,7 +1275,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); } } @@ -1929,7 +1929,7 @@ int main(int argc, char **argv) } /* find the memory node associated with the cpu i */ - node = rt_numa_numa_node_of_cpu(cpu); + node = numa_node_of_cpu(cpu); /* get the stack size set for this thread */ if (pthread_attr_getstack(&attr, &currstk, &stksize)) @@ -1940,7 +1940,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); @@ -1951,13 +1954,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)); @@ -1966,8 +1969,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); @@ -1977,14 +1980,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); @@ -2099,7 +2102,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) @@ -2108,8 +2111,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)); } } @@ -2125,14 +2128,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 */ @@ -2147,7 +2150,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 Fri Dec 18 16:18:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345799 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 51757C3526B for ; Fri, 18 Dec 2020 16:19:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2ADF023B6C for ; Fri, 18 Dec 2020 16:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730039AbgLRQTd (ORCPT ); Fri, 18 Dec 2020 11:19:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:36912 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729765AbgLRQTc (ORCPT ); Fri, 18 Dec 2020 11:19:32 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BFD54ADE1; Fri, 18 Dec 2020 16:18:51 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 04/20] cyclictest: Mimik --smp behavior with --affinity Date: Fri, 18 Dec 2020 17:18:27 +0100 Message-Id: <20201218161843.1764-5-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-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. Reviewed-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 3dafef4e7e5a..23243ddfe9d3 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1024,6 +1024,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; } if (verbose) From patchwork Fri Dec 18 16:18:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345793 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 61709C2D0E4 for ; Fri, 18 Dec 2020 16:20:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2937623B6C for ; Fri, 18 Dec 2020 16:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731381AbgLRQUO (ORCPT ); Fri, 18 Dec 2020 11:20:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:37366 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729109AbgLRQUO (ORCPT ); Fri, 18 Dec 2020 11:20:14 -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 166D4ADE2; Fri, 18 Dec 2020 16:18:52 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 05/20] cyclictest: Simplify --smp vs --affinity vs --threads argument logic Date: Fri, 18 Dec 2020 17:18:28 +0100 Message-Id: <20201218161843.1764-6-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-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 23243ddfe9d3..a34b2140f940 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -885,14 +885,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, @@ -958,7 +957,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; @@ -1013,10 +1012,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 && @@ -1024,8 +1019,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; } if (verbose) @@ -1117,22 +1110,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); @@ -1188,13 +1173,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 Fri Dec 18 16:18:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345795 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 BC1D8C3526E for ; Fri, 18 Dec 2020 16:20:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A8BB23B6C for ; Fri, 18 Dec 2020 16:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731374AbgLRQUO (ORCPT ); Fri, 18 Dec 2020 11:20:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:37364 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726181AbgLRQUO (ORCPT ); Fri, 18 Dec 2020 11:20:14 -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 64FDBADE4; Fri, 18 Dec 2020 16:18:52 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 06/20] cyclictest: Move verbose message into main Date: Fri, 18 Dec 2020 17:18:29 +0100 Message-Id: <20201218161843.1764-7-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-1-dwagner@suse.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rt-users@vger.kernel.org By moving the verbose message down we print the message with the final affinity_mask. This also handles the case where the bitmask is not set. Signed-off-by: Daniel Wagner Signed-off-by: John Kacur --- src/cyclictest/cyclictest.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index a34b2140f940..7e84c25f7070 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1020,10 +1020,6 @@ static void process_options(int argc, char *argv[], int max_cpus) argv[optind][0] == '!')) { parse_cpumask(argv[optind], max_cpus, &affinity_mask); } - - if (verbose) - printf("Using %u cpus.\n", - numa_bitmask_weight(affinity_mask)); break; case 'A': case OPT_ALIGNED: @@ -1732,6 +1728,10 @@ 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 Fri Dec 18 16:18:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345797 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 025DDC4361B for ; Fri, 18 Dec 2020 16:20:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB6CD23B6C for ; Fri, 18 Dec 2020 16:20:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731402AbgLRQUO (ORCPT ); Fri, 18 Dec 2020 11:20:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:37382 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731140AbgLRQUO (ORCPT ); Fri, 18 Dec 2020 11:20:14 -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 4F3ECAE12; Fri, 18 Dec 2020 16:18:53 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 09/20] signaltest: Simplify --smp vs --affinity vs --threads argument logic Date: Fri, 18 Dec 2020 17:18:32 +0100 Message-Id: <20201218161843.1764-10-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-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. Reviewed-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 Fri Dec 18 16:18:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345794 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 5A94EC2BBD5 for ; Fri, 18 Dec 2020 16:20:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3296023B6C for ; Fri, 18 Dec 2020 16:20:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731467AbgLRQUR (ORCPT ); Fri, 18 Dec 2020 11:20:17 -0500 Received: from mx2.suse.de ([195.135.220.15]:37398 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731141AbgLRQUO (ORCPT ); Fri, 18 Dec 2020 11:20:14 -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 7D1E5AE2B; Fri, 18 Dec 2020 16:19:01 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 12/20] rt-numa: Use mask size for iterator limit Date: Fri, 18 Dec 2020 17:18:35 +0100 Message-Id: <20201218161843.1764-13-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-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 a246dbca7291..1918f93b74eb 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 Fri Dec 18 16:18:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345796 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 DB960C3526B for ; Fri, 18 Dec 2020 16:20:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A25CA23B6C for ; Fri, 18 Dec 2020 16:20:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731450AbgLRQUQ (ORCPT ); Fri, 18 Dec 2020 11:20:16 -0500 Received: from mx2.suse.de ([195.135.220.15]:37400 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731298AbgLRQUP (ORCPT ); Fri, 18 Dec 2020 11:20:15 -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 C3390AE2E; Fri, 18 Dec 2020 16:19:01 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 13/20] rt-numa: Remove max_cpus argument from parse_cpusmask Date: Fri, 18 Dec 2020 17:18:36 +0100 Message-Id: <20201218161843.1764-14-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-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(). Reviewed-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 092534abb709..9e138c812fc8 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1013,12 +1013,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 1918f93b74eb..fc7adb4d467a 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 Fri Dec 18 16:18:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345792 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 4F5DCC2D0E4 for ; Fri, 18 Dec 2020 16:20:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2334523B6C for ; Fri, 18 Dec 2020 16:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731511AbgLRQUa (ORCPT ); Fri, 18 Dec 2020 11:20:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:37364 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731478AbgLRQUa (ORCPT ); Fri, 18 Dec 2020 11:20:30 -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 5E8F8AE39; Fri, 18 Dec 2020 16:19:02 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 15/20] signaltest: Remove unused max_cpus argument from process_options Date: Fri, 18 Dec 2020 17:18:38 +0100 Message-Id: <20201218161843.1764-16-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-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. Reviewed-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 Fri Dec 18 16:18:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345791 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 24B64C4361B for ; Fri, 18 Dec 2020 16:20:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E56572071E for ; Fri, 18 Dec 2020 16:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731526AbgLRQUz (ORCPT ); Fri, 18 Dec 2020 11:20:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:38182 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731482AbgLRQUz (ORCPT ); Fri, 18 Dec 2020 11:20:55 -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 32E52AE46; Fri, 18 Dec 2020 16:19:03 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 17/20] rt-numa: Use CPU_SETSIZE as upper loop limit Date: Fri, 18 Dec 2020 17:18:40 +0100 Message-Id: <20201218161843.1764-18-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-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. Reviewed-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 Fri Dec 18 16:18:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 345790 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 36C80C2BBD5 for ; Fri, 18 Dec 2020 16:20:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F46D23B6C for ; Fri, 18 Dec 2020 16:20:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731528AbgLRQU4 (ORCPT ); Fri, 18 Dec 2020 11:20:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:38184 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725982AbgLRQUz (ORCPT ); Fri, 18 Dec 2020 11:20:55 -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 7F634AE47; Fri, 18 Dec 2020 16:19:03 +0000 (UTC) From: Daniel Wagner To: Clark Williams , John Kacur Cc: linux-rt-users@vger.kernel.org, Daniel Wagner Subject: [rt-tests v2 v2 18/20] rt-numa: Remove used max_cpus argument from cpu_for_thread() Date: Fri, 18 Dec 2020 17:18:41 +0100 Message-Id: <20201218161843.1764-19-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201218161843.1764-1-dwagner@suse.de> References: <20201218161843.1764-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. Reviewed-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 b7de32cf58d0..5d1c08e8b8e0 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1884,7 +1884,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);