diff mbox series

[1/2] rt-tests: Don't assume numa is available at runtime

Message ID 20210222220750.12911-2-jkacur@redhat.com
State New
Headers show
Series Fix for machines without numa | expand

Commit Message

John Kacur Feb. 22, 2021, 10:07 p.m. UTC
- 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(-)
diff mbox series

Patch

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 3e31937f7088..157047837259 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -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;
 	}
diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c
index dbeaef696876..babcc634d57e 100644
--- a/src/lib/rt-numa.c
+++ b/src/lib/rt-numa.c
@@ -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)
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index 4f8e7caea2c1..b1a7e1db8302 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -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;
 	}