Skip to contentSkip to conversation

Simple Topology API v0.2

PATCH New Matthew Dobson 1 participant 1 message Jul 25, 2002

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
diff -Nur linux-2.5.27-vanilla/arch/i386/config.in linux-2.5.27-api/arch/i386/config.in
@@ -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
diff -Nur linux-2.5.27-vanilla/arch/i386/kernel/entry.S linux-2.5.27-api/arch/i386/kernel/entry.S
@@ -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
diff -Nur linux-2.5.27-vanilla/arch/i386/kernel/smpboot.c linux-2.5.27-api/arch/i386/kernel/smpboot.c
@@ -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
diff -Nur linux-2.5.27-vanilla/include/asm-i386/smp.h linux-2.5.27-api/include/asm-i386/smp.h
@@ -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
diff -Nur linux-2.5.27-vanilla/include/asm-i386/unistd.h linux-2.5.27-api/include/asm-i386/unistd.h
@@ -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
diff -Nur linux-2.5.27-vanilla/include/linux/mmzone.h linux-2.5.27-api/include/linux/mmzone.h
@@ -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
diff -Nur linux-2.5.27-vanilla/include/linux/prctl.h linux-2.5.27-api/include/linux/prctl.h
@@ -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
diff -Nur linux-2.5.27-vanilla/include/linux/smp.h linux-2.5.27-api/include/linux/smp.h
@@ -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
diff -Nur linux-2.5.27-vanilla/kernel/Makefile linux-2.5.27-api/kernel/Makefile
@@ -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
diff -Nur linux-2.5.27-vanilla/kernel/sys.c linux-2.5.27-api/kernel/sys.c
@@ -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(&current->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