cat /proc/cpuinfo
1,processor 会从0开始记数 继续下去多个cpu
2,flags 如果有 ht 说明支持超线程技术
3,判断物理CPU的个数可以查看physical id 的值,相同则为同一个物理 CPU。
下面是自己服务器上的cpuinfo文件的内容:
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.953
cache size : 2048 KB
physical id : 3
siblings : 2
core id : 3
cpu cores : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat
pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm pni monitor ds_cpl cid
xtpr
bogomips : 5914.62
processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 10
cpu MHz : 3000.953
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat
pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm pni monitor ds_cpl cid
xtpr
bogomips : 5996.54
processor : 2
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 10
cpu MHz : 3000.953
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat
pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm pni monitor ds_cpl cid
xtpr
bogomips : 5996.54
processor : 3
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.953
cache size : 2048 KB
physical id : 3
siblings : 2
core id : 3
cpu cores : 1
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat
pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm pni monitor ds_cpl cid
xtpr
bogomips : 5980.16
也就是两个双核cpu
逻辑CPU个数:
# cat /proc/cpuinfo | grep "processor" | wc -l
物理CPU个数:
# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
每个物理CPU中Core的个数:
# cat /proc/cpuinfo | grep "cpu cores" | wc -l
是否为超线程?
如果有两个逻辑CPU具有相同的"core id",那么超线程是打开的。
每个物理CPU中逻辑CPU(可能是core, threads或both)的个数:
# cat /proc/cpuinfo | grep "siblings"
逻辑CPU个数:cat /proc/cpuinfo | grep "processor" | wc -l
物理CPU个数:cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
“siblings”指的是一个物理CPU有几个逻辑CPU
”cpu cores“指的是一个物理CPU有几个核
不应该按照flags里是否有ht标志来判断系统是否有超线程能力,而应该:
如果“siblings”和“cpu cores”一致,则说明不支持超线程,或者超线程未打开。
如果“siblings”是“cpu cores”的两倍,则说明支持超线程,并且超线程已打开。
举例说明:
两个双核超线程CPU :
processor 0 1 2 3 4 5 6 7
physical id 0 0 0 0 1 1 1 1
siblings 4 4 4 4 4 4 4 4
core id 0 0 1 1 0 0 1 1
cpu cores 2 2 2 2 2 2 2 2
http://linux.net527.cn/Linuxwendang/xitongguanliyuan/1401.html