Back to home page

LXR

 
 

    


0001 
0002 Export CPU topology info via sysfs. Items (attributes) are similar
0003 to /proc/cpuinfo output of some architectures:
0004 
0005 1) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
0006 
0007         physical package id of cpuX. Typically corresponds to a physical
0008         socket number, but the actual value is architecture and platform
0009         dependent.
0010 
0011 2) /sys/devices/system/cpu/cpuX/topology/core_id:
0012 
0013         the CPU core ID of cpuX. Typically it is the hardware platform's
0014         identifier (rather than the kernel's).  The actual value is
0015         architecture and platform dependent.
0016 
0017 3) /sys/devices/system/cpu/cpuX/topology/book_id:
0018 
0019         the book ID of cpuX. Typically it is the hardware platform's
0020         identifier (rather than the kernel's).  The actual value is
0021         architecture and platform dependent.
0022 
0023 4) /sys/devices/system/cpu/cpuX/topology/drawer_id:
0024 
0025         the drawer ID of cpuX. Typically it is the hardware platform's
0026         identifier (rather than the kernel's).  The actual value is
0027         architecture and platform dependent.
0028 
0029 5) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
0030 
0031         internal kernel map of cpuX's hardware threads within the same
0032         core as cpuX.
0033 
0034 6) /sys/devices/system/cpu/cpuX/topology/thread_siblings_list:
0035 
0036         human-readable list of cpuX's hardware threads within the same
0037         core as cpuX.
0038 
0039 7) /sys/devices/system/cpu/cpuX/topology/core_siblings:
0040 
0041         internal kernel map of cpuX's hardware threads within the same
0042         physical_package_id.
0043 
0044 8) /sys/devices/system/cpu/cpuX/topology/core_siblings_list:
0045 
0046         human-readable list of cpuX's hardware threads within the same
0047         physical_package_id.
0048 
0049 9) /sys/devices/system/cpu/cpuX/topology/book_siblings:
0050 
0051         internal kernel map of cpuX's hardware threads within the same
0052         book_id.
0053 
0054 10) /sys/devices/system/cpu/cpuX/topology/book_siblings_list:
0055 
0056         human-readable list of cpuX's hardware threads within the same
0057         book_id.
0058 
0059 11) /sys/devices/system/cpu/cpuX/topology/drawer_siblings:
0060 
0061         internal kernel map of cpuX's hardware threads within the same
0062         drawer_id.
0063 
0064 12) /sys/devices/system/cpu/cpuX/topology/drawer_siblings_list:
0065 
0066         human-readable list of cpuX's hardware threads within the same
0067         drawer_id.
0068 
0069 To implement it in an architecture-neutral way, a new source file,
0070 drivers/base/topology.c, is to export the 6 to 12 attributes. The book
0071 and drawer related sysfs files will only be created if CONFIG_SCHED_BOOK
0072 and CONFIG_SCHED_DRAWER are selected.
0073 
0074 CONFIG_SCHED_BOOK and CONFIG_DRAWER are currently only used on s390, where
0075 they reflect the cpu and cache hierarchy.
0076 
0077 For an architecture to support this feature, it must define some of
0078 these macros in include/asm-XXX/topology.h:
0079 #define topology_physical_package_id(cpu)
0080 #define topology_core_id(cpu)
0081 #define topology_book_id(cpu)
0082 #define topology_drawer_id(cpu)
0083 #define topology_sibling_cpumask(cpu)
0084 #define topology_core_cpumask(cpu)
0085 #define topology_book_cpumask(cpu)
0086 #define topology_drawer_cpumask(cpu)
0087 
0088 The type of **_id macros is int.
0089 The type of **_cpumask macros is (const) struct cpumask *. The latter
0090 correspond with appropriate **_siblings sysfs attributes (except for
0091 topology_sibling_cpumask() which corresponds with thread_siblings).
0092 
0093 To be consistent on all architectures, include/linux/topology.h
0094 provides default definitions for any of the above macros that are
0095 not defined by include/asm-XXX/topology.h:
0096 1) physical_package_id: -1
0097 2) core_id: 0
0098 3) sibling_cpumask: just the given CPU
0099 4) core_cpumask: just the given CPU
0100 
0101 For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
0102 default definitions for topology_book_id() and topology_book_cpumask().
0103 For architectures that don't support drawes (CONFIG_SCHED_DRAWER) there are
0104 no default definitions for topology_drawer_id() and topology_drawer_cpumask().
0105 
0106 Additionally, CPU topology information is provided under
0107 /sys/devices/system/cpu and includes these files.  The internal
0108 source for the output is in brackets ("[]").
0109 
0110     kernel_max: the maximum CPU index allowed by the kernel configuration.
0111                 [NR_CPUS-1]
0112 
0113     offline:    CPUs that are not online because they have been
0114                 HOTPLUGGED off (see cpu-hotplug.txt) or exceed the limit
0115                 of CPUs allowed by the kernel configuration (kernel_max
0116                 above). [~cpu_online_mask + cpus >= NR_CPUS]
0117 
0118     online:     CPUs that are online and being scheduled [cpu_online_mask]
0119 
0120     possible:   CPUs that have been allocated resources and can be
0121                 brought online if they are present. [cpu_possible_mask]
0122 
0123     present:    CPUs that have been identified as being present in the
0124                 system. [cpu_present_mask]
0125 
0126 The format for the above output is compatible with cpulist_parse()
0127 [see <linux/cpumask.h>].  Some examples follow.
0128 
0129 In this example, there are 64 CPUs in the system but cpus 32-63 exceed
0130 the kernel max which is limited to 0..31 by the NR_CPUS config option
0131 being 32.  Note also that CPUs 2 and 4-31 are not online but could be
0132 brought online as they are both present and possible.
0133 
0134      kernel_max: 31
0135         offline: 2,4-31,32-63
0136          online: 0-1,3
0137        possible: 0-31
0138         present: 0-31
0139 
0140 In this example, the NR_CPUS config option is 128, but the kernel was
0141 started with possible_cpus=144.  There are 4 CPUs in the system and cpu2
0142 was manually taken offline (and is the only CPU that can be brought
0143 online.)
0144 
0145      kernel_max: 127
0146         offline: 2,4-127,128-143
0147          online: 0-1,3
0148        possible: 0-127
0149         present: 0-3
0150 
0151 See cpu-hotplug.txt for the possible_cpus=NUM kernel start parameter
0152 as well as more information on the various cpumasks.