2.4-ac affinity syscalls and how to pin a task?
RFC PATCH 1/1 2.4-ac affinity syscalls and how to pin a task?
The attached patch implements the task cpu affinity interface on top of the O(1) scheduler in 2.4.19-pre7-ac3. The migration_thread is now in -ac3 so we can implement such an interface.
This is the same interface as in 2.5 and posted previously for 2.4 (sans O(1)):
sched_getaffinity(pid_t pid, unsigned long len, unsigned long *mask) sched_setaffinity(pid_t pid, unsigned long len, unsigned long *mask)
Problem:
We need to assure the task stays valid and does not exit, but due to the semantics of set_cpus_allowed and migration_thread we can not hold a lock across a call. In 2.5 we can pin a task via get_task_struct. This assures us, at least, that the task struct is not deallocated until a final call to put_task_struct.
What equivalent mechanism do we have in 2.4? How can we assure a task stays put without grabbing a spinlock?
This patch grabs the tasklist_lock before calling set_cpus_allowed. While this is working fine here and is safe enough to play with now, it is not safe.
Comments?
Robert Love
arch/i386/kernel/entry.S +2 -2
@@ -639,8 +639,8 @@ .long SYMBOL_NAME(sys_tkill) .long SYMBOL_NAME(sys_ni_syscall) /* reserved for sendfile64 */ .long SYMBOL_NAME(sys_ni_syscall) /* 240 reserved for futex */ - .long SYMBOL_NAME(sys_ni_syscall) /* reserved for sched_setaffinity */ - .long SYMBOL_NAME(sys_ni_syscall) /* reserved for sched_getaffinity */ + .long SYMBOL_NAME(sys_sched_setaffinity) + .long SYMBOL_NAME(sys_sched_getaffinity) .rept NR_syscalls-(.-sys_call_table)/4 .long SYMBOL_NAME(sys_ni_syscall)
include/linux/capability.h +1 -0
@@ -243,6 +243,7 @@/* Allow use of FIFO and round-robin (realtime) scheduling on own processes and setting the scheduling algorithm used by another process. */ +/* Allow setting cpu affinity on other processes */ #define CAP_SYS_NICE 23
kernel/sched.c +87 -0
93 lines not on this page · raw message