Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-block.git] / Documentation / admin-guide / cputopology.rst
CommitLineData
e8cb6f1e
MCC
1===========================================
2How CPU topology info is exported via sysfs
3===========================================
69dcc991 4
663fb2fc 5Export CPU topology info via sysfs. Items (attributes) are similar
3a1c779f
LB
6to /proc/cpuinfo output of some architectures. They reside in
7/sys/devices/system/cpu/cpuX/topology/:
69dcc991 8
3a1c779f 9physical_package_id:
663fb2fc
AC
10
11 physical package id of cpuX. Typically corresponds to a physical
12 socket number, but the actual value is architecture and platform
13 dependent.
14
0e344d8c
LB
15die_id:
16
17 the CPU die ID of cpuX. Typically it is the hardware platform's
18 identifier (rather than the kernel's). The actual value is
19 architecture and platform dependent.
20
3a1c779f 21core_id:
663fb2fc
AC
22
23 the CPU core ID of cpuX. Typically it is the hardware platform's
24 identifier (rather than the kernel's). The actual value is
25 architecture and platform dependent.
26
3a1c779f 27book_id:
b40d8ed4
HC
28
29 the book ID of cpuX. Typically it is the hardware platform's
30 identifier (rather than the kernel's). The actual value is
31 architecture and platform dependent.
32
3a1c779f 33drawer_id:
a62247e1
HC
34
35 the drawer ID of cpuX. Typically it is the hardware platform's
36 identifier (rather than the kernel's). The actual value is
37 architecture and platform dependent.
38
2e4c54da 39core_cpus:
663fb2fc 40
2e4c54da
LB
41 internal kernel map of CPUs within the same core.
42 (deprecated name: "thread_siblings")
663fb2fc 43
2e4c54da 44core_cpus_list:
54a53694 45
2e4c54da
LB
46 human-readable list of CPUs within the same core.
47 (deprecated name: "thread_siblings_list");
54a53694 48
b73ed8dc 49package_cpus:
663fb2fc 50
b73ed8dc
LB
51 internal kernel map of the CPUs sharing the same physical_package_id.
52 (deprecated name: "core_siblings")
69dcc991 53
b73ed8dc 54package_cpus_list:
54a53694 55
b73ed8dc
LB
56 human-readable list of CPUs sharing the same physical_package_id.
57 (deprecated name: "core_siblings_list")
54a53694 58
2e4c54da
LB
59die_cpus:
60
61 internal kernel map of CPUs within the same die.
62
63die_cpus_list:
64
65 human-readable list of CPUs within the same die.
66
3a1c779f 67book_siblings:
b40d8ed4
HC
68
69 internal kernel map of cpuX's hardware threads within the same
70 book_id.
71
3a1c779f 72book_siblings_list:
54a53694
BG
73
74 human-readable list of cpuX's hardware threads within the same
75 book_id.
76
3a1c779f 77drawer_siblings:
a62247e1
HC
78
79 internal kernel map of cpuX's hardware threads within the same
80 drawer_id.
81
3a1c779f 82drawer_siblings_list:
a62247e1
HC
83
84 human-readable list of cpuX's hardware threads within the same
85 drawer_id.
86
3a1c779f
LB
87Architecture-neutral, drivers/base/topology.c, exports these attributes.
88However, the book and drawer related sysfs files will only be created if
89CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are selected, respectively.
a62247e1 90
3a1c779f
LB
91CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are currently only used on s390,
92where they reflect the cpu and cache hierarchy.
69dcc991 93
c50cbb05 94For an architecture to support this feature, it must define some of
e8cb6f1e
MCC
95these macros in include/asm-XXX/topology.h::
96
97 #define topology_physical_package_id(cpu)
0e344d8c 98 #define topology_die_id(cpu)
e8cb6f1e
MCC
99 #define topology_core_id(cpu)
100 #define topology_book_id(cpu)
101 #define topology_drawer_id(cpu)
102 #define topology_sibling_cpumask(cpu)
103 #define topology_core_cpumask(cpu)
2e4c54da 104 #define topology_die_cpumask(cpu)
e8cb6f1e
MCC
105 #define topology_book_cpumask(cpu)
106 #define topology_drawer_cpumask(cpu)
107
108The type of ``**_id macros`` is int.
109The type of ``**_cpumask macros`` is ``(const) struct cpumask *``. The latter
110correspond with appropriate ``**_siblings`` sysfs attributes (except for
54a53694 111topology_sibling_cpumask() which corresponds with thread_siblings).
69dcc991 112
c50cbb05
BH
113To be consistent on all architectures, include/linux/topology.h
114provides default definitions for any of the above macros that are
115not defined by include/asm-XXX/topology.h:
e8cb6f1e 116
3a1c779f 1171) topology_physical_package_id: -1
0e344d8c
LB
1182) topology_die_id: -1
1193) topology_core_id: 0
1204) topology_sibling_cpumask: just the given CPU
1215) topology_core_cpumask: just the given CPU
1226) topology_die_cpumask: just the given CPU
d62720ad 123
b40d8ed4
HC
124For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
125default definitions for topology_book_id() and topology_book_cpumask().
9bb0e9cb 126For architectures that don't support drawers (CONFIG_SCHED_DRAWER) there are
a62247e1 127no default definitions for topology_drawer_id() and topology_drawer_cpumask().
b40d8ed4 128
663fb2fc 129Additionally, CPU topology information is provided under
d62720ad
MT
130/sys/devices/system/cpu and includes these files. The internal
131source for the output is in brackets ("[]").
132
e8cb6f1e 133 =========== ==========================================================
663fb2fc 134 kernel_max: the maximum CPU index allowed by the kernel configuration.
d62720ad
MT
135 [NR_CPUS-1]
136
663fb2fc 137 offline: CPUs that are not online because they have been
d62720ad 138 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
663fb2fc 139 of CPUs allowed by the kernel configuration (kernel_max
d62720ad
MT
140 above). [~cpu_online_mask + cpus >= NR_CPUS]
141
663fb2fc 142 online: CPUs that are online and being scheduled [cpu_online_mask]
d62720ad 143
663fb2fc 144 possible: CPUs that have been allocated resources and can be
d62720ad
MT
145 brought online if they are present. [cpu_possible_mask]
146
663fb2fc 147 present: CPUs that have been identified as being present in the
d62720ad 148 system. [cpu_present_mask]
e8cb6f1e 149 =========== ==========================================================
d62720ad
MT
150
151The format for the above output is compatible with cpulist_parse()
152[see <linux/cpumask.h>]. Some examples follow.
153
663fb2fc 154In this example, there are 64 CPUs in the system but cpus 32-63 exceed
d62720ad 155the kernel max which is limited to 0..31 by the NR_CPUS config option
663fb2fc 156being 32. Note also that CPUs 2 and 4-31 are not online but could be
e8cb6f1e 157brought online as they are both present and possible::
d62720ad
MT
158
159 kernel_max: 31
160 offline: 2,4-31,32-63
161 online: 0-1,3
162 possible: 0-31
163 present: 0-31
164
165In this example, the NR_CPUS config option is 128, but the kernel was
663fb2fc
AC
166started with possible_cpus=144. There are 4 CPUs in the system and cpu2
167was manually taken offline (and is the only CPU that can be brought
e8cb6f1e 168online.)::
d62720ad
MT
169
170 kernel_max: 127
171 offline: 2,4-127,128-143
172 online: 0-1,3
173 possible: 0-127
174 present: 0-3
175
176See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
663fb2fc 177as well as more information on the various cpumasks.