All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rt-numa: optionally ignore runtime cpumask
@ 2022-01-21 14:16 Marcelo Tosatti
  2022-01-21 18:16 ` Sebastian Andrzej Siewior
  2022-01-25 18:40 ` [PATCH] rt-numa: ignore runtime cpumask if -a CPULIST is specified Marcelo Tosatti
  0 siblings, 2 replies; 16+ messages in thread
From: Marcelo Tosatti @ 2022-01-21 14:16 UTC (permalink / raw)
  To: linux-rt-users; +Cc: John Kacur


use_current_cpuset() function does:

/*
 * After this function is called, affinity_mask is the intersection of
 * 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)

However, when using isolcpus kernel command line option, the CPUs 
specificied 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, add an environment variable IGNORE_RUNTIME_CPU_AFFINITY_MASK
that when set to a value other than 0, will override the runtime cpu
affinity mask (retrieved with numa_sched_getaffinity) with a bit set
for each CPU in numa_num_configured_cpus:

numa_num_configured_cpus() returns the number of cpus in the system.
This count includes any cpus that are currently disabled. This count is
derived from the cpu numbers in /sys/devices/system/cpu. If the kernel
is configured without /sys (CONFIG_SYSFS=n) then it falls back to using
the number of online cpus.

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

diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c
index ee5ab99..3106f1e 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"
@@ -99,11 +100,20 @@ int cpu_for_thread_ua(int thread_num, int max_cpus)
 static void use_current_cpuset(int max_cpus, struct bitmask *cpumask)
 {
 	struct bitmask *curmask;
+	char *ignore_affinity_mask;
 	int i;
 
 	curmask = numa_allocate_cpumask();
 	numa_sched_getaffinity(getpid(), curmask);
 
+	ignore_affinity_mask = getenv("IGNORE_RUNTIME_CPU_AFFINITY_MASK");
+	if (ignore_affinity_mask && *ignore_affinity_mask != '0') {
+		int conf_cpus = numa_num_configured_cpus();
+
+		for (i = 0; i < conf_cpus; i++)
+			numa_bitmask_setbit(curmask, i);
+	}
+
 	/*
 	 * Clear bits that are not set in both the cpuset from the
 	 * environment, and in the user specified affinity.


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-01-28 21:11 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [PATCH v2] " Marcelo Tosatti
2022-01-26  7:21     ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.