cputopology.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ===========================================
  2. How CPU topology info is exported via sysfs
  3. ===========================================
  4. CPU topology info is exported via sysfs. Items (attributes) are similar
  5. to /proc/cpuinfo output of some architectures. They reside in
  6. /sys/devices/system/cpu/cpuX/topology/. Please refer to the ABI file:
  7. Documentation/ABI/stable/sysfs-devices-system-cpu.
  8. Architecture-neutral, drivers/base/topology.c, exports these attributes.
  9. However the die, cluster, book, and drawer hierarchy related sysfs files will
  10. only be created if an architecture provides the related macros as described
  11. below.
  12. For an architecture to support this feature, it must define some of
  13. these macros in include/asm-XXX/topology.h::
  14. #define topology_physical_package_id(cpu)
  15. #define topology_die_id(cpu)
  16. #define topology_cluster_id(cpu)
  17. #define topology_core_id(cpu)
  18. #define topology_book_id(cpu)
  19. #define topology_drawer_id(cpu)
  20. #define topology_sibling_cpumask(cpu)
  21. #define topology_core_cpumask(cpu)
  22. #define topology_cluster_cpumask(cpu)
  23. #define topology_die_cpumask(cpu)
  24. #define topology_book_cpumask(cpu)
  25. #define topology_drawer_cpumask(cpu)
  26. The type of ``**_id macros`` is int.
  27. The type of ``**_cpumask macros`` is ``(const) struct cpumask *``. The latter
  28. correspond with appropriate ``**_siblings`` sysfs attributes (except for
  29. topology_sibling_cpumask() which corresponds with thread_siblings).
  30. To be consistent on all architectures, include/linux/topology.h
  31. provides default definitions for any of the above macros that are
  32. not defined by include/asm-XXX/topology.h:
  33. 1) topology_physical_package_id: -1
  34. 2) topology_die_id: -1
  35. 3) topology_cluster_id: -1
  36. 4) topology_core_id: 0
  37. 5) topology_book_id: -1
  38. 6) topology_drawer_id: -1
  39. 7) topology_sibling_cpumask: just the given CPU
  40. 8) topology_core_cpumask: just the given CPU
  41. 9) topology_cluster_cpumask: just the given CPU
  42. 10) topology_die_cpumask: just the given CPU
  43. 11) topology_book_cpumask: just the given CPU
  44. 12) topology_drawer_cpumask: just the given CPU
  45. Additionally, CPU topology information is provided under
  46. /sys/devices/system/cpu and includes these files. The internal
  47. source for the output is in brackets ("[]").
  48. =========== ==========================================================
  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 or exceed the limit of CPUs allowed by the
  53. kernel configuration (kernel_max above).
  54. [~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. =========== ==========================================================
  61. The format for the above output is compatible with cpulist_parse()
  62. [see <linux/cpumask.h>]. Some examples follow.
  63. In this example, there are 64 CPUs in the system but cpus 32-63 exceed
  64. the kernel max which is limited to 0..31 by the NR_CPUS config option
  65. being 32. Note also that CPUs 2 and 4-31 are not online but could be
  66. brought online as they are both present and possible::
  67. kernel_max: 31
  68. offline: 2,4-31,32-63
  69. online: 0-1,3
  70. possible: 0-31
  71. present: 0-31
  72. In this example, the NR_CPUS config option is 128, but the kernel was
  73. started with possible_cpus=144. There are 4 CPUs in the system and cpu2
  74. was manually taken offline (and is the only CPU that can be brought
  75. online.)::
  76. kernel_max: 127
  77. offline: 2,4-127,128-143
  78. online: 0-1,3
  79. possible: 0-127
  80. present: 0-3
  81. See Documentation/core-api/cpu_hotplug.rst for the possible_cpus=NUM
  82. kernel start parameter as well as more information on the various cpumasks.