public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: linux-rt-users@vger.kernel.org
Cc: John Kacur <jkacur@redhat.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH v2] rt-numa: ignore runtime cpumask if -a CPULIST is specified
Date: Tue, 25 Jan 2022 15:46:00 -0300	[thread overview]
Message-ID: <YfBFaNrP/1LCgWoN@fuller.cnet> (raw)
In-Reply-To: <YfBEDR4E2dNK8XzK@fuller.cnet>

 
When using isolcpus kernel command line option, the CPUs
specified at isolcpus= are not part of the run time environment
cpumask.

This causes "cyclictest -a isolatedcpus" to fail with:

WARN: Couldn't setaffinity in main thread: Invalid argument
FATAL: No allowable cpus to run on
# /dev/cpu_dma_latency set to 0us

To fix this, ignore the runtime cpumask if neither "+", "!"
or "all" are specified in the cpu list string.

Suggested by Sebastian Andrzej Siewior.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

---

v2: fix changelog typo

diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c
index ee5ab99..d887355 100644
--- a/src/lib/rt-numa.c
+++ b/src/lib/rt-numa.c
@@ -9,6 +9,7 @@
 #include <errno.h>
 #include <sched.h>
 #include <pthread.h>
+#include <stdlib.h>
 
 #include "rt-error.h"
 #include "rt-numa.h"
@@ -96,13 +97,21 @@ int cpu_for_thread_ua(int thread_num, int max_cpus)
  * the user supplied affinity mask and the affinity mask from the run
  * time environment
  */
-static void use_current_cpuset(int max_cpus, struct bitmask *cpumask)
+static void use_current_cpuset(char *str, int max_cpus, struct bitmask *cpumask)
 {
 	struct bitmask *curmask;
 	int i;
 
 	curmask = numa_allocate_cpumask();
-	numa_sched_getaffinity(getpid(), curmask);
+
+	if (strchr(str, '!') == NULL && strchr(str, '+') == NULL &&
+	    strstr(str, "all") == NULL) {
+		int conf_cpus = numa_num_configured_cpus();
+
+		for (i = 0; i < conf_cpus; i++)
+			numa_bitmask_setbit(curmask, i);
+	} else
+		numa_sched_getaffinity(getpid(), curmask);
 
 	/*
 	 * Clear bits that are not set in both the cpuset from the
@@ -131,7 +140,7 @@ int parse_cpumask(char *str, int max_cpus, struct bitmask **cpumask)
 		return 0;
 	}
 
-	use_current_cpuset(max_cpus, mask);
+	use_current_cpuset(str, max_cpus, mask);
 	*cpumask = mask;
 
 	return 0;


  reply	other threads:[~2022-01-25 18:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21 14:16 [PATCH] rt-numa: optionally ignore runtime cpumask Marcelo Tosatti
2022-01-21 18:16 ` Sebastian Andrzej Siewior
2022-01-24 12:58   ` Marcelo Tosatti
2022-01-24 16:26     ` Sebastian Andrzej Siewior
2022-01-24 16:40       ` Marcelo Tosatti
2022-01-24 16:44         ` Marcelo Tosatti
2022-01-24 17:07         ` Sebastian Andrzej Siewior
2022-01-24 17:50           ` Marcelo Tosatti
2022-01-25 18:40 ` [PATCH] rt-numa: ignore runtime cpumask if -a CPULIST is specified Marcelo Tosatti
2022-01-25 18:46   ` Marcelo Tosatti [this message]
2022-01-26  7:21     ` [PATCH v2] " Sebastian Andrzej Siewior
2022-01-28 17:44     ` John Kacur
2022-01-28 18:17       ` Sebastian Andrzej Siewior
2022-01-28 21:08         ` John Kacur
2022-01-28 18:39       ` [PATCH v3] " Marcelo Tosatti
2022-01-28 21:11         ` John Kacur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YfBFaNrP/1LCgWoN@fuller.cnet \
    --to=mtosatti@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox