* [PATCH] cyclictest: Fix setaffinity error on large NUMA machines
@ 2020-05-04 16:12 John Kacur
0 siblings, 0 replies; only message in thread
From: John Kacur @ 2020-05-04 16:12 UTC (permalink / raw)
To: rt-users; +Cc: Clark Williams, Yunfeng Ye, Kate Carcia, John Kacur
On large NUMA machines still getting the following error
WARN: Couldn't setaffinity in main thread: Invalid argument
Instead of calling numa_bitmask_alloc() with max_cpus, use
numa_allocate_cpumask() to fix this.
Also, make sure numa_available() is called before any other calls to the
numa library. Depending on how the options were invoked this could
happen in parse_cpumask for example. Note, this did not seem to cause
any problems in practice, but let's adhere to the library contract.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/cyclictest/cyclictest.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 989113fb3483..79bb1cb71c68 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1135,7 +1135,7 @@ static void use_current_cpuset(const int max_cpus)
pid = getpid();
- curmask = numa_bitmask_alloc(max_cpus);
+ curmask = numa_allocate_cpumask();
numa_sched_getaffinity(pid, curmask);
/* Clear bits that are not set in both the cpuset from the environment,
@@ -1225,6 +1225,20 @@ enum option_values {
OPT_TRACEMARK, OPT_POSIX_TIMERS,
};
+/* numa_available() must be called before any other calls to the numa library */
+static void numa_initialize(void)
+{
+ static int is_initialized;
+
+ if (is_initialized == 1)
+ return;
+
+ if (numa_available() != -1)
+ numa = 1;
+
+ is_initialized = 1;
+}
+
/* Process commandline options */
static void process_options (int argc, char *argv[], int max_cpus)
{
@@ -1288,6 +1302,7 @@ static void process_options (int argc, char *argv[], int max_cpus)
/* smp sets AFFINITY_USEALL in OPT_SMP */
if (smp)
break;
+ numa_initialize();
if (optarg != NULL) {
parse_cpumask(optarg, max_cpus);
setaffinity = AFFINITY_SPECIFIED;
@@ -1460,12 +1475,9 @@ static void process_options (int argc, char *argv[], int max_cpus)
/* if smp wasn't requested, test for numa automatically */
if (!smp) {
#ifdef NUMA
- if (numa_available() != -1) {
- numa = 1;
- if (setaffinity == AFFINITY_UNSPECIFIED) {
- setaffinity = AFFINITY_USEALL;
- }
- }
+ numa_initialize();
+ if (setaffinity == AFFINITY_UNSPECIFIED)
+ setaffinity = AFFINITY_USEALL;
#else
warn("cyclictest was not built with the numa option\n");
numa = 0;
--
2.21.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-05-04 16:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 16:12 [PATCH] cyclictest: Fix setaffinity error on large NUMA machines John Kacur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).