1 =========================================== 1 =========================================== 2 How CPU topology info is exported via sysfs 2 How CPU topology info is exported via sysfs 3 =========================================== 3 =========================================== 4 4 5 CPU topology info is exported via sysfs. Items !! 5 Export CPU topology info via sysfs. Items (attributes) are similar 6 to /proc/cpuinfo output of some architectures. !! 6 to /proc/cpuinfo output of some architectures. They reside in 7 /sys/devices/system/cpu/cpuX/topology/. Please !! 7 /sys/devices/system/cpu/cpuX/topology/: 8 Documentation/ABI/stable/sysfs-devices-system- !! 8 >> 9 physical_package_id: >> 10 >> 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 >> 15 die_id: >> 16 >> 17 the CPU die 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 >> 21 core_id: >> 22 >> 23 the CPU core 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 >> 27 book_id: >> 28 >> 29 the book 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 >> 33 drawer_id: >> 34 >> 35 the drawer ID of cpuX. Typically it is the hardware platform's >> 36 identifier (rather than the kernel's). The actual value is >> 37 architecture and platform dependent. >> 38 >> 39 core_cpus: >> 40 >> 41 internal kernel map of CPUs within the same core. >> 42 (deprecated name: "thread_siblings") >> 43 >> 44 core_cpus_list: >> 45 >> 46 human-readable list of CPUs within the same core. >> 47 (deprecated name: "thread_siblings_list"); >> 48 >> 49 package_cpus: >> 50 >> 51 internal kernel map of the CPUs sharing the same physical_package_id. >> 52 (deprecated name: "core_siblings") >> 53 >> 54 package_cpus_list: >> 55 >> 56 human-readable list of CPUs sharing the same physical_package_id. >> 57 (deprecated name: "core_siblings_list") >> 58 >> 59 die_cpus: >> 60 >> 61 internal kernel map of CPUs within the same die. >> 62 >> 63 die_cpus_list: >> 64 >> 65 human-readable list of CPUs within the same die. >> 66 >> 67 book_siblings: >> 68 >> 69 internal kernel map of cpuX's hardware threads within the same >> 70 book_id. >> 71 >> 72 book_siblings_list: >> 73 >> 74 human-readable list of cpuX's hardware threads within the same >> 75 book_id. >> 76 >> 77 drawer_siblings: >> 78 >> 79 internal kernel map of cpuX's hardware threads within the same >> 80 drawer_id. >> 81 >> 82 drawer_siblings_list: >> 83 >> 84 human-readable list of cpuX's hardware threads within the same >> 85 drawer_id. 9 86 10 Architecture-neutral, drivers/base/topology.c, 87 Architecture-neutral, drivers/base/topology.c, exports these attributes. 11 However the die, cluster, book, and drawer hie !! 88 However, the book and drawer related sysfs files will only be created if 12 only be created if an architecture provides th !! 89 CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are selected, respectively. 13 below. !! 90 >> 91 CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are currently only used on s390, >> 92 where they reflect the cpu and cache hierarchy. 14 93 15 For an architecture to support this feature, i 94 For an architecture to support this feature, it must define some of 16 these macros in include/asm-XXX/topology.h:: 95 these macros in include/asm-XXX/topology.h:: 17 96 18 #define topology_physical_package_id(c 97 #define topology_physical_package_id(cpu) 19 #define topology_die_id(cpu) 98 #define topology_die_id(cpu) 20 #define topology_cluster_id(cpu) << 21 #define topology_core_id(cpu) 99 #define topology_core_id(cpu) 22 #define topology_book_id(cpu) 100 #define topology_book_id(cpu) 23 #define topology_drawer_id(cpu) 101 #define topology_drawer_id(cpu) 24 #define topology_sibling_cpumask(cpu) 102 #define topology_sibling_cpumask(cpu) 25 #define topology_core_cpumask(cpu) 103 #define topology_core_cpumask(cpu) 26 #define topology_cluster_cpumask(cpu) << 27 #define topology_die_cpumask(cpu) 104 #define topology_die_cpumask(cpu) 28 #define topology_book_cpumask(cpu) 105 #define topology_book_cpumask(cpu) 29 #define topology_drawer_cpumask(cpu) 106 #define topology_drawer_cpumask(cpu) 30 107 31 The type of ``**_id macros`` is int. 108 The type of ``**_id macros`` is int. 32 The type of ``**_cpumask macros`` is ``(const) 109 The type of ``**_cpumask macros`` is ``(const) struct cpumask *``. The latter 33 correspond with appropriate ``**_siblings`` sy 110 correspond with appropriate ``**_siblings`` sysfs attributes (except for 34 topology_sibling_cpumask() which corresponds w 111 topology_sibling_cpumask() which corresponds with thread_siblings). 35 112 36 To be consistent on all architectures, include 113 To be consistent on all architectures, include/linux/topology.h 37 provides default definitions for any of the ab 114 provides default definitions for any of the above macros that are 38 not defined by include/asm-XXX/topology.h: 115 not defined by include/asm-XXX/topology.h: 39 116 40 1) topology_physical_package_id: -1 117 1) topology_physical_package_id: -1 41 2) topology_die_id: -1 118 2) topology_die_id: -1 42 3) topology_cluster_id: -1 !! 119 3) topology_core_id: 0 43 4) topology_core_id: 0 !! 120 4) topology_sibling_cpumask: just the given CPU 44 5) topology_book_id: -1 !! 121 5) topology_core_cpumask: just the given CPU 45 6) topology_drawer_id: -1 !! 122 6) topology_die_cpumask: just the given CPU 46 7) topology_sibling_cpumask: just the given CP !! 123 47 8) topology_core_cpumask: just the given CPU !! 124 For architectures that don't support books (CONFIG_SCHED_BOOK) there are no 48 9) topology_cluster_cpumask: just the given CP !! 125 default definitions for topology_book_id() and topology_book_cpumask(). 49 10) topology_die_cpumask: just the given CPU !! 126 For architectures that don't support drawers (CONFIG_SCHED_DRAWER) there are 50 11) topology_book_cpumask: just the given CPU !! 127 no default definitions for topology_drawer_id() and topology_drawer_cpumask(). 51 12) topology_drawer_cpumask: just the given CP << 52 128 53 Additionally, CPU topology information is prov 129 Additionally, CPU topology information is provided under 54 /sys/devices/system/cpu and includes these fil 130 /sys/devices/system/cpu and includes these files. The internal 55 source for the output is in brackets ("[]"). 131 source for the output is in brackets ("[]"). 56 132 57 =========== ============================== 133 =========== ========================================================== 58 kernel_max: the maximum CPU index allowed 134 kernel_max: the maximum CPU index allowed by the kernel configuration. 59 [NR_CPUS-1] 135 [NR_CPUS-1] 60 136 61 offline: CPUs that are not online becau 137 offline: CPUs that are not online because they have been 62 HOTPLUGGED off or exceed the l !! 138 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit 63 kernel configuration (kernel_m !! 139 of CPUs allowed by the kernel configuration (kernel_max 64 [~cpu_online_mask + cpus >= NR !! 140 above). [~cpu_online_mask + cpus >= NR_CPUS] 65 141 66 online: CPUs that are online and being 142 online: CPUs that are online and being scheduled [cpu_online_mask] 67 143 68 possible: CPUs that have been allocated 144 possible: CPUs that have been allocated resources and can be 69 brought online if they are pre 145 brought online if they are present. [cpu_possible_mask] 70 146 71 present: CPUs that have been identified 147 present: CPUs that have been identified as being present in the 72 system. [cpu_present_mask] 148 system. [cpu_present_mask] 73 =========== ============================== 149 =========== ========================================================== 74 150 75 The format for the above output is compatible 151 The format for the above output is compatible with cpulist_parse() 76 [see <linux/cpumask.h>]. Some examples follow 152 [see <linux/cpumask.h>]. Some examples follow. 77 153 78 In this example, there are 64 CPUs in the syst 154 In this example, there are 64 CPUs in the system but cpus 32-63 exceed 79 the kernel max which is limited to 0..31 by th 155 the kernel max which is limited to 0..31 by the NR_CPUS config option 80 being 32. Note also that CPUs 2 and 4-31 are 156 being 32. Note also that CPUs 2 and 4-31 are not online but could be 81 brought online as they are both present and po 157 brought online as they are both present and possible:: 82 158 83 kernel_max: 31 159 kernel_max: 31 84 offline: 2,4-31,32-63 160 offline: 2,4-31,32-63 85 online: 0-1,3 161 online: 0-1,3 86 possible: 0-31 162 possible: 0-31 87 present: 0-31 163 present: 0-31 88 164 89 In this example, the NR_CPUS config option is 165 In this example, the NR_CPUS config option is 128, but the kernel was 90 started with possible_cpus=144. There are 4 C 166 started with possible_cpus=144. There are 4 CPUs in the system and cpu2 91 was manually taken offline (and is the only CP 167 was manually taken offline (and is the only CPU that can be brought 92 online.):: 168 online.):: 93 169 94 kernel_max: 127 170 kernel_max: 127 95 offline: 2,4-127,128-143 171 offline: 2,4-127,128-143 96 online: 0-1,3 172 online: 0-1,3 97 possible: 0-127 173 possible: 0-127 98 present: 0-3 174 present: 0-3 99 175 100 See Documentation/core-api/cpu_hotplug.rst for !! 176 See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter 101 kernel start parameter as well as more informa !! 177 as well as more information on the various cpumasks.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.