blob: 12b1b25b4da9711c95ab013adf1bec4214964d2c [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
234) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
Alex Chiang663fb2f2009-10-21 21:45:31 -060024
Xishi Qiuf8ea61e62013-09-04 18:58:29 +080025 internal kernel map of cpuX's hardware threads within the same
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020026 core as cpuX.
Alex Chiang663fb2f2009-10-21 21:45:31 -060027
Bartosz Golaszewski54a53692015-05-26 15:11:29 +0200285) /sys/devices/system/cpu/cpuX/topology/thread_siblings_list:
29
30 human-readable list of cpuX's hardware threads within the same
31 core as cpuX.
32
336) /sys/devices/system/cpu/cpuX/topology/core_siblings:
Alex Chiang663fb2f2009-10-21 21:45:31 -060034
35 internal kernel map of cpuX's hardware threads within the same
36 physical_package_id.
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080037
Bartosz Golaszewski54a53692015-05-26 15:11:29 +0200387) /sys/devices/system/cpu/cpuX/topology/core_siblings_list:
39
40 human-readable list of cpuX's hardware threads within the same
41 physical_package_id.
42
438) /sys/devices/system/cpu/cpuX/topology/book_siblings:
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020044
45 internal kernel map of cpuX's hardware threads within the same
46 book_id.
47
Bartosz Golaszewski54a53692015-05-26 15:11:29 +0200489) /sys/devices/system/cpu/cpuX/topology/book_siblings_list:
49
50 human-readable list of cpuX's hardware threads within the same
51 book_id.
52
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080053To implement it in an architecture-neutral way, a new source file,
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020054drivers/base/topology.c, is to export the 6 or 9 attributes. The three book
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020055related sysfs files will only be created if CONFIG_SCHED_BOOK is selected.
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080056
Ben Hutchingsc50cbb02008-06-04 21:47:29 -070057For an architecture to support this feature, it must define some of
58these macros in include/asm-XXX/topology.h:
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080059#define topology_physical_package_id(cpu)
60#define topology_core_id(cpu)
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020061#define topology_book_id(cpu)
Bartosz Golaszewski06931e62015-05-26 15:11:28 +020062#define topology_sibling_cpumask(cpu)
Rusty Russellfbd59a82009-01-10 21:58:08 -080063#define topology_core_cpumask(cpu)
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020064#define topology_book_cpumask(cpu)
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080065
Bartosz Golaszewski54a53692015-05-26 15:11:29 +020066The type of **_id macros is int.
67The type of **_cpumask macros is (const) struct cpumask *. The latter
68correspond with appropriate **_siblings sysfs attributes (except for
69topology_sibling_cpumask() which corresponds with thread_siblings).
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080070
Ben Hutchingsc50cbb02008-06-04 21:47:29 -070071To be consistent on all architectures, include/linux/topology.h
72provides default definitions for any of the above macros that are
73not defined by include/asm-XXX/topology.h:
741) physical_package_id: -1
752) core_id: 0
Bartosz Golaszewski54a53692015-05-26 15:11:29 +0200763) sibling_cpumask: just the given CPU
774) core_cpumask: just the given CPU
Mike Travisd62720a2008-12-17 14:14:30 -080078
Heiko Carstensb40d8ed2010-08-31 10:28:17 +020079For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
80default definitions for topology_book_id() and topology_book_cpumask().
81
Alex Chiang663fb2f2009-10-21 21:45:31 -060082Additionally, CPU topology information is provided under
Mike Travisd62720a2008-12-17 14:14:30 -080083/sys/devices/system/cpu and includes these files. The internal
84source for the output is in brackets ("[]").
85
Alex Chiang663fb2f2009-10-21 21:45:31 -060086 kernel_max: the maximum CPU index allowed by the kernel configuration.
Mike Travisd62720a2008-12-17 14:14:30 -080087 [NR_CPUS-1]
88
Alex Chiang663fb2f2009-10-21 21:45:31 -060089 offline: CPUs that are not online because they have been
Mike Travisd62720a2008-12-17 14:14:30 -080090 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
Alex Chiang663fb2f2009-10-21 21:45:31 -060091 of CPUs allowed by the kernel configuration (kernel_max
Mike Travisd62720a2008-12-17 14:14:30 -080092 above). [~cpu_online_mask + cpus >= NR_CPUS]
93
Alex Chiang663fb2f2009-10-21 21:45:31 -060094 online: CPUs that are online and being scheduled [cpu_online_mask]
Mike Travisd62720a2008-12-17 14:14:30 -080095
Alex Chiang663fb2f2009-10-21 21:45:31 -060096 possible: CPUs that have been allocated resources and can be
Mike Travisd62720a2008-12-17 14:14:30 -080097 brought online if they are present. [cpu_possible_mask]
98
Alex Chiang663fb2f2009-10-21 21:45:31 -060099 present: CPUs that have been identified as being present in the
Mike Travisd62720a2008-12-17 14:14:30 -0800100 system. [cpu_present_mask]
101
102The format for the above output is compatible with cpulist_parse()
103[see <linux/cpumask.h>]. Some examples follow.
104
Alex Chiang663fb2f2009-10-21 21:45:31 -0600105In this example, there are 64 CPUs in the system but cpus 32-63 exceed
Mike Travisd62720a2008-12-17 14:14:30 -0800106the kernel max which is limited to 0..31 by the NR_CPUS config option
Alex Chiang663fb2f2009-10-21 21:45:31 -0600107being 32. Note also that CPUs 2 and 4-31 are not online but could be
Mike Travisd62720a2008-12-17 14:14:30 -0800108brought online as they are both present and possible.
109
110 kernel_max: 31
111 offline: 2,4-31,32-63
112 online: 0-1,3
113 possible: 0-31
114 present: 0-31
115
116In this example, the NR_CPUS config option is 128, but the kernel was
Alex Chiang663fb2f2009-10-21 21:45:31 -0600117started with possible_cpus=144. There are 4 CPUs in the system and cpu2
118was manually taken offline (and is the only CPU that can be brought
Mike Travisd62720a2008-12-17 14:14:30 -0800119online.)
120
121 kernel_max: 127
122 offline: 2,4-127,128-143
123 online: 0-1,3
124 possible: 0-127
125 present: 0-3
126
127See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
Alex Chiang663fb2f2009-10-21 21:45:31 -0600128as well as more information on the various cpumasks.