Merge tag 'powerpc-4.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[deliverable/linux.git] / Documentation / cputopology.txt
1
2 Export CPU topology info via sysfs. Items (attributes) are similar
3 to /proc/cpuinfo output of some architectures:
4
5 1) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
6
7 physical package id of cpuX. Typically corresponds to a physical
8 socket number, but the actual value is architecture and platform
9 dependent.
10
11 2) /sys/devices/system/cpu/cpuX/topology/core_id:
12
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.
16
17 3) /sys/devices/system/cpu/cpuX/topology/book_id:
18
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.
22
23 4) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
24
25 internal kernel map of cpuX's hardware threads within the same
26 core as cpuX.
27
28 5) /sys/devices/system/cpu/cpuX/topology/thread_siblings_list:
29
30 human-readable list of cpuX's hardware threads within the same
31 core as cpuX.
32
33 6) /sys/devices/system/cpu/cpuX/topology/core_siblings:
34
35 internal kernel map of cpuX's hardware threads within the same
36 physical_package_id.
37
38 7) /sys/devices/system/cpu/cpuX/topology/core_siblings_list:
39
40 human-readable list of cpuX's hardware threads within the same
41 physical_package_id.
42
43 8) /sys/devices/system/cpu/cpuX/topology/book_siblings:
44
45 internal kernel map of cpuX's hardware threads within the same
46 book_id.
47
48 9) /sys/devices/system/cpu/cpuX/topology/book_siblings_list:
49
50 human-readable list of cpuX's hardware threads within the same
51 book_id.
52
53 To implement it in an architecture-neutral way, a new source file,
54 drivers/base/topology.c, is to export the 6 or 9 attributes. The three book
55 related sysfs files will only be created if CONFIG_SCHED_BOOK is selected.
56
57 For an architecture to support this feature, it must define some of
58 these macros in include/asm-XXX/topology.h:
59 #define topology_physical_package_id(cpu)
60 #define topology_core_id(cpu)
61 #define topology_book_id(cpu)
62 #define topology_sibling_cpumask(cpu)
63 #define topology_core_cpumask(cpu)
64 #define topology_book_cpumask(cpu)
65
66 The type of **_id macros is int.
67 The type of **_cpumask macros is (const) struct cpumask *. The latter
68 correspond with appropriate **_siblings sysfs attributes (except for
69 topology_sibling_cpumask() which corresponds with thread_siblings).
70
71 To be consistent on all architectures, include/linux/topology.h
72 provides default definitions for any of the above macros that are
73 not defined by include/asm-XXX/topology.h:
74 1) physical_package_id: -1
75 2) core_id: 0
76 3) sibling_cpumask: just the given CPU
77 4) core_cpumask: just the given CPU
78
79 For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
80 default definitions for topology_book_id() and topology_book_cpumask().
81
82 Additionally, CPU topology information is provided under
83 /sys/devices/system/cpu and includes these files. The internal
84 source for the output is in brackets ("[]").
85
86 kernel_max: the maximum CPU index allowed by the kernel configuration.
87 [NR_CPUS-1]
88
89 offline: CPUs that are not online because they have been
90 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
91 of CPUs allowed by the kernel configuration (kernel_max
92 above). [~cpu_online_mask + cpus >= NR_CPUS]
93
94 online: CPUs that are online and being scheduled [cpu_online_mask]
95
96 possible: CPUs that have been allocated resources and can be
97 brought online if they are present. [cpu_possible_mask]
98
99 present: CPUs that have been identified as being present in the
100 system. [cpu_present_mask]
101
102 The format for the above output is compatible with cpulist_parse()
103 [see <linux/cpumask.h>]. Some examples follow.
104
105 In this example, there are 64 CPUs in the system but cpus 32-63 exceed
106 the kernel max which is limited to 0..31 by the NR_CPUS config option
107 being 32. Note also that CPUs 2 and 4-31 are not online but could be
108 brought online as they are both present and possible.
109
110 kernel_max: 31
111 offline: 2,4-31,32-63
112 online: 0-1,3
113 possible: 0-31
114 present: 0-31
115
116 In this example, the NR_CPUS config option is 128, but the kernel was
117 started with possible_cpus=144. There are 4 CPUs in the system and cpu2
118 was manually taken offline (and is the only CPU that can be brought
119 online.)
120
121 kernel_max: 127
122 offline: 2,4-127,128-143
123 online: 0-1,3
124 possible: 0-127
125 present: 0-3
126
127 See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
128 as well as more information on the various cpumasks.
This page took 0.039142 seconds and 5 git commands to generate.