All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cobalt/sched: Save one cpumask stack variable in affinity_vfile_store
@ 2021-10-12 16:57 Jan Kiszka
  0 siblings, 0 replies; only message in thread
From: Jan Kiszka @ 2021-10-12 16:57 UTC (permalink / raw)
  To: Xenomai

From: Jan Kiszka <jan.kiszka@siemens.com>

This brings us below default CONFIG_FRAME_WARN with CONFIG_MAXSMP=y on
x86, avoiding the related compile-time warning.

Reported-by: Florian Bezdeka <florian.bezdeka@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

The first idea was to make the vars static, but the handler is actually 
not running under any lock, thus this would have been ugly - at best.

 kernel/cobalt/sched.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 222d0dd408..88c4951ed8 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -1381,7 +1381,7 @@ static int affinity_vfile_show(struct xnvfile_regular_iterator *it,
 
 static ssize_t affinity_vfile_store(struct xnvfile_input *input)
 {
-	cpumask_t affinity, set;
+	cpumask_t affinity;
 	ssize_t ret;
 	long val;
 	int cpu;
@@ -1396,21 +1396,21 @@ static ssize_t affinity_vfile_store(struct xnvfile_input *input)
 	else {
 		cpumask_clear(&affinity);
 		for (cpu = 0; cpu < BITS_PER_LONG; cpu++, val >>= 1) {
-			if (val & 1)
+			if (val & 1) {
+				/*
+				 * The new dynamic affinity must be a strict
+				 * subset of the static set of supported CPUs.
+				 */
+				if (!cpumask_test_cpu(cpu,
+						      &xnsched_realtime_cpus))
+					return -EINVAL;
 				cpumask_set_cpu(cpu, &affinity);
+			}
 		}
 	}
 
-	cpumask_and(&set, &affinity, cpu_online_mask);
-	if (cpumask_empty(&set))
-		return -EINVAL;
-
-	/*
-	 * The new dynamic affinity must be a strict subset of the
-	 * static set of supported CPUs.
-	 */
-	cpumask_or(&set, &affinity, &xnsched_realtime_cpus);
-	if (!cpumask_equal(&set, &xnsched_realtime_cpus))
+	cpumask_and(&affinity, &affinity, cpu_online_mask);
+	if (cpumask_empty(&affinity))
 		return -EINVAL;
 
 	xnlock_get_irqsave(&nklock, s);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-12 16:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12 16:57 [PATCH] cobalt/sched: Save one cpumask stack variable in affinity_vfile_store Jan Kiszka

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.