Skip to contentSkip to conversation

sys_sched_setaffinity() on UP should fail for non-zero CPUs.

PATCH New Rusty Russell 1 participant 1 message Nov 30, 2004 Scheduler

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sys_sched_setaffinity() on UP should fail for non-zero CPUs.

Name: Return EINVAL for invalid sched_setaffinity on UP
Status: Tested on 2.6.10-rc2-bk13

I was a little surprised that sys_sched_setaffinity for CPU 1 didn't fail on my UP box. With CONFIG_SMP it would have.

include/linux/sched.h +3 -0
Index: linux-2.6.10-rc2-bk13-Misc/include/linux/sched.h
===================================================================
@@ -13,6 +13,7 @@
 #include <linux/rbtree.h>
 #include <linux/thread_info.h>
 #include <linux/cpumask.h>
+#include <linux/errno.h>
 
 #include <asm/system.h>
 #include <asm/semaphore.h>
@@ -708,6 +709,8 @@
 #else
 static inline int set_cpus_allowed(task_t *p, cpumask_t new_mask)
 {
+	if (!cpus_intersects(new_mask, cpu_online_map))
+		return -EINVAL;
 	return 0;
 }
 #endif
Signature · 1 line
A bad analogy is like a leaky screwdriver -- Richard Braakman