Merge tag 'nfs-for-5.2-2' of git://git.linux-nfs.org/projects/anna/linux-nfs
[linux-2.6-block.git] / Documentation / cputopology.txt
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
3a1c779f 15core_id:
663fb2fc
AC
16
17 the CPU core 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 21book_id:
b40d8ed4
HC
22
23 the book 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 27drawer_id:
a62247e1
HC
28
29 the drawer 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 33thread_siblings:
663fb2fc 34
f8ea61e6 35 internal kernel map of cpuX's hardware threads within the same
54a53694 36 core as cpuX.
663fb2fc 37
3a1c779f 38thread_siblings_list:
54a53694
BG
39
40 human-readable list of cpuX's hardware threads within the same
41 core as cpuX.
42
3a1c779f 43core_siblings:
663fb2fc
AC
44
45 internal kernel map of cpuX's hardware threads within the same
46 physical_package_id.
69dcc991 47
3a1c779f 48core_siblings_list:
54a53694
BG
49
50 human-readable list of cpuX's hardware threads within the same
51 physical_package_id.
52
3a1c779f 53book_siblings:
b40d8ed4
HC
54
55 internal kernel map of cpuX's hardware threads within the same
56 book_id.
57
3a1c779f 58book_siblings_list:
54a53694
BG
59
60 human-readable list of cpuX's hardware threads within the same
61 book_id.
62
3a1c779f 63drawer_siblings:
a62247e1
HC
64
65 internal kernel map of cpuX's hardware threads within the same
66 drawer_id.
67
3a1c779f 68drawer_siblings_list:
a62247e1
HC
69
70 human-readable list of cpuX's hardware threads within the same
71 drawer_id.
72
3a1c779f
LB
73Architecture-neutral, drivers/base/topology.c, exports these attributes.
74However, the book and drawer related sysfs files will only be created if
75CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are selected, respectively.
a62247e1 76
3a1c779f
LB
77CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are currently only used on s390,
78where they reflect the cpu and cache hierarchy.
69dcc991 79
c50cbb05 80For an architecture to support this feature, it must define some of
e8cb6f1e
MCC
81these macros in include/asm-XXX/topology.h::
82
83 #define topology_physical_package_id(cpu)
84 #define topology_core_id(cpu)
85 #define topology_book_id(cpu)
86 #define topology_drawer_id(cpu)
87 #define topology_sibling_cpumask(cpu)
88 #define topology_core_cpumask(cpu)
89 #define topology_book_cpumask(cpu)
90 #define topology_drawer_cpumask(cpu)
91
92The type of ``**_id macros`` is int.
93The type of ``**_cpumask macros`` is ``(const) struct cpumask *``. The latter
94correspond with appropriate ``**_siblings`` sysfs attributes (except for
54a53694 95topology_sibling_cpumask() which corresponds with thread_siblings).
69dcc991 96
c50cbb05
BH
97To be consistent on all architectures, include/linux/topology.h
98provides default definitions for any of the above macros that are
99not defined by include/asm-XXX/topology.h:
e8cb6f1e 100
3a1c779f
LB
1011) topology_physical_package_id: -1
1022) topology_core_id: 0
1033) topology_sibling_cpumask: just the given CPU
1044) topology_core_cpumask: just the given CPU
d62720ad 105
b40d8ed4
HC
106For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
107default definitions for topology_book_id() and topology_book_cpumask().
9bb0e9cb 108For architectures that don't support drawers (CONFIG_SCHED_DRAWER) there are
a62247e1 109no default definitions for topology_drawer_id() and topology_drawer_cpumask().
b40d8ed4 110
663fb2fc 111Additionally, CPU topology information is provided under
d62720ad
MT
112/sys/devices/system/cpu and includes these files. The internal
113source for the output is in brackets ("[]").
114
e8cb6f1e 115 =========== ==========================================================
663fb2fc 116 kernel_max: the maximum CPU index allowed by the kernel configuration.
d62720ad
MT
117 [NR_CPUS-1]
118
663fb2fc 119 offline: CPUs that are not online because they have been
d62720ad 120 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
663fb2fc 121 of CPUs allowed by the kernel configuration (kernel_max
d62720ad
MT
122 above). [~cpu_online_mask + cpus >= NR_CPUS]
123
663fb2fc 124 online: CPUs that are online and being scheduled [cpu_online_mask]
d62720ad 125
663fb2fc 126 possible: CPUs that have been allocated resources and can be
d62720ad
MT
127 brought online if they are present. [cpu_possible_mask]
128
663fb2fc 129 present: CPUs that have been identified as being present in the
d62720ad 130 system. [cpu_present_mask]
e8cb6f1e 131 =========== ==========================================================
d62720ad
MT
132
133The format for the above output is compatible with cpulist_parse()
134[see <linux/cpumask.h>]. Some examples follow.
135
663fb2fc 136In this example, there are 64 CPUs in the system but cpus 32-63 exceed
d62720ad 137the kernel max which is limited to 0..31 by the NR_CPUS config option
663fb2fc 138being 32. Note also that CPUs 2 and 4-31 are not online but could be
e8cb6f1e 139brought online as they are both present and possible::
d62720ad
MT
140
141 kernel_max: 31
142 offline: 2,4-31,32-63
143 online: 0-1,3
144 possible: 0-31
145 present: 0-31
146
147In this example, the NR_CPUS config option is 128, but the kernel was
663fb2fc
AC
148started with possible_cpus=144. There are 4 CPUs in the system and cpu2
149was manually taken offline (and is the only CPU that can be brought
e8cb6f1e 150online.)::
d62720ad
MT
151
152 kernel_max: 127
153 offline: 2,4-127,128-143
154 online: 0-1,3
155 possible: 0-127
156 present: 0-3
157
158See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
663fb2fc 159as well as more information on the various cpumasks.