一、概念
1、物理CPU
插槽上的CPU个数,物理cpu数量等于不同physical id的个数。2、逻辑CPU
逻辑CPU数量 = 物理cpu数量 x cpu cores这个规格值 x siblings/cpu cores(如果支持并支持超线程,此值大于1)
3、CPU核数
一颗CPU上面能处理数据的芯片组的数量,一般来说,物理CPU个数 X cpu cores = 逻辑CPU的个数。如果不相等的话,则表示服务器的CPU支持超线程技术。
二、下面举例说明
1、输入:cat /proc/cpuinfo,得到如下:
guest@node43:~$ cat /proc/cpuinfoprocessor
vendor_id
cpu family
model
model name
stepping
cpu MHz
cache size
physical id
siblings
core id
cpu cores
fpu
fpu_exception
cpuid level
wp
flags
bogomips
TLB size
clflush size
cache_alignment : 64
address sizes
power management: ts ttp tm stc 100mhzsteps hwpstate
processor
vendor_id
cpu family
model
model name
stepping
cpu MHz
cache size
physical id
siblings
core id
cpu cores
fpu
fpu_exception
cpuid level
wp
flags
bogomips
TLB size
clflush size
cache_alignment : 64
address sizes
power management: ts ttp tm stc 100mhzsteps hwpstate
processor
vendor_id
cpu family
model
model name
stepping
cpu MHz
cache size
physical id
siblings
core id
cpu cores
fpu
fpu_exception
cpuid level
wp
flags
bogomips
TLB size
clflush size
cache_alignment : 64
address sizes
power management: ts ttp tm stc 100mhzsteps hwpstate
processor
vendor_id
cpu family
model
model name
stepping
cpu MHz
cache size
physical id
siblings
core id
cpu cores
fpu
fpu_exception
cpuid level
wp
flags
bogomips
TLB size
clflush size
cache_alignment : 64
address sizes
power management: ts ttp tm stc 100mhzsteps hwpstate
processor
vendor_id
cpu family
model
model name
stepping
cpu MHz
cache size
physical id
siblings
core id
cpu cores
fpu
fpu_exception
cpuid level
wp
flags
bogomips
TLB size
clflush size
cache_alignment : 64
address sizes
power management: ts ttp tm stc 100mhzsteps hwpstate
processor
vendor_id
cpu family
model
model name
stepping
cpu MHz
cache size
physical id
siblings
core id
cpu cores
fpu
fpu_exception
cpuid level
wp
flags
bogomips
TLB size
clflush size
cache_alignment : 64
address sizes
power management: ts ttp tm stc 100mhzsteps hwpstate
processor
vendor_id
cpu family
model
model name
stepping
cpu MHz
cache size
physical id
siblings
core id
cpu cores
fpu
fpu_exception
cpuid level
wp
flags
bogomips
TLB size
clflush size
cache_alignment : 64
address sizes
power management: ts ttp tm stc 100mhzsteps hwpstate
processor
vendor_id
cpu family
model
model name
stepping
cpu MHz
cache size
physical id
siblings
core id
cpu cores
fpu
fpu_exception
cpuid level
wp
flags
bogomips
TLB size
clflush size
cache_alignment : 64
address sizes
power management: ts ttp tm stc 100mhzsteps hwpstate
可以看出:
- physical id 从0到1,说明有2个物理cpu;
- processor
从0到7,说明有8个逻辑CPU(如果不支持超线程的话); - 支不支持超线程,就看siblings和cpu cores是否相等,如果siblings=cpu cores,则不支持超线程;如果siblings > cpu cores,则支持超线程,此时 逻辑cpu个数 = (processor :n中的n) X (siblings/cpu cores)。本例中,siblings=cpu cores=4,所以本机器的 逻辑cpu个数 = 8 X 4/4 = 8。
- core id由物理cpu决定,同一个physical id上的core id从0到n-1,n为cpu cores的值。例如本例中的core id从0到3,然后又从0到3,前者是physical id=0的物理cpu上的核,后者是physical id=1的物理cpu上的核。
注意:cpu的个数只与processor 、physical id、siblings 、cpu cores 四个参数有关,其他参数值可以不用考虑。
2、查看物理CPU的个数
guest@node43:~$ cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l2
3、查看逻辑CPU的个数
guest@node43:~$ cat /proc/cpuinfo |grep "processor"|wc -l8
4、查看一个物理CPU是几核
guest@node43:~$ cat /proc/cpuinfo |grep "cores"|uniq4