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 CPU topology info is exported 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/. Please refer to the ABI file: 8 Documentation/ABI/stable/sysfs-devices-system- 8 Documentation/ABI/stable/sysfs-devices-system-cpu. 9 9 10 Architecture-neutral, drivers/base/topology.c, 10 Architecture-neutral, drivers/base/topology.c, exports these attributes. 11 However the die, cluster, book, and drawer hie !! 11 However, the book and drawer related sysfs files will only be created if 12 only be created if an architecture provides th !! 12 CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are selected, respectively. 13 below. !! 13 >> 14 CONFIG_SCHED_BOOK and CONFIG_SCHED_DRAWER are currently only used on s390, >> 15 where they reflect the cpu and cache hierarchy. 14 16 15 For an architecture to support this feature, i 17 For an architecture to support this feature, it must define some of 16 these macros in include/asm-XXX/topology.h:: 18 these macros in include/asm-XXX/topology.h:: 17 19 18 #define topology_physical_package_id(c 20 #define topology_physical_package_id(cpu) 19 #define topology_die_id(cpu) 21 #define topology_die_id(cpu) 20 #define topology_cluster_id(cpu) 22 #define topology_cluster_id(cpu) 21 #define topology_core_id(cpu) 23 #define topology_core_id(cpu) 22 #define topology_book_id(cpu) 24 #define topology_book_id(cpu) 23 #define topology_drawer_id(cpu) 25 #define topology_drawer_id(cpu) 24 #define topology_sibling_cpumask(cpu) 26 #define topology_sibling_cpumask(cpu) 25 #define topology_core_cpumask(cpu) 27 #define topology_core_cpumask(cpu) 26 #define topology_cluster_cpumask(cpu) 28 #define topology_cluster_cpumask(cpu) 27 #define topology_die_cpumask(cpu) 29 #define topology_die_cpumask(cpu) 28 #define topology_book_cpumask(cpu) 30 #define topology_book_cpumask(cpu) 29 #define topology_drawer_cpumask(cpu) 31 #define topology_drawer_cpumask(cpu) 30 32 31 The type of ``**_id macros`` is int. 33 The type of ``**_id macros`` is int. 32 The type of ``**_cpumask macros`` is ``(const) 34 The type of ``**_cpumask macros`` is ``(const) struct cpumask *``. The latter 33 correspond with appropriate ``**_siblings`` sy 35 correspond with appropriate ``**_siblings`` sysfs attributes (except for 34 topology_sibling_cpumask() which corresponds w 36 topology_sibling_cpumask() which corresponds with thread_siblings). 35 37 36 To be consistent on all architectures, include 38 To be consistent on all architectures, include/linux/topology.h 37 provides default definitions for any of the ab 39 provides default definitions for any of the above macros that are 38 not defined by include/asm-XXX/topology.h: 40 not defined by include/asm-XXX/topology.h: 39 41 40 1) topology_physical_package_id: -1 42 1) topology_physical_package_id: -1 41 2) topology_die_id: -1 43 2) topology_die_id: -1 42 3) topology_cluster_id: -1 44 3) topology_cluster_id: -1 43 4) topology_core_id: 0 45 4) topology_core_id: 0 44 5) topology_book_id: -1 !! 46 5) topology_sibling_cpumask: just the given CPU 45 6) topology_drawer_id: -1 !! 47 6) topology_core_cpumask: just the given CPU 46 7) topology_sibling_cpumask: just the given CP !! 48 7) topology_cluster_cpumask: just the given CPU 47 8) topology_core_cpumask: just the given CPU !! 49 8) topology_die_cpumask: just the given CPU 48 9) topology_cluster_cpumask: just the given CP !! 50 49 10) topology_die_cpumask: just the given CPU !! 51 For architectures that don't support books (CONFIG_SCHED_BOOK) there are no 50 11) topology_book_cpumask: just the given CPU !! 52 default definitions for topology_book_id() and topology_book_cpumask(). 51 12) topology_drawer_cpumask: just the given CP !! 53 For architectures that don't support drawers (CONFIG_SCHED_DRAWER) there are >> 54 no default definitions for topology_drawer_id() and topology_drawer_cpumask(). 52 55 53 Additionally, CPU topology information is prov 56 Additionally, CPU topology information is provided under 54 /sys/devices/system/cpu and includes these fil 57 /sys/devices/system/cpu and includes these files. The internal 55 source for the output is in brackets ("[]"). 58 source for the output is in brackets ("[]"). 56 59 57 =========== ============================== 60 =========== ========================================================== 58 kernel_max: the maximum CPU index allowed 61 kernel_max: the maximum CPU index allowed by the kernel configuration. 59 [NR_CPUS-1] 62 [NR_CPUS-1] 60 63 61 offline: CPUs that are not online becau 64 offline: CPUs that are not online because they have been 62 HOTPLUGGED off or exceed the l 65 HOTPLUGGED off or exceed the limit of CPUs allowed by the 63 kernel configuration (kernel_m 66 kernel configuration (kernel_max above). 64 [~cpu_online_mask + cpus >= NR 67 [~cpu_online_mask + cpus >= NR_CPUS] 65 68 66 online: CPUs that are online and being 69 online: CPUs that are online and being scheduled [cpu_online_mask] 67 70 68 possible: CPUs that have been allocated 71 possible: CPUs that have been allocated resources and can be 69 brought online if they are pre 72 brought online if they are present. [cpu_possible_mask] 70 73 71 present: CPUs that have been identified 74 present: CPUs that have been identified as being present in the 72 system. [cpu_present_mask] 75 system. [cpu_present_mask] 73 =========== ============================== 76 =========== ========================================================== 74 77 75 The format for the above output is compatible 78 The format for the above output is compatible with cpulist_parse() 76 [see <linux/cpumask.h>]. Some examples follow 79 [see <linux/cpumask.h>]. Some examples follow. 77 80 78 In this example, there are 64 CPUs in the syst 81 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 82 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 83 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 84 brought online as they are both present and possible:: 82 85 83 kernel_max: 31 86 kernel_max: 31 84 offline: 2,4-31,32-63 87 offline: 2,4-31,32-63 85 online: 0-1,3 88 online: 0-1,3 86 possible: 0-31 89 possible: 0-31 87 present: 0-31 90 present: 0-31 88 91 89 In this example, the NR_CPUS config option is 92 In this example, the NR_CPUS config option is 128, but the kernel was 90 started with possible_cpus=144. There are 4 C 93 started with possible_cpus=144. There are 4 CPUs in the system and cpu2 91 was manually taken offline (and is the only CP 94 was manually taken offline (and is the only CPU that can be brought 92 online.):: 95 online.):: 93 96 94 kernel_max: 127 97 kernel_max: 127 95 offline: 2,4-127,128-143 98 offline: 2,4-127,128-143 96 online: 0-1,3 99 online: 0-1,3 97 possible: 0-127 100 possible: 0-127 98 present: 0-3 101 present: 0-3 99 102 100 See Documentation/core-api/cpu_hotplug.rst for 103 See Documentation/core-api/cpu_hotplug.rst for the possible_cpus=NUM 101 kernel start parameter as well as more informa 104 kernel start parameter 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.