1 ===========================================
2 How CPU topology info is exported via sysfs
3 ===========================================
5 Export CPU topology info via sysfs. Items (attributes) are similar
6 to /proc/cpuinfo output of some architectures. They reside in
7 /sys/devices/system/cpu/cpuX/topology/:
11 physical package id of cpuX. Typically corresponds to a physical
12 socket number, but the actual value is architecture and platform
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.
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.
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.
35 internal kernel map of cpuX's hardware threads within the same
40 human-readable list of cpuX's hardware threads within the same
45 internal kernel map of cpuX's hardware threads within the same
50 human-readable list of cpuX's hardware threads within the same
55 internal kernel map of cpuX's hardware threads within the same
60 human-readable list of cpuX's hardware threads within the same
65 internal kernel map of cpuX's hardware threads within the same
70 human-readable list of cpuX's hardware threads within the same
73 Architecture-neutral, drivers/base/topology.c, exports these attributes.
74 However, the book and drawer related sysfs files will only be created if
75 CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are selected, respectively.
77 CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are currently only used on s390,
78 where they reflect the cpu and cache hierarchy.
80 For an architecture to support this feature, it must define some of
81 these macros in include/asm-XXX/topology.h::
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)
92 The type of ``**_id macros`` is int.
93 The type of ``**_cpumask macros`` is ``(const) struct cpumask *``. The latter
94 correspond with appropriate ``**_siblings`` sysfs attributes (except for
95 topology_sibling_cpumask() which corresponds with thread_siblings).
97 To be consistent on all architectures, include/linux/topology.h
98 provides default definitions for any of the above macros that are
99 not defined by include/asm-XXX/topology.h:
101 1) topology_physical_package_id: -1
102 2) topology_core_id: 0
103 3) topology_sibling_cpumask: just the given CPU
104 4) topology_core_cpumask: just the given CPU
106 For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
107 default definitions for topology_book_id() and topology_book_cpumask().
108 For architectures that don't support drawers (CONFIG_SCHED_DRAWER) there are
109 no default definitions for topology_drawer_id() and topology_drawer_cpumask().
111 Additionally, CPU topology information is provided under
112 /sys/devices/system/cpu and includes these files. The internal
113 source for the output is in brackets ("[]").
115 =========== ==========================================================
116 kernel_max: the maximum CPU index allowed by the kernel configuration.
119 offline: CPUs that are not online because they have been
120 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
121 of CPUs allowed by the kernel configuration (kernel_max
122 above). [~cpu_online_mask + cpus >= NR_CPUS]
124 online: CPUs that are online and being scheduled [cpu_online_mask]
126 possible: CPUs that have been allocated resources and can be
127 brought online if they are present. [cpu_possible_mask]
129 present: CPUs that have been identified as being present in the
130 system. [cpu_present_mask]
131 =========== ==========================================================
133 The format for the above output is compatible with cpulist_parse()
134 [see <linux/cpumask.h>]. Some examples follow.
136 In this example, there are 64 CPUs in the system but cpus 32-63 exceed
137 the kernel max which is limited to 0..31 by the NR_CPUS config option
138 being 32. Note also that CPUs 2 and 4-31 are not online but could be
139 brought online as they are both present and possible::
142 offline: 2,4-31,32-63
147 In this example, the NR_CPUS config option is 128, but the kernel was
148 started with possible_cpus=144. There are 4 CPUs in the system and cpu2
149 was manually taken offline (and is the only CPU that can be brought
153 offline: 2,4-127,128-143
158 See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
159 as well as more information on the various cpumasks.