blob: f722f227a73bbc2cc0bbbbd6e0e65ab0d2f8b23e [file] [log] [blame]
Zhang, Yanmin69dcc992006-02-03 03:04:36 -08001
Alex Chiang663fb2f2009-10-21 21:45:31 -06002Export CPU topology info via sysfs. Items (attributes) are similar
Bartosz Golaszewski54a53692015-05-26 15:11:29 +02003to /proc/cpuinfo output of some architectures:
Zhang, Yanmin69dcc992006-02-03 03:04:36 -08004
51) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
Alex Chiang663fb2f2009-10-21 21:45:31 -06006
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
Zhang, Yanmin69dcc992006-02-03 03:04:36 -0800112) /sys/devices/system/cpu/cpuX/topology/core_id:
Alex Chiang663fb2f2009-10-21 21:45:31 -060012
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
Heiko Carstensb40d8ed2010-08-31 10:28:17 +0200173) /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
Heiko Carstensa62247e12016-05-21 11:10:13 +0200234) /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
295) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
Alex Chiang663fb2f2009-10-21 21:45:31 -060030
Xishi Qiuf8ea61e62013-09-04 18:58:29 +080031 internal kernel map of cpuX's hardware threads within the same
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020032 core as cpuX.
Alex Chiang663fb2f2009-10-21 21:45:31 -060033
Heiko Carstensa62247e12016-05-21 11:10:13 +0200346) /sys/devices/system/cpu/cpuX/topology/thread_siblings_list:
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020035
36 human-readable list of cpuX's hardware threads within the same
37 core as cpuX.
38
Heiko Carstensa62247e12016-05-21 11:10:13 +0200397) /sys/devices/system/cpu/cpuX/topology/core_siblings:
Alex Chiang663fb2f2009-10-21 21:45:31 -060040
41 internal kernel map of cpuX's hardware threads within the same
42 physical_package_id.
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080043
Heiko Carstensa62247e12016-05-21 11:10:13 +0200448) /sys/devices/system/cpu/cpuX/topology/core_siblings_list:
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020045
46 human-readable list of cpuX's hardware threads within the same
47 physical_package_id.
48
Heiko Carstensa62247e12016-05-21 11:10:13 +0200499) /sys/devices/system/cpu/cpuX/topology/book_siblings:
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020050
51 internal kernel map of cpuX's hardware threads within the same
52 book_id.
53
Heiko Carstensa62247e12016-05-21 11:10:13 +02005410) /sys/devices/system/cpu/cpuX/topology/book_siblings_list:
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020055
56 human-readable list of cpuX's hardware threads within the same
57 book_id.
58
Heiko Carstensa62247e12016-05-21 11:10:13 +02005911) /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
6412) /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
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080069To implement it in an architecture-neutral way, a new source file,
Heiko Carstensa62247e12016-05-21 11:10:13 +020070drivers/base/topology.c, is to export the 6 to 12 attributes. The book
71and drawer related sysfs files will only be created if CONFIG_SCHED_BOOK
72and CONFIG_SCHED_DRAWER are selected.
73
74CONFIG_SCHED_BOOK and CONFIG_DRAWER are currently only used on s390, where
75they reflect the cpu and cache hierarchy.
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080076
Ben Hutchingsc50cbb02008-06-04 21:47:29 -070077For an architecture to support this feature, it must define some of
78these macros in include/asm-XXX/topology.h:
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080079#define topology_physical_package_id(cpu)
80#define topology_core_id(cpu)
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020081#define topology_book_id(cpu)
Heiko Carstensa62247e12016-05-21 11:10:13 +020082#define topology_drawer_id(cpu)
Bartosz Golaszewski06931e62015-05-26 15:11:28 +020083#define topology_sibling_cpumask(cpu)
Rusty Russellfbd59a82009-01-10 21:58:08 -080084#define topology_core_cpumask(cpu)
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020085#define topology_book_cpumask(cpu)
Heiko Carstensa62247e12016-05-21 11:10:13 +020086#define topology_drawer_cpumask(cpu)
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080087
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020088The type of **_id macros is int.
89The type of **_cpumask macros is (const) struct cpumask *. The latter
90correspond with appropriate **_siblings sysfs attributes (except for
91topology_sibling_cpumask() which corresponds with thread_siblings).
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080092
Ben Hutchingsc50cbb02008-06-04 21:47:29 -070093To be consistent on all architectures, include/linux/topology.h
94provides default definitions for any of the above macros that are
95not defined by include/asm-XXX/topology.h:
961) physical_package_id: -1
972) core_id: 0
Bartosz Golaszewski54a53692015-05-26 15:11:29 +0200983) sibling_cpumask: just the given CPU
994) core_cpumask: just the given CPU
Mike Travisd62720a2008-12-17 14:14:30 -0800100
Heiko Carstensb40d8ed2010-08-31 10:28:17 +0200101For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
102default definitions for topology_book_id() and topology_book_cpumask().
Heiko Carstensa62247e12016-05-21 11:10:13 +0200103For architectures that don't support drawes (CONFIG_SCHED_DRAWER) there are
104no default definitions for topology_drawer_id() and topology_drawer_cpumask().
Heiko Carstensb40d8ed2010-08-31 10:28:17 +0200105
Alex Chiang663fb2f2009-10-21 21:45:31 -0600106Additionally, CPU topology information is provided under
Mike Travisd62720a2008-12-17 14:14:30 -0800107/sys/devices/system/cpu and includes these files. The internal
108source for the output is in brackets ("[]").
109
Alex Chiang663fb2f2009-10-21 21:45:31 -0600110 kernel_max: the maximum CPU index allowed by the kernel configuration.
Mike Travisd62720a2008-12-17 14:14:30 -0800111 [NR_CPUS-1]
112
Alex Chiang663fb2f2009-10-21 21:45:31 -0600113 offline: CPUs that are not online because they have been
Mike Travisd62720a2008-12-17 14:14:30 -0800114 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
Alex Chiang663fb2f2009-10-21 21:45:31 -0600115 of CPUs allowed by the kernel configuration (kernel_max
Mike Travisd62720a2008-12-17 14:14:30 -0800116 above). [~cpu_online_mask + cpus >= NR_CPUS]
117
Alex Chiang663fb2f2009-10-21 21:45:31 -0600118 online: CPUs that are online and being scheduled [cpu_online_mask]
Mike Travisd62720a2008-12-17 14:14:30 -0800119
Alex Chiang663fb2f2009-10-21 21:45:31 -0600120 possible: CPUs that have been allocated resources and can be
Mike Travisd62720a2008-12-17 14:14:30 -0800121 brought online if they are present. [cpu_possible_mask]
122
Alex Chiang663fb2f2009-10-21 21:45:31 -0600123 present: CPUs that have been identified as being present in the
Mike Travisd62720a2008-12-17 14:14:30 -0800124 system. [cpu_present_mask]
125
126The format for the above output is compatible with cpulist_parse()
127[see <linux/cpumask.h>]. Some examples follow.
128
Alex Chiang663fb2f2009-10-21 21:45:31 -0600129In this example, there are 64 CPUs in the system but cpus 32-63 exceed
Mike Travisd62720a2008-12-17 14:14:30 -0800130the kernel max which is limited to 0..31 by the NR_CPUS config option
Alex Chiang663fb2f2009-10-21 21:45:31 -0600131being 32. Note also that CPUs 2 and 4-31 are not online but could be
Mike Travisd62720a2008-12-17 14:14:30 -0800132brought 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
140In this example, the NR_CPUS config option is 128, but the kernel was
Alex Chiang663fb2f2009-10-21 21:45:31 -0600141started with possible_cpus=144. There are 4 CPUs in the system and cpu2
142was manually taken offline (and is the only CPU that can be brought
Mike Travisd62720a2008-12-17 14:14:30 -0800143online.)
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
151See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
Alex Chiang663fb2f2009-10-21 21:45:31 -0600152as well as more information on the various cpumasks.