Commit | Line | Data |
---|---|---|
69dcc991 | 1 | |
663fb2fc | 2 | Export CPU topology info via sysfs. Items (attributes) are similar |
54a53694 | 3 | to /proc/cpuinfo output of some architectures: |
69dcc991 ZY |
4 | |
5 | 1) /sys/devices/system/cpu/cpuX/topology/physical_package_id: | |
663fb2fc AC |
6 | |
7 | physical package id of cpuX. Typically corresponds to a physical | |
8 | socket number, but the actual value is architecture and platform | |
9 | dependent. | |
10 | ||
69dcc991 | 11 | 2) /sys/devices/system/cpu/cpuX/topology/core_id: |
663fb2fc AC |
12 | |
13 | the CPU core ID of cpuX. Typically it is the hardware platform's | |
14 | identifier (rather than the kernel's). The actual value is | |
15 | architecture and platform dependent. | |
16 | ||
b40d8ed4 HC |
17 | 3) /sys/devices/system/cpu/cpuX/topology/book_id: |
18 | ||
19 | the book ID of cpuX. Typically it is the hardware platform's | |
20 | identifier (rather than the kernel's). The actual value is | |
21 | architecture and platform dependent. | |
22 | ||
a62247e1 HC |
23 | 4) /sys/devices/system/cpu/cpuX/topology/drawer_id: |
24 | ||
25 | the drawer ID of cpuX. Typically it is the hardware platform's | |
26 | identifier (rather than the kernel's). The actual value is | |
27 | architecture and platform dependent. | |
28 | ||
29 | 5) /sys/devices/system/cpu/cpuX/topology/thread_siblings: | |
663fb2fc | 30 | |
f8ea61e6 | 31 | internal kernel map of cpuX's hardware threads within the same |
54a53694 | 32 | core as cpuX. |
663fb2fc | 33 | |
a62247e1 | 34 | 6) /sys/devices/system/cpu/cpuX/topology/thread_siblings_list: |
54a53694 BG |
35 | |
36 | human-readable list of cpuX's hardware threads within the same | |
37 | core as cpuX. | |
38 | ||
a62247e1 | 39 | 7) /sys/devices/system/cpu/cpuX/topology/core_siblings: |
663fb2fc AC |
40 | |
41 | internal kernel map of cpuX's hardware threads within the same | |
42 | physical_package_id. | |
69dcc991 | 43 | |
a62247e1 | 44 | 8) /sys/devices/system/cpu/cpuX/topology/core_siblings_list: |
54a53694 BG |
45 | |
46 | human-readable list of cpuX's hardware threads within the same | |
47 | physical_package_id. | |
48 | ||
a62247e1 | 49 | 9) /sys/devices/system/cpu/cpuX/topology/book_siblings: |
b40d8ed4 HC |
50 | |
51 | internal kernel map of cpuX's hardware threads within the same | |
52 | book_id. | |
53 | ||
a62247e1 | 54 | 10) /sys/devices/system/cpu/cpuX/topology/book_siblings_list: |
54a53694 BG |
55 | |
56 | human-readable list of cpuX's hardware threads within the same | |
57 | book_id. | |
58 | ||
a62247e1 HC |
59 | 11) /sys/devices/system/cpu/cpuX/topology/drawer_siblings: |
60 | ||
61 | internal kernel map of cpuX's hardware threads within the same | |
62 | drawer_id. | |
63 | ||
64 | 12) /sys/devices/system/cpu/cpuX/topology/drawer_siblings_list: | |
65 | ||
66 | human-readable list of cpuX's hardware threads within the same | |
67 | drawer_id. | |
68 | ||
69dcc991 | 69 | To implement it in an architecture-neutral way, a new source file, |
a62247e1 HC |
70 | drivers/base/topology.c, is to export the 6 to 12 attributes. The book |
71 | and drawer related sysfs files will only be created if CONFIG_SCHED_BOOK | |
72 | and CONFIG_SCHED_DRAWER are selected. | |
73 | ||
74 | CONFIG_SCHED_BOOK and CONFIG_DRAWER are currently only used on s390, where | |
75 | they reflect the cpu and cache hierarchy. | |
69dcc991 | 76 | |
c50cbb05 BH |
77 | For an architecture to support this feature, it must define some of |
78 | these macros in include/asm-XXX/topology.h: | |
69dcc991 ZY |
79 | #define topology_physical_package_id(cpu) |
80 | #define topology_core_id(cpu) | |
b40d8ed4 | 81 | #define topology_book_id(cpu) |
a62247e1 | 82 | #define topology_drawer_id(cpu) |
06931e62 | 83 | #define topology_sibling_cpumask(cpu) |
fbd59a8d | 84 | #define topology_core_cpumask(cpu) |
b40d8ed4 | 85 | #define topology_book_cpumask(cpu) |
a62247e1 | 86 | #define topology_drawer_cpumask(cpu) |
69dcc991 | 87 | |
54a53694 BG |
88 | The type of **_id macros is int. |
89 | The type of **_cpumask macros is (const) struct cpumask *. The latter | |
90 | correspond with appropriate **_siblings sysfs attributes (except for | |
91 | topology_sibling_cpumask() which corresponds with thread_siblings). | |
69dcc991 | 92 | |
c50cbb05 BH |
93 | To be consistent on all architectures, include/linux/topology.h |
94 | provides default definitions for any of the above macros that are | |
95 | not defined by include/asm-XXX/topology.h: | |
96 | 1) physical_package_id: -1 | |
97 | 2) core_id: 0 | |
54a53694 BG |
98 | 3) sibling_cpumask: just the given CPU |
99 | 4) core_cpumask: just the given CPU | |
d62720ad | 100 | |
b40d8ed4 HC |
101 | For architectures that don't support books (CONFIG_SCHED_BOOK) there are no |
102 | default definitions for topology_book_id() and topology_book_cpumask(). | |
a62247e1 HC |
103 | For architectures that don't support drawes (CONFIG_SCHED_DRAWER) there are |
104 | no default definitions for topology_drawer_id() and topology_drawer_cpumask(). | |
b40d8ed4 | 105 | |
663fb2fc | 106 | Additionally, CPU topology information is provided under |
d62720ad MT |
107 | /sys/devices/system/cpu and includes these files. The internal |
108 | source for the output is in brackets ("[]"). | |
109 | ||
663fb2fc | 110 | kernel_max: the maximum CPU index allowed by the kernel configuration. |
d62720ad MT |
111 | [NR_CPUS-1] |
112 | ||
663fb2fc | 113 | offline: CPUs that are not online because they have been |
d62720ad | 114 | HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit |
663fb2fc | 115 | of CPUs allowed by the kernel configuration (kernel_max |
d62720ad MT |
116 | above). [~cpu_online_mask + cpus >= NR_CPUS] |
117 | ||
663fb2fc | 118 | online: CPUs that are online and being scheduled [cpu_online_mask] |
d62720ad | 119 | |
663fb2fc | 120 | possible: CPUs that have been allocated resources and can be |
d62720ad MT |
121 | brought online if they are present. [cpu_possible_mask] |
122 | ||
663fb2fc | 123 | present: CPUs that have been identified as being present in the |
d62720ad MT |
124 | system. [cpu_present_mask] |
125 | ||
126 | The format for the above output is compatible with cpulist_parse() | |
127 | [see <linux/cpumask.h>]. Some examples follow. | |
128 | ||
663fb2fc | 129 | In this example, there are 64 CPUs in the system but cpus 32-63 exceed |
d62720ad | 130 | the kernel max which is limited to 0..31 by the NR_CPUS config option |
663fb2fc | 131 | being 32. Note also that CPUs 2 and 4-31 are not online but could be |
d62720ad MT |
132 | brought online as they are both present and possible. |
133 | ||
134 | kernel_max: 31 | |
135 | offline: 2,4-31,32-63 | |
136 | online: 0-1,3 | |
137 | possible: 0-31 | |
138 | present: 0-31 | |
139 | ||
140 | In this example, the NR_CPUS config option is 128, but the kernel was | |
663fb2fc AC |
141 | started with possible_cpus=144. There are 4 CPUs in the system and cpu2 |
142 | was manually taken offline (and is the only CPU that can be brought | |
d62720ad MT |
143 | online.) |
144 | ||
145 | kernel_max: 127 | |
146 | offline: 2,4-127,128-143 | |
147 | online: 0-1,3 | |
148 | possible: 0-127 | |
149 | present: 0-3 | |
150 | ||
151 | See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter | |
663fb2fc | 152 | as well as more information on the various cpumasks. |