rt-tests: Don't assume numa is available at runtime

- 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>
This commit is contained in:
John Kacur 2021-02-22 16:52:35 -05:00
parent 6b9ac75508
commit 2dc376c322
3 changed files with 15 additions and 18 deletions

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}