cputopology.txt 4.5 KB

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