Fix asm-i386/topology.h
PATCH 1/1 Fix asm-i386/topology.h
Linus,
This patch fixes some slow, quickly written macros inasm-i386/topology.h. The new versions use value caching in arrays to greatly speed up topology queries.
Please apply.
[mcd@arrakis patches]$ diffstat i386_topology_fixup-2.5.47.patch
arch/i386/kernel/smpboot.c | 43 +++++++++++++++++++++++++++++++++++++++++++ include/asm-i386/smpboot.h | 8 ++++++++ include/asm-i386/topology.h | 43 +++++-------------------------------------- 3 files changed, 56 insertions(+), 38 deletions(-)
Cheers!
-Matt
We'll give this another shot, with the patch attatched this time.
Cheers!
-Matt
Quoted 14 lines · Matthew Dobson
Linus,
This patch fixes some slow, quickly written macros inasm-i386/topology.h. The new versions use value caching in arrays to greatly speed up topology queries.Please apply.
[mcd@arrakis patches]$ diffstat i386_topology_fixup-2.5.47.patch
arch/i386/kernel/smpboot.c | 43 +++++++++++++++++++++++++++++++++++++++++++ include/asm-i386/smpboot.h | 8 ++++++++ include/asm-i386/topology.h | 43 +++++-------------------------------------- 3 files changed, 56 insertions(+), 38 deletions(-)
Quoted 4 lines
Cheers!
-Matt
arch/i386/kernel/smpboot.c +43 -0
@@ -501,6 +501,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 */
@@ -524,6 +564,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)
@@ -535,6 +576,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;
@@ -550,6 +592,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