本文主要是介绍图说Linux cpuinfo,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
命令
cat /proc/cpuinfo
输出
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 106
model name : Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
stepping : 6
microcode : 0xd0003d1
cpu MHz : 3446.620
cache size : 55296 KB
physical id : 0
siblings : 16
core id : 0
cpu cores : 8
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 27
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves wbnoinvd ida arat avx512vbmi pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs mmio_stale_data gds
bogomips : 5799.97
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 106
model name : Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
stepping : 6
microcode : 0xd0003d1
cpu MHz : 3441.970
cache size : 55296 KB
physical id : 0
siblings : 16
core id : 1
cpu cores : 8
apicid : 2
initial apicid : 2
fpu : yes
fpu_exception : yes
cpuid level : 27
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves wbnoinvd ida arat avx512vbmi pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear flush_l1d arch_capabilities
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs mmio_stale_data gds
bogomips : 5799.97
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:
图说
2块cpu(即2个插槽)
cpu配置:8核心,并且开启了超线程
注意:core id可能不连续
查看cpu相关配置
查看cpu配置
方法1
cat /proc/cpuinfo
processor | 系统中逻辑处理核心数的编号,从0开始排序 |
---|---|
vendor_id | CPU制造商 |
cpu family | CPU产品系列代号 |
model | CPU属于其系列中的哪一代的代号 |
model name | CPU属于的名字及其编号、标称主频 |
stepping | CPU属于制作更新版本 |
cpu MHz | CPU的实际使用主频 |
cache size | CPU L3 缓存大小(参考lscpu输出与cpuinfo核对数据) |
physical id | 单个物理CPU的标号 |
siblings | 单个物理CPU的逻辑CPU数。siblings=cpu cores [*2]。 |
core id | 当前物理核在其所处CPU中的编号,这个编号不一定连续。 |
cpu cores | 该逻辑核所处CPU的物理核数。比如此处cpu cores 是4个,那么对应core id 可能是 1、3、4、5。 |
apicid | 用来区分不同逻辑核的编号,系统中每个逻辑核的此编号必然不同,此编号不一定连续 |
initial apicid | |
fpu | 是否具有浮点运算单元(Floating Point Unit) |
fpu_exception | 是否支持浮点计算异常 |
cpuid level | 执行cpuid指令前,eax寄存器中的值,根据不同的值cpuid指令会返回不同的内容 |
wp | 表明当前CPU是否在内核态支持对用户空间的写保护(Write Protection) |
flags | 当前CPU支持的功能 |
bugs | |
bogomips | 在系统内核启动时粗略测算的CPU速度(Million Instructions Per Second |
clflush size | 每次刷新缓存的大小单位 |
cache_alignment | 缓存地址对齐单位 |
address sizes | 可访问地址空间位数 |
power management | 对能源管理的支持 |
方法2
lscpu
Architecture | x86_64 |
---|---|
CPU op-mode(s) | 32-bit, 64-bit |
Byte Order | Little Endian |
CPU(s) | 64 |
On-line CPU(s) list | 0-31 |
Off-line CPU(s) list | 32-63 |
Thread(s) per core | 1 |
Core(s) per socket | 32 |
Socket(s) | 1 |
NUMA node(s) | 1 |
Vendor ID | GenuineIntel |
CPU family | 6 |
Model | 106 |
Model name | Intel® Xeon® Platinum 8375C CPU @ 2.90GHz |
Stepping | 6 |
CPU MHz | 3503.307 |
BogoMIPS | 5799.96 |
Hypervisor vendor | KVM |
Virtualization type | full |
L1d cache | 48K |
L1i cache | 32K |
L2 cache | 1280K |
L3 cache | 55296K |
NUMA node0 CPU(s) | 0-31 |
Flags | fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves wbnoinvd ida arat avx512vbmi pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear flush_l1d arch_capabilities |
查看逻辑cpu数量
cat /proc/cpuinfo | grep "processor" | wc -l
查看物理cpu数量
cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l
查看每个物理CPU中Core的个数
cat /proc/cpuinfo | grep "cpu cores" | uniq | awk -F: '{print $2}'
查看core id的数量
即为所有物理CPU上的core的总数,实际数量可能<=物理cpu数量*cpu cores,因为容器可能与其他服务共享了资源
cat /proc/cpuinfo | grep "core id" | uniq | wc -l
每个物理CPU中逻辑CPU(可能是core, threads或both)数量
cat /proc/cpuinfo | grep "siblings"
超频判断方法
- 同一块物理cpu下具有相同core id的cpu是同一个core的超线程(超频)
- 或者siblings = 2 * cpu cores 也说明开启了超线程(超频)
这篇关于图说Linux cpuinfo的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!