blob: cb61277e230828a28fa6ed0bfb1d0d13a4fde6c7 [file] [log] [blame]
Mauro Carvalho Chehabe8cb6f12017-05-14 09:52:01 -03001===========================================
2How CPU topology info is exported via sysfs
3===========================================
Zhang, Yanmin69dcc992006-02-03 03:04:36 -08004
Alex Chiang663fb2f2009-10-21 21:45:31 -06005Export CPU topology info via sysfs. Items (attributes) are similar
Len Brown3a1c7792019-02-26 01:20:00 -05006to /proc/cpuinfo output of some architectures. They reside in
7/sys/devices/system/cpu/cpuX/topology/:
Zhang, Yanmin69dcc992006-02-03 03:04:36 -08008
Len Brown3a1c7792019-02-26 01:20:00 -05009physical_package_id:
Alex Chiang663fb2f2009-10-21 21:45:31 -060010
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
Len Brown3a1c7792019-02-26 01:20:00 -050015core_id:
Alex Chiang663fb2f2009-10-21 21:45:31 -060016
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
Len Brown3a1c7792019-02-26 01:20:00 -050021book_id:
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020022
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
Len Brown3a1c7792019-02-26 01:20:00 -050027drawer_id:
Heiko Carstensa62247e2016-05-21 11:10:13 +020028
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
Len Brown3a1c7792019-02-26 01:20:00 -050033thread_siblings:
Alex Chiang663fb2f2009-10-21 21:45:31 -060034
Xishi Qiuf8ea61e62013-09-04 18:58:29 +080035 internal kernel map of cpuX's hardware threads within the same
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020036 core as cpuX.
Alex Chiang663fb2f2009-10-21 21:45:31 -060037
Len Brown3a1c7792019-02-26 01:20:00 -050038thread_siblings_list:
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020039
40 human-readable list of cpuX's hardware threads within the same
41 core as cpuX.
42
Len Brown3a1c7792019-02-26 01:20:00 -050043core_siblings:
Alex Chiang663fb2f2009-10-21 21:45:31 -060044
45 internal kernel map of cpuX's hardware threads within the same
46 physical_package_id.
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080047
Len Brown3a1c7792019-02-26 01:20:00 -050048core_siblings_list:
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020049
50 human-readable list of cpuX's hardware threads within the same
51 physical_package_id.
52
Len Brown3a1c7792019-02-26 01:20:00 -050053book_siblings:
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020054
55 internal kernel map of cpuX's hardware threads within the same
56 book_id.
57
Len Brown3a1c7792019-02-26 01:20:00 -050058book_siblings_list:
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020059
60 human-readable list of cpuX's hardware threads within the same
61 book_id.
62
Len Brown3a1c7792019-02-26 01:20:00 -050063drawer_siblings:
Heiko Carstensa62247e2016-05-21 11:10:13 +020064
65 internal kernel map of cpuX's hardware threads within the same
66 drawer_id.
67
Len Brown3a1c7792019-02-26 01:20:00 -050068drawer_siblings_list:
Heiko Carstensa62247e2016-05-21 11:10:13 +020069
70 human-readable list of cpuX's hardware threads within the same
71 drawer_id.
72
Len Brown3a1c7792019-02-26 01:20:00 -050073Architecture-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.
Heiko Carstensa62247e2016-05-21 11:10:13 +020076
Len Brown3a1c7792019-02-26 01:20:00 -050077CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are currently only used on s390,
78where they reflect the cpu and cache hierarchy.
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080079
Ben Hutchingsc50cbb02008-06-04 21:47:29 -070080For an architecture to support this feature, it must define some of
Mauro Carvalho Chehabe8cb6f12017-05-14 09:52:01 -030081these macros in include/asm-XXX/topology.h::
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080082
Mauro Carvalho Chehabe8cb6f12017-05-14 09:52:01 -030083 #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
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020095topology_sibling_cpumask() which corresponds with thread_siblings).
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080096
Ben Hutchingsc50cbb02008-06-04 21:47:29 -070097To 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:
Mauro Carvalho Chehabe8cb6f12017-05-14 09:52:01 -0300100
Len Brown3a1c7792019-02-26 01:20:00 -05001011) 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
Mike Travisd62720a2008-12-17 14:14:30 -0800105
Heiko Carstensb40d8ed2010-08-31 10:28:17 +0200106For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
107default definitions for topology_book_id() and topology_book_cpumask().
Stan Drozd9bb0e9c2017-04-21 13:16:03 +0200108For architectures that don't support drawers (CONFIG_SCHED_DRAWER) there are
Heiko Carstensa62247e2016-05-21 11:10:13 +0200109no default definitions for topology_drawer_id() and topology_drawer_cpumask().
Heiko Carstensb40d8ed2010-08-31 10:28:17 +0200110
Alex Chiang663fb2f2009-10-21 21:45:31 -0600111Additionally, CPU topology information is provided under
Mike Travisd62720a2008-12-17 14:14:30 -0800112/sys/devices/system/cpu and includes these files. The internal
113source for the output is in brackets ("[]").
114
Mauro Carvalho Chehabe8cb6f12017-05-14 09:52:01 -0300115 =========== ==========================================================
Alex Chiang663fb2f2009-10-21 21:45:31 -0600116 kernel_max: the maximum CPU index allowed by the kernel configuration.
Mike Travisd62720a2008-12-17 14:14:30 -0800117 [NR_CPUS-1]
118
Alex Chiang663fb2f2009-10-21 21:45:31 -0600119 offline: CPUs that are not online because they have been
Mike Travisd62720a2008-12-17 14:14:30 -0800120 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
Alex Chiang663fb2f2009-10-21 21:45:31 -0600121 of CPUs allowed by the kernel configuration (kernel_max
Mike Travisd62720a2008-12-17 14:14:30 -0800122 above). [~cpu_online_mask + cpus >= NR_CPUS]
123
Alex Chiang663fb2f2009-10-21 21:45:31 -0600124 online: CPUs that are online and being scheduled [cpu_online_mask]
Mike Travisd62720a2008-12-17 14:14:30 -0800125
Alex Chiang663fb2f2009-10-21 21:45:31 -0600126 possible: CPUs that have been allocated resources and can be
Mike Travisd62720a2008-12-17 14:14:30 -0800127 brought online if they are present. [cpu_possible_mask]
128
Alex Chiang663fb2f2009-10-21 21:45:31 -0600129 present: CPUs that have been identified as being present in the
Mike Travisd62720a2008-12-17 14:14:30 -0800130 system. [cpu_present_mask]
Mauro Carvalho Chehabe8cb6f12017-05-14 09:52:01 -0300131 =========== ==========================================================
Mike Travisd62720a2008-12-17 14:14:30 -0800132
133The format for the above output is compatible with cpulist_parse()
134[see <linux/cpumask.h>]. Some examples follow.
135
Alex Chiang663fb2f2009-10-21 21:45:31 -0600136In this example, there are 64 CPUs in the system but cpus 32-63 exceed
Mike Travisd62720a2008-12-17 14:14:30 -0800137the kernel max which is limited to 0..31 by the NR_CPUS config option
Alex Chiang663fb2f2009-10-21 21:45:31 -0600138being 32. Note also that CPUs 2 and 4-31 are not online but could be
Mauro Carvalho Chehabe8cb6f12017-05-14 09:52:01 -0300139brought online as they are both present and possible::
Mike Travisd62720a2008-12-17 14:14:30 -0800140
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
Alex Chiang663fb2f2009-10-21 21:45:31 -0600148started 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
Mauro Carvalho Chehabe8cb6f12017-05-14 09:52:01 -0300150online.)::
Mike Travisd62720a2008-12-17 14:14:30 -0800151
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
Alex Chiang663fb2f2009-10-21 21:45:31 -0600159as well as more information on the various cpumasks.