diff options
author | Zhang, Yanmin <yanmin.zhang@intel.com> | 2006-02-03 06:04:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-02-03 11:32:09 -0500 |
commit | 69dcc99199fe29b0a29471a3488d39d9d33b25fc (patch) | |
tree | 4232ad9a782dee6abfe7fa20c95a49249195de8f /include | |
parent | 66ac5a294db70aa377c0d7bbdb0c4e3ef2349b7b (diff) |
[PATCH] Export cpu topology in sysfs
The patch implements cpu topology exportation by sysfs.
Items (attributes) are similar to /proc/cpuinfo.
1) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
represent the physical package id of cpu X;
2) /sys/devices/system/cpu/cpuX/topology/core_id:
represent the cpu core id to cpu X;
3) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
represent the thread siblings to cpu X in the same core;
4) /sys/devices/system/cpu/cpuX/topology/core_siblings:
represent the thread siblings to cpu X in the same physical package;
To implement it in an architecture-neutral way, a new source file,
driver/base/topology.c, is to export the 5 attributes.
If one architecture wants to support this feature, it just needs to
implement 4 defines, typically in file include/asm-XXX/topology.h.
The 4 defines are:
#define topology_physical_package_id(cpu)
#define topology_core_id(cpu)
#define topology_thread_siblings(cpu)
#define topology_core_siblings(cpu)
The type of **_id is int.
The type of siblings is cpumask_t.
To be consistent on all architectures, the 4 attributes should have
deafult values if their values are unavailable. Below is the rule.
1) physical_package_id: If cpu has no physical package id, -1 is the
default value.
2) core_id: If cpu doesn't support multi-core, its core id is 0.
3) thread_siblings: Just include itself, if the cpu doesn't support
HT/multi-thread.
4) core_siblings: Just include itself, if the cpu doesn't support
multi-core and HT/Multi-thread.
So be careful when declaring the 4 defines in include/asm-XXX/topology.h.
If an attribute isn't defined on an architecture, it won't be exported.
Thank Nathan, Greg, Andi, Paul and Venki.
The patch provides defines for i386/x86_64/ia64.
Signed-off-by: Zhang, Yanmin <yanmin.zhang@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-i386/topology.h | 9 | ||||
-rw-r--r-- | include/asm-ia64/topology.h | 7 | ||||
-rw-r--r-- | include/asm-x86_64/topology.h | 9 |
3 files changed, 25 insertions, 0 deletions
diff --git a/include/asm-i386/topology.h b/include/asm-i386/topology.h index d7e19eb344b7..af503a122b23 100644 --- a/include/asm-i386/topology.h +++ b/include/asm-i386/topology.h | |||
@@ -27,6 +27,15 @@ | |||
27 | #ifndef _ASM_I386_TOPOLOGY_H | 27 | #ifndef _ASM_I386_TOPOLOGY_H |
28 | #define _ASM_I386_TOPOLOGY_H | 28 | #define _ASM_I386_TOPOLOGY_H |
29 | 29 | ||
30 | #ifdef CONFIG_SMP | ||
31 | #define topology_physical_package_id(cpu) \ | ||
32 | (phys_proc_id[cpu] == BAD_APICID ? -1 : phys_proc_id[cpu]) | ||
33 | #define topology_core_id(cpu) \ | ||
34 | (cpu_core_id[cpu] == BAD_APICID ? 0 : cpu_core_id[cpu]) | ||
35 | #define topology_core_siblings(cpu) (cpu_core_map[cpu]) | ||
36 | #define topology_thread_siblings(cpu) (cpu_sibling_map[cpu]) | ||
37 | #endif | ||
38 | |||
30 | #ifdef CONFIG_NUMA | 39 | #ifdef CONFIG_NUMA |
31 | 40 | ||
32 | #include <asm/mpspec.h> | 41 | #include <asm/mpspec.h> |
diff --git a/include/asm-ia64/topology.h b/include/asm-ia64/topology.h index 412ef8e493a8..3ee19dfa46df 100644 --- a/include/asm-ia64/topology.h +++ b/include/asm-ia64/topology.h | |||
@@ -102,6 +102,13 @@ void build_cpu_to_node_map(void); | |||
102 | 102 | ||
103 | #endif /* CONFIG_NUMA */ | 103 | #endif /* CONFIG_NUMA */ |
104 | 104 | ||
105 | #ifdef CONFIG_SMP | ||
106 | #define topology_physical_package_id(cpu) (cpu_data(cpu)->socket_id) | ||
107 | #define topology_core_id(cpu) (cpu_data(cpu)->core_id) | ||
108 | #define topology_core_siblings(cpu) (cpu_core_map[cpu]) | ||
109 | #define topology_thread_siblings(cpu) (cpu_sibling_map[cpu]) | ||
110 | #endif | ||
111 | |||
105 | #include <asm-generic/topology.h> | 112 | #include <asm-generic/topology.h> |
106 | 113 | ||
107 | #endif /* _ASM_IA64_TOPOLOGY_H */ | 114 | #endif /* _ASM_IA64_TOPOLOGY_H */ |
diff --git a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h index 2fa7f27381b4..c642f5d9882d 100644 --- a/include/asm-x86_64/topology.h +++ b/include/asm-x86_64/topology.h | |||
@@ -57,6 +57,15 @@ extern int __node_distance(int, int); | |||
57 | 57 | ||
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #ifdef CONFIG_SMP | ||
61 | #define topology_physical_package_id(cpu) \ | ||
62 | (phys_proc_id[cpu] == BAD_APICID ? -1 : phys_proc_id[cpu]) | ||
63 | #define topology_core_id(cpu) \ | ||
64 | (cpu_core_id[cpu] == BAD_APICID ? 0 : cpu_core_id[cpu]) | ||
65 | #define topology_core_siblings(cpu) (cpu_core_map[cpu]) | ||
66 | #define topology_thread_siblings(cpu) (cpu_sibling_map[cpu]) | ||
67 | #endif | ||
68 | |||
60 | #include <asm-generic/topology.h> | 69 | #include <asm-generic/topology.h> |
61 | 70 | ||
62 | #endif | 71 | #endif |