rt-tests: cyclictest: Remove HAVE_PARSE_CPUSTRING_ALL
PATCH 1/4 rt-tests: cyclictest: Remove HAVE_PARSE_CPUSTRING_ALL
We assume that numa_parse_cpustring_all() is available. Older numa libs without it are no-longer supported
--- Makefile | 8 -------- src/cyclictest/rt_numa.h | 10 ---------- 2 files changed, 18 deletions(-)
Makefile +0 -8
@@ -85,17 +85,9 @@ ifneq ($(filter x86_64 i386 ia64 mips powerpc,$(machinetype)),) NUMA := 1 endif -# The default is to assume that you have numa_parse_cpustring_all -# If you have an older version of libnuma that only has numa_parse_cpustring -# then compile with -# make HAVE_PARSE_CPUSTRING_ALL=0 -HAVE_PARSE_CPUSTRING_ALL?=1 ifeq ($(NUMA),1) CFLAGS += -DNUMA NUMA_LIBS = -lnuma - ifeq ($(HAVE_PARSE_CPUSTRING_ALL),1) - CFLAGS += -DHAVE_PARSE_CPUSTRING_ALL - endif endif include src/arch/android/Makefile
src/cyclictest/rt_numa.h +0 -10
@@ -78,17 +78,7 @@ static inline unsigned int rt_numa_bitmask_isbitset( const struct bitmask *mask,static inline struct bitmask *rt_numa_parse_cpustring (const char * s,int max_cpus) { -#ifdef HAVE_PARSE_CPUSTRING_ALL /* Currently not defined anywhere. No -autotools build. */ return numa_parse_cpustring_all (s); -#else -/* We really need numa_parse_cpustring_all(), so we can assign threads -* to cores which are part of an isolcpus set, but early 2.x versions of -* libnuma do not have this function. A work around should be to run -* your command with e.g. taskset -c 9-15 <command> -*/ -return numa_parse_cpustring ((char *)s); -#endif }static inline void rt_bitmask_free (struct bitmask *mask)
Signature · 1 line
2.20.1
PATCH 2/4 rt-tests: cyclictest: Remove support for compiling without NUMA
We announced way back in 2015 that compiling without the NUMA libs was no-longer supported, but we left the bits in there for you to do it anyway.
Since this is not supported, and is broken now anyway, let's remove the cruft.
Of course running on non-NUMA machines should still work fine.
--- Makefile | 17 +++------- src/cyclictest/rt_numa.h | 67 ---------------------------------------- 2 files changed, 4 insertions(+), 80 deletions(-)
Makefile +4 -13
@@ -76,19 +76,10 @@ ostype := $(lastword $(subst -, ,$(dumpmachine))) machinetype := $(shell echo $(dumpmachine)| \ sed -e 's/-.*//' -e 's/i.86/i386/' -e 's/mips.*/mips/' -e 's/ppc.*/powerpc/') -# The default is to assume you have libnuma installed, which is fine to do -# even on non-numa machines. If you don't want to install the numa libs, for -# example, they might not be available in an embedded environment, then -# compile with -# make NUMA=0 -ifneq ($(filter x86_64 i386 ia64 mips powerpc,$(machinetype)),) -NUMA := 1 -endif - -ifeq ($(NUMA),1) - CFLAGS += -DNUMA - NUMA_LIBS = -lnuma -endif +# You have to have libnuma installed, which is fine to do even if you are +# running on non-numa machines +CFLAGS += -DNUMA +NUMA_LIBS = -lnuma include src/arch/android/Makefile
src/cyclictest/rt_numa.h +0 -67
85 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 3/4 rt-tests: cyclictest: Make the affinity mask apply to the main thread too
In reply to John KacurThere is no reason that the main thread should be treated differently, so apply the affinity setting there too.
--- src/cyclictest/cyclictest.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
src/cyclictest/cyclictest.c +11 -0
@@ -1992,6 +1992,17 @@ int main(int argc, char **argv)if (verbose)printf ("Max CPUs = %d\n" , max_cpus); +/* Restrict the main pid to the affinity specified by the user */ +if (affinity_mask !=NULL ) { +int res; + + errno =0 ; + res =numa_sched_setaffinity (getpid (), affinity_mask); +if (res !=0 ) { +warn ("Couldn't setaffinity in main thread: %s\n" ,strerror (errno)); + } + } +if (trigger) {int retval; retval =trigger_init ();
Signature · 1 line
2.20.1
PATCH 4/4 rt-tests: cyclictest: Fix -t without a user specified [NUM]
In reply to John KacurFix -t without a specified [NUM] to run the same number of threads as available processors.
Currently it runs the same number of threads as cpus on a system. However, if cyclictest is contrained to run on a smaller set of cpus either because of a container or a user specified affinity or a combination of the two, then the actual number of available cpus is smaller. -t should reflect that.
--- src/cyclictest/cyclictest.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-)
src/cyclictest/cyclictest.c +34 -2
@@ -1040,6 +1040,35 @@ static unsigned int is_cpumask_zero(const struct bitmask *mask)return (rt_numa_bitmask_count (mask) ==0 ); } +/* Get available cpus according to getaffinity or according to the +* intersection of getaffinity and the user specified affinity +* in the case of AFFINITY_SPECIFIED, the function has to be called +* after the call to parse_cpumask made in process_options() +*/ +static int get_available_cpus (void ) +{ +int num_cpus =0 ; +int res; +pthread_t thread; +cpu_set_t cpuset; + + +if (affinity_mask !=NULL ) { + num_cpus =rt_numa_bitmask_count (affinity_mask); + }else { +CPU_ZERO (&cpuset); + thread =pthread_self (); + res =pthread_getaffinity_np (thread,sizeof (cpu_set_t), &cpuset); +if (res !=0 ) { +fatal ("pthread_getaffinity_np failed: %s\n" ,strerror (res)); + } + num_cpus =CPU_COUNT (&cpuset); + } + +return num_cpus; + +} +/* cpu_for_thread AFFINITY_SPECIFIED */ static int cpu_for_thread_sp (int thread_num,int max_cpus) {
@@ -1358,7 +1387,7 @@ static void process_options (int argc, char *argv[], int max_cpus)if (numa)fatal ("numa and smp options are mutually exclusive\n" ); smp =1 ; - num_threads = max_cpus; + num_threads =-1 ;/* update after parsing */ setaffinity =AFFINITY_USEALL ;break ;case 't' :
@@ -1372,7 +1401,7 @@ static void process_options (int argc, char *argv[], int max_cpus)else if (optind<argc &&atoi (argv[optind])) num_threads =atoi (argv[optind]);else - num_threads = max_cpus; + num_threads =-1 ;/* update after parsing */ break ;case OPT_TRIGGER : trigger =atoi (optarg);
@@ -1485,6 +1514,9 @@ static void process_options (int argc, char *argv[], int max_cpus)if (priority <0 || priority >99 ) error =1 ; +if (num_threads ==-1 ) + num_threads =get_available_cpus (); +if (priospread && priority ==0 ) {fprintf (stderr,"defaulting realtime priority to %d\n" , num_threads+1 );
Signature · 1 line
2.20.1