diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index e2753db39c02..3e31937f7088 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1018,6 +1018,9 @@ 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,6 +1129,8 @@ 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;@@ -1199,17 +1204,16 @@ 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 && smp) {
- warn("-a ignored due to smp mode\n");
- if (affinity_mask) {
- numa_bitmask_free(affinity_mask);
- affinity_mask = NULL;
- }
- setaffinity = AFFINITY_USEALL;
+ if (option_affinity) {
+ if (smp)
+ warn("-a ignored due to smp mode\n");
}
if (smi) {@@ -1778,12 +1782,6 @@ int main(int argc, char **argv)
int online_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);
@@ -1972,27 +1970,34 @@ int main(int argc, char **argv)
default: cpu = -1;
}
- /* find the memory node associated with the cpu i */
- node = rt_numa_numa_node_of_cpu(cpu);
+ node = -1;
+ if (numa) {
+ void *stack;
+ void *currstk;
+ size_t stksize;
- /* 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);
+ /* find the memory node associated with the cpu i */
+ node = rt_numa_numa_node_of_cpu(cpu);
- /* if the stack size is zero, set a default */
- if (stksize == 0)
- stksize = PTHREAD_STACK_MIN * 2;
+ /* 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);
- /* allocate memory for a stack on appropriate node */
- stack = rt_numa_numa_alloc_onnode(stksize, node, cpu);
+ /* if the stack size is zero, set a default */
+ if (stksize == 0)
+ stksize = PTHREAD_STACK_MIN * 2;
- /* touch the stack pages to pre-fault them in */
- memset(stack, 0, stksize);
+ /* allocate memory for a stack on appropriate node */
+ stack = rt_numa_numa_alloc_onnode(stksize, node, cpu);
- /* 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);
+ /* 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);
+ }
/* 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 87f5d3b66458..4cbd979c21e8 100644
--- a/src/cyclictest/rt_numa.h
+++ b/src/cyclictest/rt_numa.h
@@ -13,6 +13,8 @@
#include "rt-utils.h"
#include "rt-error.h"
+static int numa = 0;
+
#include <numa.h>
static void *
--
2.26.2