i386 Topology update
PATCH 1/1 i386 Topology update
Linus,
This patch updates the i386 Topology macros to be much more efficient.
The functions there now are relatively slow searches, and these are simple array lookups. #ifdef'd out for non-NUMAQ.
i386_topo_fixup.patch
Updates include/asm-i386/topology.h to read values from an array populated at boot time with cpu<->node mapping information, rather than calculating this information each time it is called.
Please apply...
Cheers!
-Matt
arch/i386/kernel/smpboot.c +43 -0
@@ -500,6 +500,46 @@return do_fork (CLONE_VM |CLONE_IDLETASK ,0 , ®s,0 ,NULL ); } +#ifdef CONFIG_X86_NUMAQ +/* which logical CPUs are on which nodes */ +volatile unsigned long node_2_cpu_mask[MAX_NR_NODES ]; +/* which node each logical CPU is on */ +volatile int cpu_2_node[NR_CPUS ]; + +/* Initialize all maps between cpu number and node */ +static inline void init_cpu_to_node_mapping (void ) +{ +int node, cpu; + +for (node =0 ; node <MAX_NR_NODES ; node++) { + node_2_cpu_mask[node] =0 ; + } +for (cpu =0 ; cpu <NR_CPUS ; cpu++) { + cpu_2_node[cpu] =-1 ; + } +} + +/* set up a mapping between cpu and node. */ +static inline void map_cpu_to_node (int cpu,int node) +{ + node_2_cpu_mask[node] |= (1 << cpu); + cpu_2_node[cpu] = node; +} + +/* undo a mapping between cpu and node. */ +static inline void unmap_cpu_to_node (int cpu,int node) +{ + node_2_cpu_mask[node] &= ~(1 << cpu); + cpu_2_node[cpu] =-1 ; +} +#else /* !CONFIG_X86_NUMAQ */ + +#define init_cpu_to_node_mapping () ({}) +#define map_cpu_to_node (cpu, node) ({}) +#define unmap_cpu_to_node (cpu, node) ({}) + +#endif /* CONFIG_X86_NUMAQ */ +/* which physical APIC ID maps to which logical CPU number */ volatile int physical_apicid_2_cpu[MAX_APICID ];/* which logical CPU number maps to which physical APIC ID */
@@ -523,6 +563,7 @@ cpu_2_physical_apicid[cpu] =-1 ; cpu_2_logical_apicid[cpu] =-1 ; } +init_cpu_to_node_mapping (); }static inline void map_cpu_to_boot_apicid (int cpu,int apicid)
@@ -534,6 +575,7 @@if (clustered_apic_mode) { logical_apicid_2_cpu[apicid] = cpu; cpu_2_logical_apicid[cpu] = apicid; +map_cpu_to_node (cpu, apicid >>4 ); }else { physical_apicid_2_cpu[apicid] = cpu; cpu_2_physical_apicid[cpu] = apicid;
@@ -549,6 +591,7 @@if (clustered_apic_mode) { logical_apicid_2_cpu[apicid] =-1 ; cpu_2_logical_apicid[cpu] =-1 ; +unmap_cpu_to_node (cpu, apicid >>4 ); }else { physical_apicid_2_cpu[apicid] =-1 ; cpu_2_physical_apicid[cpu] =-1 ;
include/asm-i386/smpboot.h +8 -0
@@ -23,6 +23,14 @@#define boot_cpu_apicid boot_cpu_physical_apicid#endif /* CONFIG_CLUSTERED_APIC */ +#ifdef CONFIG_X86_NUMAQ +/* +* Mappings between logical cpu number and node number +*/ +extern volatile unsigned long node_2_cpu_mask[]; +extern volatile int cpu_2_node[]; +#endif /* CONFIG_X86_NUMAQ */ +/* * Mappings between logical cpu number and logical / physical apicid * The first four macros are trivial, but it keeps the abstraction consistent
include/asm-i386/topology.h +5 -38
56 lines not on this page · raw message