cputopology.txt 5.6 KB

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