diff options
author | John Kacur <jkacur@redhat.com> | 2015-09-15 23:37:12 +0200 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2015-09-17 21:19:30 +0200 |
commit | 1d6b1c9d25416a417f5e1f87f00a55029850021c (patch) | |
tree | dd679a7a93cf6fe06e9210041e2f652682b35b2e | |
parent | e4de2b6db9a0b7bdcbdcce235d673a859f30e18e (diff) | |
download | rt-tests-1d6b1c9d25416a417f5e1f87f00a55029850021c.tar.gz |
numa_on_and_available: Remove from main in cyclictest
We don't support building without numa libs anymore, although we of
course support running on machines without numa. Never-the-less I
created two versions of numa_on_and_available, one for if you build with
the unsupported NUMA=0 and one for if you build with NUMA=1, which is
the default.
I would prefer not to drop this function, since I think it cleanly
documents the fact that numa_available must be called before any other
numa library functions are defined.
As Josh Cartwright reported though, there was no need to call it from
main() since it was already tested in process_options(), so I tested it
there.
Tested by building with NUMA=0, NUMA=1 and with the non-standard
-Wimplicit-function-declaration
Reported-by: Josh Cartwright <joshc@ni.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r-- | src/cyclictest/cyclictest.c | 7 | ||||
-rw-r--r-- | src/cyclictest/rt_numa.h | 18 |
2 files changed, 15 insertions, 10 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 213c527..b3abfcc 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1451,12 +1451,11 @@ static void process_options (int argc, char *argv[], int max_cpus) setvbuf(stdout, NULL, _IONBF, 0); break; case 'U': case OPT_NUMA: /* NUMA testing */ + numa = 1; /* Turn numa on */ if (smp) fatal("numa and smp options are mutually exclusive\n"); + numa_on_and_available(); #ifdef NUMA - if (numa_available() == -1) - fatal("NUMA functionality not available!"); - numa = 1; num_threads = max_cpus; setaffinity = AFFINITY_USEALL; use_nanosleep = MODE_CLOCK_NANOSLEEP; @@ -1816,8 +1815,6 @@ int main(int argc, char **argv) if (verbose) printf("Max CPUs = %d\n", max_cpus); - /* Checks if numa is on, program exits if numa on but not available */ - numa_on_and_available(); /* lock all memory (prevent swapping) */ if (lockall) diff --git a/src/cyclictest/rt_numa.h b/src/cyclictest/rt_numa.h index 06c9420..c1b3f94 100644 --- a/src/cyclictest/rt_numa.h +++ b/src/cyclictest/rt_numa.h @@ -192,6 +192,12 @@ static inline void rt_bitmask_free(struct bitmask *mask) #endif /* LIBNUMA_API_VERSION */ +static void numa_on_and_available() +{ + if (numa && (numa_available() == -1)) + fatal("--numa specified and numa functions not available.\n"); +} + #else /* ! NUMA */ struct bitmask { @@ -249,17 +255,19 @@ static inline void rt_bitmask_free(struct bitmask *mask) free(mask); } -#endif /* NUMA */ -/* - * Any behavioral differences above are transparent to these functions - */ static void numa_on_and_available() { - if (numa && (numa_available() == -1)) + if (numa) /* NUMA is not defined here */ fatal("--numa specified and numa functions not available.\n"); } +#endif /* NUMA */ + +/* + * Any behavioral differences above are transparent to these functions + */ + /** Returns number of bits set in mask. */ static inline unsigned int rt_numa_bitmask_count(const struct bitmask *mask) { |