cputopology.txt 2.9 KB

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