cputopology.txt 3.2 KB

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