[PATCH] sys_sched_setaffinity() on UP should fail for non-zeroCPUs.

From: Rusty Russell
Date: Mon Nov 29 2004 - 23:40:26 EST


Name: Return EINVAL for invalid sched_setaffinity on UP
Status: Tested on 2.6.10-rc2-bk13
Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>

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.

Index: linux-2.6.10-rc2-bk13-Misc/include/linux/sched.h
===================================================================
--- linux-2.6.10-rc2-bk13-Misc.orig/include/linux/sched.h 2004-11-16 15:30:07.000000000 +1100
+++ linux-2.6.10-rc2-bk13-Misc/include/linux/sched.h 2004-11-30 14:09:38.000000000 +1100
@@ -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

--
A bad analogy is like a leaky screwdriver -- Richard Braakman

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/