Simple Topology API v0.3 (2/2)
PATCH 1/1 Simple Topology API v0.3 (2/2)
Andrew, Linus, et al:
Here's the latest version of the Simple Topology API. I've broken the patches
into a solely in-kernel portion, and a portion that exposes the API to userspace via syscalls and prctl. This patch (part 2) is the userspace part. I hope that the smaller versions of these patches will draw more feedback, comments, flames, etc. Other than that, the patch remains relatively unchanged from the last posting.
Cheers!
-Matt
arch/i386/kernel/entry.S +1 -0
@@ -753,6 +753,7 @@ .long sys_sched_setaffinity .long sys_sched_getaffinity .long sys_set_thread_area + .long sys_check_topology .rept NR_syscalls-(.-sys_call_table)/4 .long sys_ni_syscall
include/asm-i386/unistd.h +1 -0
@@ -248,6 +248,7 @@#define __NR_sched_setaffinity 241#define __NR_sched_getaffinity 242#define __NR_set_thread_area 243 +#define __NR_check_topology 244/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
include/linux/prctl.h +4 -0
@@ -26,4 +26,8 @@# define PR_FPEMU_NOPRINT 1/* silently emulate fp operations accesses */ # define PR_FPEMU_SIGFPE 2/* don't emulate fp operations, send SIGFPE instead */ +/* Get CPU/Node */ +#define PR_GET_CURR_CPU 11 +#define PR_GET_CURR_NODE 12 +#endif /* _LINUX_PRCTL_H */
include/linux/topology.h +46 -0
46 lines not on this page · raw message
kernel/Makefile +2 -1
@@ -15,7 +15,8 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ module.o exit.o itimer.o time.o softirq.o resource.o \ sysctl.o capability.o ptrace.o timer.o user.o \ - signal.o sys.o kmod.o context.o futex.o platform.o + signal.o sys.o kmod.o context.o futex.o platform.o \ + topology.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o obj-$(CONFIG_SMP) += cpu.o
kernel/sys.c +32 -0
@@ -20,6 +20,7 @@#include <linux/device.h> #include <linux/times.h> #include <linux/security.h> +#include <linux/topology.h> #include <asm/uaccess.h> #include <asm/io.h>
@@ -1236,6 +1237,31 @@ mask =xchg (¤t->fs->umask, mask &S_IRWXUGO );return mask; } + +asmlinkage long sys_check_topology (int convert_type,int to_convert) +{ +int ret =0 ; + +switch (convert_type) { +case CPU_TO_NODE : + ret =cpu_to_node (to_convert); +break ; +case MEMBLK_TO_NODE : + ret =memblk_to_node (to_convert); +break ; +case NODE_TO_NODE : + ret =node_to_node (to_convert); +break ; +case NODE_TO_CPU : + ret =node_to_cpu (to_convert); +break ; +case NODE_TO_MEMBLK : + ret =node_to_memblk (to_convert); +break ; + } + +return (long )ret; +}asmlinkage long sys_prctl (int option,unsigned long arg2,unsigned long arg3,unsigned long arg4,unsigned long arg5)
@@ -1295,6 +1321,12 @@ } current->keep_capabilities = arg2;break ; +case PR_GET_CURR_CPU : + error =get_curr_cpu (); +break ; +case PR_GET_CURR_NODE : + error =get_curr_node (); +break ;default : error = -EINVAL ;break ;
kernel/topology.c +127 -0
127 lines not on this page · raw message
Quoted 30 lines · Matthew Dobson
diff -Nur
linux-2.5.27-vanilla/kernel/sys.clinux-2.5.27-api/kernel/sys.ckernel/sys.c +16
-0@@ -20,6 +20,7 @@#include <linux/device.h> #include <linux/times.h> #include <linux/security.h> +#include <linux/topology.h> #include <asm/uaccess.h> #include <asm/io.h> @@ -1236,6 +1237,31 @@ mask =xchg (¤t->fs->umask, mask &S_IRWXUGO );return mask; } + +asmlinkage long sys_check_topology (int convert_type,int to_convert) +{ +int ret =0 ; + +switch (convert_type) { +case CPU_TO_NODE : + ret =cpu_to_node (to_convert); +break ; +case MEMBLK_TO_NODE : + ret =memblk_to_node (to_convert); +break ; +case NODE_TO_NODE : + ret =node_to_node (to_convert); +break ;
kernel/sys.c line 1264
Quoted 10 lines
kernel/sys.c +10
-0+case NODE_TO_CPU : + ret =node_to_cpu (to_convert); +break ; +case NODE_TO_MEMBLK : + ret =node_to_memblk (to_convert); +break ; + } + +return (long )ret; +}
You don't consider this a proper syscall API, do you?
Christoph,
I've had some comments/flames about that... One of the better suggestions that
I've heard so far is to change it to a /proc interface. I'll probably do that today and resent the userspace patch. If you (or anyone) has better suggestions, I'm definitely all ears (or eyes, I suppose ;)!
Cheers!
-Matt
Quoted 47 lines · Christoph Hellwig
Quoted 30 lines · Matthew Dobson
diff -Nur
linux-2.5.27-vanilla/kernel/sys.clinux-2.5.27-api/kernel/sys.ckernel/sys.c +16
-0@@ -20,6 +20,7 @@#include <linux/device.h> #include <linux/times.h> #include <linux/security.h> +#include <linux/topology.h> #include <asm/uaccess.h> #include <asm/io.h> @@ -1236,6 +1237,31 @@ mask =xchg (¤t->fs->umask, mask &S_IRWXUGO );return mask; } + +asmlinkage long sys_check_topology (int convert_type,int to_convert) +{ +int ret =0 ; + +switch (convert_type) { +case CPU_TO_NODE : + ret =cpu_to_node (to_convert); +break ; +case MEMBLK_TO_NODE : + ret =memblk_to_node (to_convert); +break ; +case NODE_TO_NODE : + ret =node_to_node (to_convert); +break ;kernel/sys.c line 1264
Quoted 10 lines
kernel/sys.c +10
-0+case NODE_TO_CPU : + ret =node_to_cpu (to_convert); +break ; +case NODE_TO_MEMBLK : + ret =node_to_memblk (to_convert); +break ; + } + +return (long )ret; +}You don't consider this a proper syscall API, do you?