brintos

brintos / linux-shallow public Read only

0
0
Text · 3.8 KiB · d29cacc Raw
102 lines · plain
1===========================================2How CPU topology info is exported via sysfs3===========================================4 5CPU topology info is exported via sysfs. Items (attributes) are similar6to /proc/cpuinfo output of some architectures. They reside in7/sys/devices/system/cpu/cpuX/topology/. Please refer to the ABI file:8Documentation/ABI/stable/sysfs-devices-system-cpu.9 10Architecture-neutral, drivers/base/topology.c, exports these attributes.11However the die, cluster, book, and drawer hierarchy related sysfs files will12only be created if an architecture provides the related macros as described13below.14 15For an architecture to support this feature, it must define some of16these macros in include/asm-XXX/topology.h::17 18	#define topology_physical_package_id(cpu)19	#define topology_die_id(cpu)20	#define topology_cluster_id(cpu)21	#define topology_core_id(cpu)22	#define topology_book_id(cpu)23	#define topology_drawer_id(cpu)24	#define topology_sibling_cpumask(cpu)25	#define topology_core_cpumask(cpu)26	#define topology_cluster_cpumask(cpu)27	#define topology_die_cpumask(cpu)28	#define topology_book_cpumask(cpu)29	#define topology_drawer_cpumask(cpu)30 31The type of ``**_id macros`` is int.32The type of ``**_cpumask macros`` is ``(const) struct cpumask *``. The latter33correspond with appropriate ``**_siblings`` sysfs attributes (except for34topology_sibling_cpumask() which corresponds with thread_siblings).35 36To be consistent on all architectures, include/linux/topology.h37provides default definitions for any of the above macros that are38not defined by include/asm-XXX/topology.h:39 401) topology_physical_package_id: -1412) topology_die_id: -1423) topology_cluster_id: -1434) topology_core_id: 0445) topology_book_id: -1456) topology_drawer_id: -1467) topology_sibling_cpumask: just the given CPU478) topology_core_cpumask: just the given CPU489) topology_cluster_cpumask: just the given CPU4910) topology_die_cpumask: just the given CPU5011) topology_book_cpumask:  just the given CPU5112) topology_drawer_cpumask: just the given CPU52 53Additionally, CPU topology information is provided under54/sys/devices/system/cpu and includes these files.  The internal55source for the output is in brackets ("[]").56 57    =========== ==========================================================58    kernel_max: the maximum CPU index allowed by the kernel configuration.59		[NR_CPUS-1]60 61    offline:	CPUs that are not online because they have been62		HOTPLUGGED off or exceed the limit of CPUs allowed by the63		kernel configuration (kernel_max above).64		[~cpu_online_mask + cpus >= NR_CPUS]65 66    online:	CPUs that are online and being scheduled [cpu_online_mask]67 68    possible:	CPUs that have been allocated resources and can be69		brought online if they are present. [cpu_possible_mask]70 71    present:	CPUs that have been identified as being present in the72		system. [cpu_present_mask]73    =========== ==========================================================74 75The format for the above output is compatible with cpulist_parse()76[see <linux/cpumask.h>].  Some examples follow.77 78In this example, there are 64 CPUs in the system but cpus 32-63 exceed79the kernel max which is limited to 0..31 by the NR_CPUS config option80being 32.  Note also that CPUs 2 and 4-31 are not online but could be81brought online as they are both present and possible::82 83     kernel_max: 3184        offline: 2,4-31,32-6385         online: 0-1,386       possible: 0-3187        present: 0-3188 89In this example, the NR_CPUS config option is 128, but the kernel was90started with possible_cpus=144.  There are 4 CPUs in the system and cpu291was manually taken offline (and is the only CPU that can be brought92online.)::93 94     kernel_max: 12795        offline: 2,4-127,128-14396         online: 0-1,397       possible: 0-12798        present: 0-399 100See Documentation/core-api/cpu_hotplug.rst for the possible_cpus=NUM101kernel start parameter as well as more information on the various cpumasks.102