cputopology.txt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. If one architecture wants to support this feature, it just needs to
  14. implement 4 defines, typically in file include/asm-XXX/topology.h.
  15. The 4 defines are:
  16. #define topology_physical_package_id(cpu)
  17. #define topology_core_id(cpu)
  18. #define topology_thread_siblings(cpu)
  19. #define topology_core_siblings(cpu)
  20. The type of **_id is int.
  21. The type of siblings is cpumask_t.
  22. To be consistent on all architectures, the 4 attributes should have
  23. default values if their values are unavailable. Below is the rule.
  24. 1) physical_package_id: If cpu has no physical package id, -1 is the
  25. default value.
  26. 2) core_id: If cpu doesn't support multi-core, its core id is 0.
  27. 3) thread_siblings: Just include itself, if the cpu doesn't support
  28. HT/multi-thread.
  29. 4) core_siblings: Just include itself, if the cpu doesn't support
  30. multi-core and HT/Multi-thread.
  31. So be careful when declaring the 4 defines in include/asm-XXX/topology.h.
  32. If an attribute isn't defined on an architecture, it won't be exported.