diff options
author | Tejun Heo <tj@kernel.org> | 2011-02-16 11:11:10 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2011-02-16 11:11:10 -0500 |
commit | 6b78cb549b4105cbf7c6f7461f27a21f00c44997 (patch) | |
tree | fc0e67399cb02445c7f3ca7fcb1f62c41583738c | |
parent | 1cca53407336fb6a86092e36dbc5c1e4d45d912b (diff) |
x86-64, NUMA: Unify emulated apicid -> node mapping transformation
NUMA emulation changes node mappings and thus apicid -> node mapping
needs to be updated accordingly. srat_64 and amdtopology_64 did this
separately; however, all the necessary information is the mapping from
emulated nodes to physical nodes which is available in
emu_nid_to_phys[].
Implement common __apicid_to_node[] transformation in numa_emulation()
and drop duplicate implementations.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Shaohui Zheng <shaohui.zheng@intel.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | arch/x86/mm/amdtopology_64.c | 9 | ||||
-rw-r--r-- | arch/x86/mm/numa_64.c | 16 | ||||
-rw-r--r-- | arch/x86/mm/srat_64.c | 24 |
3 files changed, 16 insertions, 33 deletions
diff --git a/arch/x86/mm/amdtopology_64.c b/arch/x86/mm/amdtopology_64.c index fd7b609025ba..f37ea2fe85e6 100644 --- a/arch/x86/mm/amdtopology_64.c +++ b/arch/x86/mm/amdtopology_64.c | |||
@@ -196,10 +196,6 @@ int __init amd_numa_init(void) | |||
196 | } | 196 | } |
197 | 197 | ||
198 | #ifdef CONFIG_NUMA_EMU | 198 | #ifdef CONFIG_NUMA_EMU |
199 | static s16 fake_apicid_to_node[MAX_LOCAL_APIC] __initdata = { | ||
200 | [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE | ||
201 | }; | ||
202 | |||
203 | /* | 199 | /* |
204 | * For NUMA emulation, fake proximity domain (_PXM) to node id mappings must be | 200 | * For NUMA emulation, fake proximity domain (_PXM) to node id mappings must be |
205 | * setup to represent the physical topology but reflect the emulated | 201 | * setup to represent the physical topology but reflect the emulated |
@@ -224,20 +220,15 @@ void __init amd_fake_nodes(const struct bootnode *nodes, int nr_nodes) | |||
224 | for (i = 0; i < nr_nodes; i++) { | 220 | for (i = 0; i < nr_nodes; i++) { |
225 | int index; | 221 | int index; |
226 | int nid; | 222 | int nid; |
227 | int j; | ||
228 | 223 | ||
229 | nid = find_node_by_addr(nodes[i].start); | 224 | nid = find_node_by_addr(nodes[i].start); |
230 | if (nid == NUMA_NO_NODE) | 225 | if (nid == NUMA_NO_NODE) |
231 | continue; | 226 | continue; |
232 | 227 | ||
233 | index = nodeids[nid] << bits; | 228 | index = nodeids[nid] << bits; |
234 | if (fake_apicid_to_node[index + apicid_base] == NUMA_NO_NODE) | ||
235 | for (j = apicid_base; j < cores + apicid_base; j++) | ||
236 | fake_apicid_to_node[index + j] = i; | ||
237 | #ifdef CONFIG_ACPI_NUMA | 229 | #ifdef CONFIG_ACPI_NUMA |
238 | __acpi_map_pxm_to_node(nid, i); | 230 | __acpi_map_pxm_to_node(nid, i); |
239 | #endif | 231 | #endif |
240 | } | 232 | } |
241 | memcpy(__apicid_to_node, fake_apicid_to_node, sizeof(__apicid_to_node)); | ||
242 | } | 233 | } |
243 | #endif /* CONFIG_NUMA_EMU */ | 234 | #endif /* CONFIG_NUMA_EMU */ |
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c index bd086ebc0ffc..722039e0948f 100644 --- a/arch/x86/mm/numa_64.c +++ b/arch/x86/mm/numa_64.c | |||
@@ -858,7 +858,7 @@ static bool __init numa_emulation(int acpi, int amd) | |||
858 | static struct numa_meminfo ei __initdata; | 858 | static struct numa_meminfo ei __initdata; |
859 | static struct numa_meminfo pi __initdata; | 859 | static struct numa_meminfo pi __initdata; |
860 | const u64 max_addr = max_pfn << PAGE_SHIFT; | 860 | const u64 max_addr = max_pfn << PAGE_SHIFT; |
861 | int i, ret; | 861 | int i, j, ret; |
862 | 862 | ||
863 | memset(&ei, 0, sizeof(ei)); | 863 | memset(&ei, 0, sizeof(ei)); |
864 | pi = numa_meminfo; | 864 | pi = numa_meminfo; |
@@ -894,6 +894,20 @@ static bool __init numa_emulation(int acpi, int amd) | |||
894 | /* commit */ | 894 | /* commit */ |
895 | numa_meminfo = ei; | 895 | numa_meminfo = ei; |
896 | 896 | ||
897 | /* | ||
898 | * Transform __apicid_to_node table to use emulated nids by | ||
899 | * reverse-mapping phys_nid. The maps should always exist but fall | ||
900 | * back to zero just in case. | ||
901 | */ | ||
902 | for (i = 0; i < ARRAY_SIZE(__apicid_to_node); i++) { | ||
903 | if (__apicid_to_node[i] == NUMA_NO_NODE) | ||
904 | continue; | ||
905 | for (j = 0; j < ARRAY_SIZE(emu_nid_to_phys); j++) | ||
906 | if (__apicid_to_node[i] == emu_nid_to_phys[j]) | ||
907 | break; | ||
908 | __apicid_to_node[i] = j < ARRAY_SIZE(emu_nid_to_phys) ? j : 0; | ||
909 | } | ||
910 | |||
897 | /* make sure all emulated nodes are mapped to a physical node */ | 911 | /* make sure all emulated nodes are mapped to a physical node */ |
898 | for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++) | 912 | for (i = 0; i < ARRAY_SIZE(emu_nid_to_phys); i++) |
899 | if (emu_nid_to_phys[i] == NUMA_NO_NODE) | 913 | if (emu_nid_to_phys[i] == NUMA_NO_NODE) |
diff --git a/arch/x86/mm/srat_64.c b/arch/x86/mm/srat_64.c index d2f53f35d86a..d4fbfea53543 100644 --- a/arch/x86/mm/srat_64.c +++ b/arch/x86/mm/srat_64.c | |||
@@ -265,9 +265,6 @@ int __init x86_acpi_numa_init(void) | |||
265 | static int fake_node_to_pxm_map[MAX_NUMNODES] __initdata = { | 265 | static int fake_node_to_pxm_map[MAX_NUMNODES] __initdata = { |
266 | [0 ... MAX_NUMNODES-1] = PXM_INVAL | 266 | [0 ... MAX_NUMNODES-1] = PXM_INVAL |
267 | }; | 267 | }; |
268 | static s16 fake_apicid_to_node[MAX_LOCAL_APIC] __initdata = { | ||
269 | [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE | ||
270 | }; | ||
271 | 268 | ||
272 | /* | 269 | /* |
273 | * In NUMA emulation, we need to setup proximity domain (_PXM) to node ID | 270 | * In NUMA emulation, we need to setup proximity domain (_PXM) to node ID |
@@ -279,7 +276,7 @@ static s16 fake_apicid_to_node[MAX_LOCAL_APIC] __initdata = { | |||
279 | */ | 276 | */ |
280 | void __init acpi_fake_nodes(const struct bootnode *fake_nodes, int num_nodes) | 277 | void __init acpi_fake_nodes(const struct bootnode *fake_nodes, int num_nodes) |
281 | { | 278 | { |
282 | int i, j; | 279 | int i; |
283 | 280 | ||
284 | for (i = 0; i < num_nodes; i++) { | 281 | for (i = 0; i < num_nodes; i++) { |
285 | int nid, pxm; | 282 | int nid, pxm; |
@@ -291,29 +288,10 @@ void __init acpi_fake_nodes(const struct bootnode *fake_nodes, int num_nodes) | |||
291 | if (pxm == PXM_INVAL) | 288 | if (pxm == PXM_INVAL) |
292 | continue; | 289 | continue; |
293 | fake_node_to_pxm_map[i] = pxm; | 290 | fake_node_to_pxm_map[i] = pxm; |
294 | /* | ||
295 | * For each apicid_to_node mapping that exists for this real | ||
296 | * node, it must now point to the fake node ID. | ||
297 | */ | ||
298 | for (j = 0; j < MAX_LOCAL_APIC; j++) | ||
299 | if (__apicid_to_node[j] == nid && | ||
300 | fake_apicid_to_node[j] == NUMA_NO_NODE) | ||
301 | fake_apicid_to_node[j] = i; | ||
302 | } | 291 | } |
303 | 292 | ||
304 | /* | ||
305 | * If there are apicid-to-node mappings for physical nodes that do not | ||
306 | * have a corresponding emulated node, it should default to a guaranteed | ||
307 | * value. | ||
308 | */ | ||
309 | for (i = 0; i < MAX_LOCAL_APIC; i++) | ||
310 | if (__apicid_to_node[i] != NUMA_NO_NODE && | ||
311 | fake_apicid_to_node[i] == NUMA_NO_NODE) | ||
312 | fake_apicid_to_node[i] = 0; | ||
313 | |||
314 | for (i = 0; i < num_nodes; i++) | 293 | for (i = 0; i < num_nodes; i++) |
315 | __acpi_map_pxm_to_node(fake_node_to_pxm_map[i], i); | 294 | __acpi_map_pxm_to_node(fake_node_to_pxm_map[i], i); |
316 | memcpy(__apicid_to_node, fake_apicid_to_node, sizeof(__apicid_to_node)); | ||
317 | 295 | ||
318 | for (i = 0; i < num_nodes; i++) | 296 | for (i = 0; i < num_nodes; i++) |
319 | if (fake_nodes[i].start != fake_nodes[i].end) | 297 | if (fake_nodes[i].start != fake_nodes[i].end) |