diff options
author | Christoph Lameter <christoph@lameter.com> | 2005-06-23 03:08:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-23 12:45:08 -0400 |
commit | 8c5a09082f4e61a176382e96a831a0636b918602 (patch) | |
tree | 89a7086ebbec9d94dc7b7b3483d3750220ba979c | |
parent | e164f5573bef0e6caf53519719cf0228c9c15ce3 (diff) |
[PATCH] x86/x86_64: pcibus_to_node
Define pcibus_to_node to be able to figure out which NUMA node contains a
given PCI device. This defines pcibus_to_node(bus) in
include/linux/topology.h and adjusts the macros for i386 and x86_64 that
already provided a way to determine the cpumask of a pci device.
x86_64 was changed to not build an array of cpumasks anymore. Instead an
array of nodes is build which can be used to generate the cpumask via
node_to_cpumask.
Signed-off-by: Christoph Lameter <christoph@lameter.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/x86_64/kernel/mpparse.c | 4 | ||||
-rw-r--r-- | arch/x86_64/pci/k8-bus.c | 16 | ||||
-rw-r--r-- | include/asm-generic/topology.h | 9 | ||||
-rw-r--r-- | include/asm-i386/topology.h | 8 | ||||
-rw-r--r-- | include/asm-x86_64/topology.h | 14 |
5 files changed, 17 insertions, 34 deletions
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c index 61a63be6b294..ed6a5588146d 100644 --- a/arch/x86_64/kernel/mpparse.c +++ b/arch/x86_64/kernel/mpparse.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/kernel_stat.h> | 23 | #include <linux/kernel_stat.h> |
24 | #include <linux/mc146818rtc.h> | 24 | #include <linux/mc146818rtc.h> |
25 | #include <linux/acpi.h> | 25 | #include <linux/acpi.h> |
26 | #include <linux/module.h> | ||
26 | 27 | ||
27 | #include <asm/smp.h> | 28 | #include <asm/smp.h> |
28 | #include <asm/mtrr.h> | 29 | #include <asm/mtrr.h> |
@@ -45,7 +46,8 @@ int acpi_found_madt; | |||
45 | int apic_version [MAX_APICS]; | 46 | int apic_version [MAX_APICS]; |
46 | unsigned char mp_bus_id_to_type [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 }; | 47 | unsigned char mp_bus_id_to_type [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 }; |
47 | int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 }; | 48 | int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 }; |
48 | cpumask_t pci_bus_to_cpumask [256] = { [0 ... 255] = CPU_MASK_ALL }; | 49 | unsigned char pci_bus_to_node [256]; |
50 | EXPORT_SYMBOL(pci_bus_to_node); | ||
49 | 51 | ||
50 | static int mp_current_pci_id = 0; | 52 | static int mp_current_pci_id = 0; |
51 | /* I/O APIC entries */ | 53 | /* I/O APIC entries */ |
diff --git a/arch/x86_64/pci/k8-bus.c b/arch/x86_64/pci/k8-bus.c index 62349c78db57..7e7d0c2a0025 100644 --- a/arch/x86_64/pci/k8-bus.c +++ b/arch/x86_64/pci/k8-bus.c | |||
@@ -53,25 +53,11 @@ fill_mp_bus_to_cpumask(void) | |||
53 | for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus); | 53 | for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus); |
54 | j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus); | 54 | j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus); |
55 | j++) | 55 | j++) |
56 | pci_bus_to_cpumask[j] = | 56 | pci_bus_to_node[j] = NODE_ID(nid); |
57 | node_to_cpumask(NODE_ID(nid)); | ||
58 | } | 57 | } |
59 | } | 58 | } |
60 | } | 59 | } |
61 | 60 | ||
62 | /* quick sanity check */ | ||
63 | printed = 0; | ||
64 | for (i = 0; i < 256; i++) { | ||
65 | if (cpus_empty(pci_bus_to_cpumask[i])) { | ||
66 | pci_bus_to_cpumask[i] = CPU_MASK_ALL; | ||
67 | if (printed) | ||
68 | continue; | ||
69 | printk(KERN_ERR | ||
70 | "k8-bus.c: some busses have empty cpu mask\n"); | ||
71 | printed = 1; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | return 0; | 61 | return 0; |
76 | } | 62 | } |
77 | 63 | ||
diff --git a/include/asm-generic/topology.h b/include/asm-generic/topology.h index ec96e8b0f190..5d9d70cd17fc 100644 --- a/include/asm-generic/topology.h +++ b/include/asm-generic/topology.h | |||
@@ -41,8 +41,15 @@ | |||
41 | #ifndef node_to_first_cpu | 41 | #ifndef node_to_first_cpu |
42 | #define node_to_first_cpu(node) (0) | 42 | #define node_to_first_cpu(node) (0) |
43 | #endif | 43 | #endif |
44 | #ifndef pcibus_to_node | ||
45 | #define pcibus_to_node(node) (-1) | ||
46 | #endif | ||
47 | |||
44 | #ifndef pcibus_to_cpumask | 48 | #ifndef pcibus_to_cpumask |
45 | #define pcibus_to_cpumask(bus) (cpu_online_map) | 49 | #define pcibus_to_cpumask(bus) (pcibus_to_node(bus) == -1 ? \ |
50 | CPU_MASK_ALL : \ | ||
51 | node_to_cpumask(pcibus_to_node(bus)) \ | ||
52 | ) | ||
46 | #endif | 53 | #endif |
47 | 54 | ||
48 | #endif /* _ASM_GENERIC_TOPOLOGY_H */ | 55 | #endif /* _ASM_GENERIC_TOPOLOGY_H */ |
diff --git a/include/asm-i386/topology.h b/include/asm-i386/topology.h index 98f9e6850cba..6d0f67507b21 100644 --- a/include/asm-i386/topology.h +++ b/include/asm-i386/topology.h | |||
@@ -60,12 +60,8 @@ static inline int node_to_first_cpu(int node) | |||
60 | return first_cpu(mask); | 60 | return first_cpu(mask); |
61 | } | 61 | } |
62 | 62 | ||
63 | /* Returns the number of the node containing PCI bus number 'busnr' */ | 63 | #define pcibus_to_node(bus) mp_bus_id_to_node[(bus)->number] |
64 | static inline cpumask_t __pcibus_to_cpumask(int busnr) | 64 | #define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus)) |
65 | { | ||
66 | return node_to_cpumask(mp_bus_id_to_node[busnr]); | ||
67 | } | ||
68 | #define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus->number) | ||
69 | 65 | ||
70 | /* sched_domains SD_NODE_INIT for NUMAQ machines */ | 66 | /* sched_domains SD_NODE_INIT for NUMAQ machines */ |
71 | #define SD_NODE_INIT (struct sched_domain) { \ | 67 | #define SD_NODE_INIT (struct sched_domain) { \ |
diff --git a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h index da21573ec731..8f77e9f6bc23 100644 --- a/include/asm-x86_64/topology.h +++ b/include/asm-x86_64/topology.h | |||
@@ -13,8 +13,8 @@ | |||
13 | extern cpumask_t cpu_online_map; | 13 | extern cpumask_t cpu_online_map; |
14 | 14 | ||
15 | extern unsigned char cpu_to_node[]; | 15 | extern unsigned char cpu_to_node[]; |
16 | extern unsigned char pci_bus_to_node[]; | ||
16 | extern cpumask_t node_to_cpumask[]; | 17 | extern cpumask_t node_to_cpumask[]; |
17 | extern cpumask_t pci_bus_to_cpumask[]; | ||
18 | 18 | ||
19 | #ifdef CONFIG_ACPI_NUMA | 19 | #ifdef CONFIG_ACPI_NUMA |
20 | extern int __node_distance(int, int); | 20 | extern int __node_distance(int, int); |
@@ -26,16 +26,8 @@ extern int __node_distance(int, int); | |||
26 | #define parent_node(node) (node) | 26 | #define parent_node(node) (node) |
27 | #define node_to_first_cpu(node) (__ffs(node_to_cpumask[node])) | 27 | #define node_to_first_cpu(node) (__ffs(node_to_cpumask[node])) |
28 | #define node_to_cpumask(node) (node_to_cpumask[node]) | 28 | #define node_to_cpumask(node) (node_to_cpumask[node]) |
29 | 29 | #define pcibus_to_node(bus) pci_bus_to_node[(bus)->number] | |
30 | static inline cpumask_t __pcibus_to_cpumask(int bus) | 30 | #define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus)); |
31 | { | ||
32 | cpumask_t busmask = pci_bus_to_cpumask[bus]; | ||
33 | cpumask_t online = cpu_online_map; | ||
34 | cpumask_t res; | ||
35 | cpus_and(res, busmask, online); | ||
36 | return res; | ||
37 | } | ||
38 | #define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus->number) | ||
39 | 31 | ||
40 | /* sched_domains SD_NODE_INIT for x86_64 machines */ | 32 | /* sched_domains SD_NODE_INIT for x86_64 machines */ |
41 | #define SD_NODE_INIT (struct sched_domain) { \ | 33 | #define SD_NODE_INIT (struct sched_domain) { \ |