Skip to contentSkip to conversation

Fixed set_affinity/get_affinity syscalls

PATCH New Rusty Russell 1 participant 1 message Jun 20, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fixed set_affinity/get_affinity syscalls

It's a little more kernel code, but it allows userspace to do:

     unsigned int mask = (1 << cpu);
     sys_setaffinity(getpid(), LINUX_AFFINITY_INCLUDE, mask, sizeof(mask));

And it will always do the Right Thing.

Applies on top of last patch.
Comments?

Name: Modified set_affinity/get_affinity syscalls
Author: Rusty Russell
Status: Experimental
Depends: Hotcpu/cpumask.patch.gz

D: This allows userspace to have cpu affinity control without needing
D: to know the size of kernel datastructures and allows them to
D: control what happens when new CPUs are brought online. It also
D: means that in the future we can sanely interpret affinity in
D: HyperThreading.

include/linux/affinity.h +9 -0
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal working-2.5.23-sent-to-linus/include/linux/affinity.h working-2.5.23-sched/include/linux/affinity.h
@@ -0,0 +1,9 @@
+#ifndef _LINUX_AFFINITY_H
+#define _LINUX_AFFINITY_H
+enum {
+	/* Set affinity to these processors */
+	LINUX_AFFINITY_INCLUDE,
+	/* Set affinity to all *but* these processors */
+	LINUX_AFFINITY_EXCLUDE,
+};
+#endif
kernel/sched.c +52 -31

126 lines not on this page · raw message

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.