diff options
author | Tejun Heo <tj@kernel.org> | 2011-02-16 11:11:09 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2011-02-16 11:11:09 -0500 |
commit | a844ef46fa3055165c28feede6114a711b8375ad (patch) | |
tree | fcbe0deaa1d743bef8ebeed4d37b7089a561d91b /arch/x86/mm | |
parent | 56e827fbde9a3cb886a2fe138db0d99e98efbfb1 (diff) |
x86-64, NUMA: Add common find_node_by_addr()
srat_64.c and amdtopology_64.c had their own versions of
find_node_by_addr() which were basically the same. Add common one in
numa_64.c and remove the duplicates.
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>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r-- | arch/x86/mm/amdtopology_64.c | 13 | ||||
-rw-r--r-- | arch/x86/mm/numa_64.c | 19 | ||||
-rw-r--r-- | arch/x86/mm/srat_64.c | 18 |
3 files changed, 19 insertions, 31 deletions
diff --git a/arch/x86/mm/amdtopology_64.c b/arch/x86/mm/amdtopology_64.c index 90cf297b3b5..8f7a5eb4bd3 100644 --- a/arch/x86/mm/amdtopology_64.c +++ b/arch/x86/mm/amdtopology_64.c | |||
@@ -205,19 +205,6 @@ static s16 fake_apicid_to_node[MAX_LOCAL_APIC] __initdata = { | |||
205 | [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE | 205 | [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE |
206 | }; | 206 | }; |
207 | 207 | ||
208 | static int __init find_node_by_addr(unsigned long addr) | ||
209 | { | ||
210 | int ret = NUMA_NO_NODE; | ||
211 | int i; | ||
212 | |||
213 | for (i = 0; i < 8; i++) | ||
214 | if (addr >= numa_nodes[i].start && addr < numa_nodes[i].end) { | ||
215 | ret = i; | ||
216 | break; | ||
217 | } | ||
218 | return ret; | ||
219 | } | ||
220 | |||
221 | /* | 208 | /* |
222 | * For NUMA emulation, fake proximity domain (_PXM) to node id mappings must be | 209 | * For NUMA emulation, fake proximity domain (_PXM) to node id mappings must be |
223 | * setup to represent the physical topology but reflect the emulated | 210 | * setup to represent the physical topology but reflect the emulated |
diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c index 20aa1d31e16..681bc0d59db 100644 --- a/arch/x86/mm/numa_64.c +++ b/arch/x86/mm/numa_64.c | |||
@@ -430,6 +430,25 @@ void __init numa_emu_cmdline(char *str) | |||
430 | cmdline = str; | 430 | cmdline = str; |
431 | } | 431 | } |
432 | 432 | ||
433 | int __init find_node_by_addr(unsigned long addr) | ||
434 | { | ||
435 | int ret = NUMA_NO_NODE; | ||
436 | int i; | ||
437 | |||
438 | for_each_node_mask(i, mem_nodes_parsed) { | ||
439 | /* | ||
440 | * Find the real node that this emulated node appears on. For | ||
441 | * the sake of simplicity, we only use a real node's starting | ||
442 | * address to determine which emulated node it appears on. | ||
443 | */ | ||
444 | if (addr >= numa_nodes[i].start && addr < numa_nodes[i].end) { | ||
445 | ret = i; | ||
446 | break; | ||
447 | } | ||
448 | } | ||
449 | return ret; | ||
450 | } | ||
451 | |||
433 | static int __init setup_physnodes(unsigned long start, unsigned long end) | 452 | static int __init setup_physnodes(unsigned long start, unsigned long end) |
434 | { | 453 | { |
435 | int ret = 0; | 454 | int ret = 0; |
diff --git a/arch/x86/mm/srat_64.c b/arch/x86/mm/srat_64.c index d56eff811cd..51d07338d2e 100644 --- a/arch/x86/mm/srat_64.c +++ b/arch/x86/mm/srat_64.c | |||
@@ -277,24 +277,6 @@ static int fake_node_to_pxm_map[MAX_NUMNODES] __initdata = { | |||
277 | static s16 fake_apicid_to_node[MAX_LOCAL_APIC] __initdata = { | 277 | static s16 fake_apicid_to_node[MAX_LOCAL_APIC] __initdata = { |
278 | [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE | 278 | [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE |
279 | }; | 279 | }; |
280 | static int __init find_node_by_addr(unsigned long addr) | ||
281 | { | ||
282 | int ret = NUMA_NO_NODE; | ||
283 | int i; | ||
284 | |||
285 | for_each_node_mask(i, mem_nodes_parsed) { | ||
286 | /* | ||
287 | * Find the real node that this emulated node appears on. For | ||
288 | * the sake of simplicity, we only use a real node's starting | ||
289 | * address to determine which emulated node it appears on. | ||
290 | */ | ||
291 | if (addr >= numa_nodes[i].start && addr < numa_nodes[i].end) { | ||
292 | ret = i; | ||
293 | break; | ||
294 | } | ||
295 | } | ||
296 | return ret; | ||
297 | } | ||
298 | 280 | ||
299 | /* | 281 | /* |
300 | * In NUMA emulation, we need to setup proximity domain (_PXM) to node ID | 282 | * In NUMA emulation, we need to setup proximity domain (_PXM) to node ID |