@@ -1018,9 +1018,7 @@ 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;
+ numa = numa_initialize();
if (optarg) {
parse_cpumask(optarg, max_cpus, &affinity_mask);
setaffinity = AFFINITY_SPECIFIED;
@@ -1204,9 +1202,7 @@ 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;
+ numa = numa_initialize();
if (setaffinity == AFFINITY_UNSPECIFIED)
setaffinity = AFFINITY_USEALL;
}
@@ -13,19 +13,24 @@
#include "rt-error.h"
#include "rt-numa.h"
-/* numa_available() must be called before any other calls to the numa library */
+/*
+ * numa_available() must be called before any other calls to the numa library
+ * returns 0 if numa is available, or 1 if numa is not available
+ */
int numa_initialize(void)
{
- static int is_initialized;
+ static int is_initialized; // Only call numa_available once
+ static int numa;
if (is_initialized == 1)
- return 0;
+ return numa;
- if (numa_available() == -1)
- return -1;
+ if (numa_available() != -1)
+ numa = 1;
is_initialized = 1;
- return 0;
+
+ return numa;
}
int get_available_cpus(struct bitmask *cpumask)
@@ -253,9 +253,7 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus)
/* smp sets AFFINITY_USEALL in OPT_SMP */
if (smp)
break;
- if (numa_initialize())
- fatal("Couldn't initialize libnuma");
- numa = 1;
+ numa = numa_initialize();
if (optarg) {
parse_cpumask(optarg, max_cpus, &affinity_mask);
setaffinity = AFFINITY_SPECIFIED;
@@ -339,9 +337,7 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus)
/* if smp wasn't requested, test for numa automatically */
if (!smp) {
- if (numa_initialize())
- fatal("Couldn't initialize libnuma");
- numa = 1;
+ numa = numa_initialize();
if (setaffinity == AFFINITY_UNSPECIFIED)
setaffinity = AFFINITY_USEALL;
}
- Rework numa_initialize a bit to return the status of numa - Don't fail if numa is not available after the call to numa_initialize Signed-off-by: John Kacur <jkacur@redhat.com> --- src/cyclictest/cyclictest.c | 8 ++------ src/lib/rt-numa.c | 17 +++++++++++------ src/signaltest/signaltest.c | 8 ++------ 3 files changed, 15 insertions(+), 18 deletions(-)