2 Export CPU topology info via sysfs. Items (attributes) are similar
5 1) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
7 physical package id of cpuX. Typically corresponds to a physical
8 socket number, but the actual value is architecture and platform
11 2) /sys/devices/system/cpu/cpuX/topology/core_id:
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.
17 3) /sys/devices/system/cpu/cpuX/topology/book_id:
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.
23 4) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
25 internel kernel map of cpuX's hardware threads within the same
28 5) /sys/devices/system/cpu/cpuX/topology/core_siblings:
30 internal kernel map of cpuX's hardware threads within the same
33 6) /sys/devices/system/cpu/cpuX/topology/book_siblings:
35 internal kernel map of cpuX's hardware threads within the same
38 To implement it in an architecture-neutral way, a new source file,
39 drivers/base/topology.c, is to export the 4 or 6 attributes. The two book
40 related sysfs files will only be created if CONFIG_SCHED_BOOK is selected.
42 For an architecture to support this feature, it must define some of
43 these macros in include/asm-XXX/topology.h:
44 #define topology_physical_package_id(cpu)
45 #define topology_core_id(cpu)
46 #define topology_book_id(cpu)
47 #define topology_thread_cpumask(cpu)
48 #define topology_core_cpumask(cpu)
49 #define topology_book_cpumask(cpu)
51 The type of **_id is int.
52 The type of siblings is (const) struct cpumask *.
54 To be consistent on all architectures, include/linux/topology.h
55 provides default definitions for any of the above macros that are
56 not defined by include/asm-XXX/topology.h:
57 1) physical_package_id: -1
59 3) thread_siblings: just the given CPU
60 4) core_siblings: just the given CPU
62 For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
63 default definitions for topology_book_id() and topology_book_cpumask().
65 Additionally, CPU topology information is provided under
66 /sys/devices/system/cpu and includes these files. The internal
67 source for the output is in brackets ("[]").
69 kernel_max: the maximum CPU index allowed by the kernel configuration.
72 offline: CPUs that are not online because they have been
73 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
74 of CPUs allowed by the kernel configuration (kernel_max
75 above). [~cpu_online_mask + cpus >= NR_CPUS]
77 online: CPUs that are online and being scheduled [cpu_online_mask]
79 possible: CPUs that have been allocated resources and can be
80 brought online if they are present. [cpu_possible_mask]
82 present: CPUs that have been identified as being present in the
83 system. [cpu_present_mask]
85 The format for the above output is compatible with cpulist_parse()
86 [see <linux/cpumask.h>]. Some examples follow.
88 In this example, there are 64 CPUs in the system but cpus 32-63 exceed
89 the kernel max which is limited to 0..31 by the NR_CPUS config option
90 being 32. Note also that CPUs 2 and 4-31 are not online but could be
91 brought online as they are both present and possible.
99 In this example, the NR_CPUS config option is 128, but the kernel was
100 started with possible_cpus=144. There are 4 CPUs in the system and cpu2
101 was manually taken offline (and is the only CPU that can be brought
105 offline: 2,4-127,128-143
110 See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
111 as well as more information on the various cpumasks.