cputopology.txt 3.8 KB

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