blob: f1c5c4bccd3e8ed6674903eedbc59db3cf76ff9e [file] [log] [blame]
Zhang, Yanmin69dcc992006-02-03 03:04:36 -08001
Alex Chiang663fb2f2009-10-21 21:45:31 -06002Export CPU topology info via sysfs. Items (attributes) are similar
Zhang, Yanmin69dcc992006-02-03 03:04:36 -08003to /proc/cpuinfo.
4
51) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
Alex Chiang663fb2f2009-10-21 21:45:31 -06006
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
Zhang, Yanmin69dcc992006-02-03 03:04:36 -0800112) /sys/devices/system/cpu/cpuX/topology/core_id:
Alex Chiang663fb2f2009-10-21 21:45:31 -060012
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
Zhang, Yanmin69dcc992006-02-03 03:04:36 -0800173) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
Alex Chiang663fb2f2009-10-21 21:45:31 -060018
19 internel kernel map of cpuX's hardware threads within the same
20 core as cpuX
21
Zhang, Yanmin69dcc992006-02-03 03:04:36 -0800224) /sys/devices/system/cpu/cpuX/topology/core_siblings:
Alex Chiang663fb2f2009-10-21 21:45:31 -060023
24 internal kernel map of cpuX's hardware threads within the same
25 physical_package_id.
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080026
27To implement it in an architecture-neutral way, a new source file,
Jesper Juhlded23ac2006-03-28 01:56:52 -080028drivers/base/topology.c, is to export the 4 attributes.
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080029
Ben Hutchingsc50cbb02008-06-04 21:47:29 -070030For an architecture to support this feature, it must define some of
31these macros in include/asm-XXX/topology.h:
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080032#define topology_physical_package_id(cpu)
33#define topology_core_id(cpu)
Rusty Russellfbd59a82009-01-10 21:58:08 -080034#define topology_thread_cpumask(cpu)
35#define topology_core_cpumask(cpu)
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080036
37The type of **_id is int.
Rusty Russellfbd59a82009-01-10 21:58:08 -080038The type of siblings is (const) struct cpumask *.
Zhang, Yanmin69dcc992006-02-03 03:04:36 -080039
Ben Hutchingsc50cbb02008-06-04 21:47:29 -070040To be consistent on all architectures, include/linux/topology.h
41provides default definitions for any of the above macros that are
42not defined by include/asm-XXX/topology.h:
431) physical_package_id: -1
442) core_id: 0
453) thread_siblings: just the given CPU
464) core_siblings: just the given CPU
Mike Travisd62720a2008-12-17 14:14:30 -080047
Alex Chiang663fb2f2009-10-21 21:45:31 -060048Additionally, CPU topology information is provided under
Mike Travisd62720a2008-12-17 14:14:30 -080049/sys/devices/system/cpu and includes these files. The internal
50source for the output is in brackets ("[]").
51
Alex Chiang663fb2f2009-10-21 21:45:31 -060052 kernel_max: the maximum CPU index allowed by the kernel configuration.
Mike Travisd62720a2008-12-17 14:14:30 -080053 [NR_CPUS-1]
54
Alex Chiang663fb2f2009-10-21 21:45:31 -060055 offline: CPUs that are not online because they have been
Mike Travisd62720a2008-12-17 14:14:30 -080056 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
Alex Chiang663fb2f2009-10-21 21:45:31 -060057 of CPUs allowed by the kernel configuration (kernel_max
Mike Travisd62720a2008-12-17 14:14:30 -080058 above). [~cpu_online_mask + cpus >= NR_CPUS]
59
Alex Chiang663fb2f2009-10-21 21:45:31 -060060 online: CPUs that are online and being scheduled [cpu_online_mask]
Mike Travisd62720a2008-12-17 14:14:30 -080061
Alex Chiang663fb2f2009-10-21 21:45:31 -060062 possible: CPUs that have been allocated resources and can be
Mike Travisd62720a2008-12-17 14:14:30 -080063 brought online if they are present. [cpu_possible_mask]
64
Alex Chiang663fb2f2009-10-21 21:45:31 -060065 present: CPUs that have been identified as being present in the
Mike Travisd62720a2008-12-17 14:14:30 -080066 system. [cpu_present_mask]
67
68The format for the above output is compatible with cpulist_parse()
69[see <linux/cpumask.h>]. Some examples follow.
70
Alex Chiang663fb2f2009-10-21 21:45:31 -060071In this example, there are 64 CPUs in the system but cpus 32-63 exceed
Mike Travisd62720a2008-12-17 14:14:30 -080072the kernel max which is limited to 0..31 by the NR_CPUS config option
Alex Chiang663fb2f2009-10-21 21:45:31 -060073being 32. Note also that CPUs 2 and 4-31 are not online but could be
Mike Travisd62720a2008-12-17 14:14:30 -080074brought online as they are both present and possible.
75
76 kernel_max: 31
77 offline: 2,4-31,32-63
78 online: 0-1,3
79 possible: 0-31
80 present: 0-31
81
82In this example, the NR_CPUS config option is 128, but the kernel was
Alex Chiang663fb2f2009-10-21 21:45:31 -060083started with possible_cpus=144. There are 4 CPUs in the system and cpu2
84was manually taken offline (and is the only CPU that can be brought
Mike Travisd62720a2008-12-17 14:14:30 -080085online.)
86
87 kernel_max: 127
88 offline: 2,4-127,128-143
89 online: 0-1,3
90 possible: 0-127
91 present: 0-3
92
93See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
Alex Chiang663fb2f2009-10-21 21:45:31 -060094as well as more information on the various cpumasks.