cputopology.rst 5.7 KB

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