Simple Topology API v0.2
PATCH 1/1 Simple Topology API v0.2
Here is the latest revision of the Simple Topology API discussed here on LKML last week. The patch is against 2.5.28. I have made changes to incorporate most of the feedback that I got from the last posting. Some of the calls have changed from prctl() to syscalls. A couple of functions have been optimized. Some files and config options have been renamed to be more in-sync with things I expect to happen in the near future. And the locking was revised.
I look forward to additional discussion on both this and the Memory Binding API I'll be posting momentarily.
Cheers!
-Matt
arch/i386/config.in +4 -1
@@ -165,7 +165,10 @@ define_bool CONFIG_X86_IO_APIC y fi else - bool 'Multiquad NUMA system' CONFIG_MULTIQUAD + bool 'Multiquad NUMA system' CONFIG_X86_NUMAQ + if [ "$CONFIG_X86_NUMAQ" = y ]; then + define_bool CONFIG_MULTIQUAD y + fi fi bool 'Machine Check Exception' CONFIG_X86_MCE
arch/i386/kernel/entry.S +1 -0
@@ -753,6 +753,7 @@ .long sys_futex /* 240 */ .long sys_sched_setaffinity .long sys_sched_getaffinity + .long sys_check_topology .rept NR_syscalls-(.-sys_call_table)/4 .long sys_ni_syscall
arch/i386/kernel/smpboot.c +3 -0
@@ -63,6 +63,9 @@/* Bitmask of currently online CPUs */ unsigned long cpu_online_map; +/* Bitmask of currently online memory blocks */ +unsigned long memblk_online_map; +static volatile unsigned long cpu_callin_map;static volatile unsigned long cpu_callout_map;
include/asm-i386/mmzone.h +57 -0
57 lines not on this page · raw message
include/asm-i386/numaq.h +60 -0
60 lines not on this page · raw message
include/asm-i386/smp.h +6 -0
@@ -55,6 +55,7 @@extern void smp_alloc_memory (void );extern unsigned long phys_cpu_present_map;extern unsigned long cpu_online_map; +extern unsigned long memblk_online_map;extern volatile unsigned long smp_invalidate_needed;extern int pic_mode;extern int smp_num_siblings;
@@ -99,6 +100,11 @@return hweight32 (cpu_online_map); } +extern inline unsigned int num_online_memblks (void ) +{ +return hweight32 (memblk_online_map); +} +extern inline int any_online_cpu (unsigned int mask) {if (mask & cpu_online_map)
include/asm-i386/unistd.h +1 -0
@@ -247,6 +247,7 @@#define __NR_futex 240#define __NR_sched_setaffinity 241#define __NR_sched_getaffinity 242 +#define __NR_check_topology 243/* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
include/linux/mmzone.h +3 -3
@@ -9,6 +9,8 @@#include <linux/list.h> #include <linux/wait.h> +#include <asm/mmzone.h> +/* * Free memory management - zoned buddy allocator. */
@@ -169,9 +171,7 @@#define NODE_MEM_MAP (nid) mem_map#define MAX_NR_NODES 1 -#else /* !CONFIG_DISCONTIGMEM */ - -#include <asm/mmzone.h> +#else /* CONFIG_DISCONTIGMEM */ /* page->zone is currently 8 bits ... */ #define MAX_NR_NODES (255 / MAX_NR_ZONES)
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/smp.h +1 -0
@@ -86,6 +86,7 @@#define smp_call_function (func,info,retry,wait) ({ 0; })static inline void smp_send_reschedule (int cpu) { }static inline void smp_send_reschedule_all (void ) { } +#define memblk_online_map 1#define cpu_online_map 1#define cpu_online (cpu) 1#define num_online_cpus () 1
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 dma.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_UID16) += uid16.o obj-$(CONFIG_MODULES) += ksyms.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