linux下cpu/mem的硬件拓扑

linux系统中,sysfs导出了很多系统硬件信息。cpu的拓扑即在其中。

cpu相关的拓扑信息位于/sys/devices/system/cpu下。

# ls /sys/devices/system/cpu
cpu0   cpu1 cpufreq  cpuidle crash_hotplug isolated  kernel_max microcode  modalias nohz_full offline online possible power present smt uevent vulnerabilities

isolated表示隔离的cpulist,online,offline,possible,present分配代表cpu的硬件状态。

在cpuX下有关于该cpu更详细的信息。

# ls /sys/devices/system/cpu/cpu0
cache    cpuidle      crash_notes_size  firmware_node  microcode  power      topology
cpufreq  crash_notes  driver            hotplug        node0      subsystem  uevent

这一层级可以得到cpu的频率,所属的numa。在cache目录下可以得到详细的cache信息。

# ls /sys/devices/system/cpu/cpu0/cache
index0  index1  index2  index3  uevent

# ls /sys/devices/system/cpu/cpu0/cache/index0
coherency_line_size  level           physical_line_partition  shared_cpu_map  type    ways_of_associativity
id                   number_of_sets  shared_cpu_list          size            uevent

topology下有详细的cpu拓扑信息。

# ls /sys/devices/system/cpu/cpu0/topology/
cluster_cpus       core_cpus       core_siblings       die_cpus_list  package_cpus_list    thread_siblings_list
cluster_cpus_list  core_cpus_list  core_siblings_list  die_id         physical_package_id
cluster_id         core_id         die_cpus            package_cpus   thread_siblings

可以看到cpu层级,cluster->package->die->core->thread。

在/sys/devices/system/node有numa信息。

# ls /sys/devices/system/node
has_cpu                has_memory         node0  node2  node4  node6  online    power
has_generic_initiator  has_normal_memory  node1  node3  node5  node7  possible  uevent

可以得到numa node的数量,包含cpu numa数量和memory numa数量(通常两者相等)

进一步可以在nodeX内找到更多信息。

# ls node0
compact cpu0 cpu1 cpulist hugepages meminfo memory0 memory1 cpumap
distance numastat power subsystem uevent vmstat memory_failure x86

cpulist表示当前numa node包含的cpu数,distance表示当前numa和所有numa之间的距离信息

posted @ 2024-04-18 14:23  半山随笔  阅读(2)  评论(0编辑  收藏  举报