Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
[linux-block.git] / Documentation / admin-guide / cputopology.rst
CommitLineData
e8cb6f1e
MCC
1===========================================
2How CPU topology info is exported via sysfs
3===========================================
69dcc991 4
05a463ec
TT
5CPU topology info is exported via sysfs. Items (attributes) are similar
6to /proc/cpuinfo output of some architectures. They reside in
7/sys/devices/system/cpu/cpuX/topology/. Please refer to the ABI file:
8Documentation/ABI/stable/sysfs-devices-system-cpu.
a62247e1 9
3a1c779f 10Architecture-neutral, drivers/base/topology.c, exports these attributes.
f1045056
HC
11However the die, cluster, book, and drawer hierarchy related sysfs files will
12only be created if an architecture provides the related macros as described
13below.
69dcc991 14
c50cbb05 15For an architecture to support this feature, it must define some of
e8cb6f1e
MCC
16these macros in include/asm-XXX/topology.h::
17
18 #define topology_physical_package_id(cpu)
0e344d8c 19 #define topology_die_id(cpu)
c5e22fef 20 #define topology_cluster_id(cpu)
e8cb6f1e
MCC
21 #define topology_core_id(cpu)
22 #define topology_book_id(cpu)
23 #define topology_drawer_id(cpu)
24 #define topology_sibling_cpumask(cpu)
25 #define topology_core_cpumask(cpu)
c5e22fef 26 #define topology_cluster_cpumask(cpu)
2e4c54da 27 #define topology_die_cpumask(cpu)
e8cb6f1e
MCC
28 #define topology_book_cpumask(cpu)
29 #define topology_drawer_cpumask(cpu)
30
31The type of ``**_id macros`` is int.
32The type of ``**_cpumask macros`` is ``(const) struct cpumask *``. The latter
33correspond with appropriate ``**_siblings`` sysfs attributes (except for
54a53694 34topology_sibling_cpumask() which corresponds with thread_siblings).
69dcc991 35
c50cbb05
BH
36To be consistent on all architectures, include/linux/topology.h
37provides default definitions for any of the above macros that are
38not defined by include/asm-XXX/topology.h:
e8cb6f1e 39
aa483f3c
HC
401) topology_physical_package_id: -1
412) topology_die_id: -1
423) topology_cluster_id: -1
434) topology_core_id: 0
445) topology_book_id: -1
456) topology_drawer_id: -1
467) topology_sibling_cpumask: just the given CPU
478) topology_core_cpumask: just the given CPU
489) topology_cluster_cpumask: just the given CPU
f1045056
HC
4910) topology_die_cpumask: just the given CPU
5011) topology_book_cpumask: just the given CPU
5112) topology_drawer_cpumask: just the given CPU
b40d8ed4 52
663fb2fc 53Additionally, CPU topology information is provided under
d62720ad
MT
54/sys/devices/system/cpu and includes these files. The internal
55source for the output is in brackets ("[]").
56
e8cb6f1e 57 =========== ==========================================================
663fb2fc 58 kernel_max: the maximum CPU index allowed by the kernel configuration.
d62720ad
MT
59 [NR_CPUS-1]
60
663fb2fc 61 offline: CPUs that are not online because they have been
d5caec39
YX
62 HOTPLUGGED off or exceed the limit of CPUs allowed by the
63 kernel configuration (kernel_max above).
64 [~cpu_online_mask + cpus >= NR_CPUS]
d62720ad 65
663fb2fc 66 online: CPUs that are online and being scheduled [cpu_online_mask]
d62720ad 67
663fb2fc 68 possible: CPUs that have been allocated resources and can be
d62720ad
MT
69 brought online if they are present. [cpu_possible_mask]
70
663fb2fc 71 present: CPUs that have been identified as being present in the
d62720ad 72 system. [cpu_present_mask]
e8cb6f1e 73 =========== ==========================================================
d62720ad
MT
74
75The format for the above output is compatible with cpulist_parse()
76[see <linux/cpumask.h>]. Some examples follow.
77
663fb2fc 78In this example, there are 64 CPUs in the system but cpus 32-63 exceed
d62720ad 79the kernel max which is limited to 0..31 by the NR_CPUS config option
663fb2fc 80being 32. Note also that CPUs 2 and 4-31 are not online but could be
e8cb6f1e 81brought online as they are both present and possible::
d62720ad
MT
82
83 kernel_max: 31
84 offline: 2,4-31,32-63
85 online: 0-1,3
86 possible: 0-31
87 present: 0-31
88
89In this example, the NR_CPUS config option is 128, but the kernel was
663fb2fc
AC
90started with possible_cpus=144. There are 4 CPUs in the system and cpu2
91was manually taken offline (and is the only CPU that can be brought
e8cb6f1e 92online.)::
d62720ad
MT
93
94 kernel_max: 127
95 offline: 2,4-127,128-143
96 online: 0-1,3
97 possible: 0-127
98 present: 0-3
99
d5caec39
YX
100See Documentation/core-api/cpu_hotplug.rst for the possible_cpus=NUM
101kernel start parameter as well as more information on the various cpumasks.