cputopology.txt 5.3 KB

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