aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2011-01-23 08:37:41 -0500
committerIngo Molnar <mingo@elte.hu>2011-01-28 08:54:10 -0500
commitde2d9445f1627830ed2ebd00ee9d851986c940b5 (patch)
treef71c90737aefaca45d0e28b904c59660809ea0b3 /arch/x86
parent645a79195f66eb68ef3ab2b21d9829ac3aa085a9 (diff)
x86: Unify node_to_cpumask_map handling between 32 and 64bit
x86_32 has been managing node_to_cpumask_map explicitly from map_cpu_to_node() and friends in a rather ugly way. With previous changes, it's now possible to share the code with 64bit. * When CONFIG_NUMA_EMU is disabled, numa_add/remove_cpu() are implemented in numa.c and shared by 32 and 64bit. CONFIG_NUMA_EMU versions still live in numa_64.c. NUMA_EMU's dependency on 64bit is planned to be removed and the above should go away together. * identify_cpu() now calls numa_add_cpu() for 32bit too. This makes the explicit mask management from map_cpu_to_node() unnecessary. * The whole x86_32 specific map_cpu_to_node() chunk is no longer necessary. Dropped. Signed-off-by: Tejun Heo <tj@kernel.org> Reviewed-by: Pekka Enberg <penberg@kernel.org> Cc: eric.dumazet@gmail.com Cc: yinghai@kernel.org Cc: brgerst@gmail.com Cc: gorcunov@gmail.com Cc: shaohui.zheng@intel.com Cc: rientjes@google.com LKML-Reference: <1295789862-25482-16-git-send-email-tj@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: David Rientjes <rientjes@google.com> Cc: Shaohui Zheng <shaohui.zheng@intel.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/numa.h9
-rw-r--r--arch/x86/include/asm/numa_32.h1
-rw-r--r--arch/x86/include/asm/numa_64.h4
-rw-r--r--arch/x86/kernel/cpu/common.c2
-rw-r--r--arch/x86/kernel/smpboot.c47
-rw-r--r--arch/x86/mm/numa.c64
-rw-r--r--arch/x86/mm/numa_64.c75
7 files changed, 87 insertions, 115 deletions
diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h
index 2b21fff9f655..d3964b28b128 100644
--- a/arch/x86/include/asm/numa.h
+++ b/arch/x86/include/asm/numa.h
@@ -1,6 +1,7 @@
1#ifndef _ASM_X86_NUMA_H 1#ifndef _ASM_X86_NUMA_H
2#define _ASM_X86_NUMA_H 2#define _ASM_X86_NUMA_H
3 3
4#include <asm/topology.h>
4#include <asm/apicdef.h> 5#include <asm/apicdef.h>
5 6
6#ifdef CONFIG_NUMA 7#ifdef CONFIG_NUMA
@@ -33,9 +34,17 @@ static inline void set_apicid_to_node(int apicid, s16 node)
33#ifdef CONFIG_NUMA 34#ifdef CONFIG_NUMA
34extern void __cpuinit numa_set_node(int cpu, int node); 35extern void __cpuinit numa_set_node(int cpu, int node);
35extern void __cpuinit numa_clear_node(int cpu); 36extern void __cpuinit numa_clear_node(int cpu);
37extern void __cpuinit numa_add_cpu(int cpu);
38extern void __cpuinit numa_remove_cpu(int cpu);
36#else /* CONFIG_NUMA */ 39#else /* CONFIG_NUMA */
37static inline void numa_set_node(int cpu, int node) { } 40static inline void numa_set_node(int cpu, int node) { }
38static inline void numa_clear_node(int cpu) { } 41static inline void numa_clear_node(int cpu) { }
42static inline void numa_add_cpu(int cpu) { }
43static inline void numa_remove_cpu(int cpu) { }
39#endif /* CONFIG_NUMA */ 44#endif /* CONFIG_NUMA */
40 45
46#ifdef CONFIG_DEBUG_PER_CPU_MAPS
47struct cpumask __cpuinit *debug_cpumask_set_cpu(int cpu, int enable);
48#endif
49
41#endif /* _ASM_X86_NUMA_H */ 50#endif /* _ASM_X86_NUMA_H */
diff --git a/arch/x86/include/asm/numa_32.h b/arch/x86/include/asm/numa_32.h
index cdf8043d7a1a..bc66031afa1f 100644
--- a/arch/x86/include/asm/numa_32.h
+++ b/arch/x86/include/asm/numa_32.h
@@ -4,7 +4,6 @@
4extern int numa_off; 4extern int numa_off;
5 5
6extern int pxm_to_nid(int pxm); 6extern int pxm_to_nid(int pxm);
7extern void numa_remove_cpu(int cpu);
8 7
9#ifdef CONFIG_NUMA 8#ifdef CONFIG_NUMA
10extern int __cpuinit numa_cpu_node(int apicid); 9extern int __cpuinit numa_cpu_node(int apicid);
diff --git a/arch/x86/include/asm/numa_64.h b/arch/x86/include/asm/numa_64.h
index 6ead9f361bda..123f1856101c 100644
--- a/arch/x86/include/asm/numa_64.h
+++ b/arch/x86/include/asm/numa_64.h
@@ -30,8 +30,6 @@ extern void setup_node_bootmem(int nodeid, unsigned long start,
30 30
31extern void __init init_cpu_to_node(void); 31extern void __init init_cpu_to_node(void);
32extern int __cpuinit numa_cpu_node(int cpu); 32extern int __cpuinit numa_cpu_node(int cpu);
33extern void __cpuinit numa_add_cpu(int cpu);
34extern void __cpuinit numa_remove_cpu(int cpu);
35 33
36#ifdef CONFIG_NUMA_EMU 34#ifdef CONFIG_NUMA_EMU
37#define FAKE_NODE_MIN_SIZE ((u64)32 << 20) 35#define FAKE_NODE_MIN_SIZE ((u64)32 << 20)
@@ -41,8 +39,6 @@ void numa_emu_cmdline(char *);
41#else 39#else
42static inline void init_cpu_to_node(void) { } 40static inline void init_cpu_to_node(void) { }
43static inline int numa_cpu_node(int cpu) { return NUMA_NO_NODE; } 41static inline int numa_cpu_node(int cpu) { return NUMA_NO_NODE; }
44static inline void numa_add_cpu(int cpu, int node) { }
45static inline void numa_remove_cpu(int cpu) { }
46#endif 42#endif
47 43
48#endif /* _ASM_X86_NUMA_64_H */ 44#endif /* _ASM_X86_NUMA_64_H */
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 1d59834396bd..a2559c3ed500 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -869,7 +869,7 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
869 869
870 select_idle_routine(c); 870 select_idle_routine(c);
871 871
872#if defined(CONFIG_NUMA) && defined(CONFIG_X86_64) 872#ifdef CONFIG_NUMA
873 numa_add_cpu(smp_processor_id()); 873 numa_add_cpu(smp_processor_id());
874#endif 874#endif
875} 875}
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 2c203822424f..522b2173888a 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -132,49 +132,6 @@ EXPORT_PER_CPU_SYMBOL(cpu_info);
132 132
133atomic_t init_deasserted; 133atomic_t init_deasserted;
134 134
135#if defined(CONFIG_NUMA) && defined(CONFIG_X86_32)
136/* set up a mapping between cpu and node. */
137static void map_cpu_to_node(int cpu, int node)
138{
139 printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node);
140 cpumask_set_cpu(cpu, node_to_cpumask_map[node]);
141}
142
143/* undo a mapping between cpu and node. */
144static void unmap_cpu_to_node(int cpu)
145{
146 int node;
147
148 printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu);
149 for (node = 0; node < MAX_NUMNODES; node++)
150 cpumask_clear_cpu(cpu, node_to_cpumask_map[node]);
151}
152#else /* !(CONFIG_NUMA && CONFIG_X86_32) */
153#define map_cpu_to_node(cpu, node) ({})
154#define unmap_cpu_to_node(cpu) ({})
155#endif
156
157#ifdef CONFIG_X86_32
158static void map_cpu_to_logical_apicid(void)
159{
160 int cpu = smp_processor_id();
161 int node;
162
163 node = numa_cpu_node(cpu);
164 if (!node_online(node))
165 node = first_online_node;
166
167 map_cpu_to_node(cpu, node);
168}
169
170void numa_remove_cpu(int cpu)
171{
172 unmap_cpu_to_node(cpu);
173}
174#else
175#define map_cpu_to_logical_apicid() do {} while (0)
176#endif
177
178/* 135/*
179 * Report back to the Boot Processor. 136 * Report back to the Boot Processor.
180 * Running on AP. 137 * Running on AP.
@@ -242,7 +199,6 @@ static void __cpuinit smp_callin(void)
242 apic->smp_callin_clear_local_apic(); 199 apic->smp_callin_clear_local_apic();
243 setup_local_APIC(); 200 setup_local_APIC();
244 end_local_APIC_setup(); 201 end_local_APIC_setup();
245 map_cpu_to_logical_apicid();
246 202
247 /* 203 /*
248 * Need to setup vector mappings before we enable interrupts. 204 * Need to setup vector mappings before we enable interrupts.
@@ -943,7 +899,6 @@ static __init void disable_smp(void)
943 physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); 899 physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map);
944 else 900 else
945 physid_set_mask_of_physid(0, &phys_cpu_present_map); 901 physid_set_mask_of_physid(0, &phys_cpu_present_map);
946 map_cpu_to_logical_apicid();
947 cpumask_set_cpu(0, cpu_sibling_mask(0)); 902 cpumask_set_cpu(0, cpu_sibling_mask(0));
948 cpumask_set_cpu(0, cpu_core_mask(0)); 903 cpumask_set_cpu(0, cpu_core_mask(0));
949} 904}
@@ -1120,8 +1075,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1120 1075
1121 end_local_APIC_setup(); 1076 end_local_APIC_setup();
1122 1077
1123 map_cpu_to_logical_apicid();
1124
1125 if (apic->setup_portio_remap) 1078 if (apic->setup_portio_remap)
1126 apic->setup_portio_remap(); 1079 apic->setup_portio_remap();
1127 1080
diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index 187810be3d6c..75abecb614c9 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -99,7 +99,21 @@ void __init setup_node_to_cpumask_map(void)
99 pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids); 99 pr_debug("Node to cpumask map for %d nodes\n", nr_node_ids);
100} 100}
101 101
102#ifdef CONFIG_DEBUG_PER_CPU_MAPS 102#ifndef CONFIG_DEBUG_PER_CPU_MAPS
103
104# ifndef CONFIG_NUMA_EMU
105void __cpuinit numa_add_cpu(int cpu)
106{
107 cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);
108}
109
110void __cpuinit numa_remove_cpu(int cpu)
111{
112 cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]);
113}
114# endif /* !CONFIG_NUMA_EMU */
115
116#else /* !CONFIG_DEBUG_PER_CPU_MAPS */
103 117
104int __cpu_to_node(int cpu) 118int __cpu_to_node(int cpu)
105{ 119{
@@ -131,6 +145,52 @@ int early_cpu_to_node(int cpu)
131 return per_cpu(x86_cpu_to_node_map, cpu); 145 return per_cpu(x86_cpu_to_node_map, cpu);
132} 146}
133 147
148struct cpumask __cpuinit *debug_cpumask_set_cpu(int cpu, int enable)
149{
150 int node = early_cpu_to_node(cpu);
151 struct cpumask *mask;
152 char buf[64];
153
154 mask = node_to_cpumask_map[node];
155 if (!mask) {
156 pr_err("node_to_cpumask_map[%i] NULL\n", node);
157 dump_stack();
158 return NULL;
159 }
160
161 cpulist_scnprintf(buf, sizeof(buf), mask);
162 printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n",
163 enable ? "numa_add_cpu" : "numa_remove_cpu",
164 cpu, node, buf);
165 return mask;
166}
167
168# ifndef CONFIG_NUMA_EMU
169static void __cpuinit numa_set_cpumask(int cpu, int enable)
170{
171 struct cpumask *mask;
172
173 mask = debug_cpumask_set_cpu(cpu, enable);
174 if (!mask)
175 return;
176
177 if (enable)
178 cpumask_set_cpu(cpu, mask);
179 else
180 cpumask_clear_cpu(cpu, mask);
181}
182
183void __cpuinit numa_add_cpu(int cpu)
184{
185 numa_set_cpumask(cpu, 1);
186}
187
188void __cpuinit numa_remove_cpu(int cpu)
189{
190 numa_set_cpumask(cpu, 0);
191}
192# endif /* !CONFIG_NUMA_EMU */
193
134/* 194/*
135 * Returns a pointer to the bitmask of CPUs on Node 'node'. 195 * Returns a pointer to the bitmask of CPUs on Node 'node'.
136 */ 196 */
@@ -154,4 +214,4 @@ const struct cpumask *cpumask_of_node(int node)
154} 214}
155EXPORT_SYMBOL(cpumask_of_node); 215EXPORT_SYMBOL(cpumask_of_node);
156 216
157#endif /* CONFIG_DEBUG_PER_CPU_MAPS */ 217#endif /* !CONFIG_DEBUG_PER_CPU_MAPS */
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c
index f5459400644d..14664f58a759 100644
--- a/arch/x86/mm/numa_64.c
+++ b/arch/x86/mm/numa_64.c
@@ -726,19 +726,18 @@ int __cpuinit numa_cpu_node(int cpu)
726 return NUMA_NO_NODE; 726 return NUMA_NO_NODE;
727} 727}
728 728
729#ifndef CONFIG_DEBUG_PER_CPU_MAPS 729/*
730 730 * UGLINESS AHEAD: Currently, CONFIG_NUMA_EMU is 64bit only and makes use
731#ifndef CONFIG_NUMA_EMU 731 * of 64bit specific data structures. The distinction is artificial and
732void __cpuinit numa_add_cpu(int cpu) 732 * should be removed. numa_{add|remove}_cpu() are implemented in numa.c
733{ 733 * for both 32 and 64bit when CONFIG_NUMA_EMU is disabled but here when
734 cpumask_set_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); 734 * enabled.
735} 735 *
736 736 * NUMA emulation is planned to be made generic and the following and other
737void __cpuinit numa_remove_cpu(int cpu) 737 * related code should be moved to numa.c.
738{ 738 */
739 cpumask_clear_cpu(cpu, node_to_cpumask_map[early_cpu_to_node(cpu)]); 739#ifdef CONFIG_NUMA_EMU
740} 740# ifndef CONFIG_DEBUG_PER_CPU_MAPS
741#else
742void __cpuinit numa_add_cpu(int cpu) 741void __cpuinit numa_add_cpu(int cpu)
743{ 742{
744 unsigned long addr; 743 unsigned long addr;
@@ -778,47 +777,7 @@ void __cpuinit numa_remove_cpu(int cpu)
778 for_each_online_node(i) 777 for_each_online_node(i)
779 cpumask_clear_cpu(cpu, node_to_cpumask_map[i]); 778 cpumask_clear_cpu(cpu, node_to_cpumask_map[i]);
780} 779}
781#endif /* !CONFIG_NUMA_EMU */ 780# else /* !CONFIG_DEBUG_PER_CPU_MAPS */
782
783#else /* CONFIG_DEBUG_PER_CPU_MAPS */
784static struct cpumask __cpuinit *debug_cpumask_set_cpu(int cpu, int enable)
785{
786 int node = early_cpu_to_node(cpu);
787 struct cpumask *mask;
788 char buf[64];
789
790 mask = node_to_cpumask_map[node];
791 if (!mask) {
792 pr_err("node_to_cpumask_map[%i] NULL\n", node);
793 dump_stack();
794 return NULL;
795 }
796
797 cpulist_scnprintf(buf, sizeof(buf), mask);
798 printk(KERN_DEBUG "%s cpu %d node %d: mask now %s\n",
799 enable ? "numa_add_cpu" : "numa_remove_cpu",
800 cpu, node, buf);
801 return mask;
802}
803
804/*
805 * --------- debug versions of the numa functions ---------
806 */
807#ifndef CONFIG_NUMA_EMU
808static void __cpuinit numa_set_cpumask(int cpu, int enable)
809{
810 struct cpumask *mask;
811
812 mask = debug_cpumask_set_cpu(cpu, enable);
813 if (!mask)
814 return;
815
816 if (enable)
817 cpumask_set_cpu(cpu, mask);
818 else
819 cpumask_clear_cpu(cpu, mask);
820}
821#else
822static void __cpuinit numa_set_cpumask(int cpu, int enable) 781static void __cpuinit numa_set_cpumask(int cpu, int enable)
823{ 782{
824 int node = early_cpu_to_node(cpu); 783 int node = early_cpu_to_node(cpu);
@@ -842,7 +801,6 @@ static void __cpuinit numa_set_cpumask(int cpu, int enable)
842 cpumask_clear_cpu(cpu, mask); 801 cpumask_clear_cpu(cpu, mask);
843 } 802 }
844} 803}
845#endif /* CONFIG_NUMA_EMU */
846 804
847void __cpuinit numa_add_cpu(int cpu) 805void __cpuinit numa_add_cpu(int cpu)
848{ 806{
@@ -853,8 +811,5 @@ void __cpuinit numa_remove_cpu(int cpu)
853{ 811{
854 numa_set_cpumask(cpu, 0); 812 numa_set_cpumask(cpu, 0);
855} 813}
856/* 814# endif /* !CONFIG_DEBUG_PER_CPU_MAPS */
857 * --------- end of debug versions of the numa functions --------- 815#endif /* CONFIG_NUMA_EMU */
858 */
859
860#endif /* CONFIG_DEBUG_PER_CPU_MAPS */