Shell實(shí)現(xiàn)識(shí)別物理cpu個(gè)數(shù)、核心數(shù)
如何識(shí)別物理cpu個(gè)數(shù),幾個(gè)核,是超線程還是多核心
判斷依據(jù):
1.具有相同core id的cpu是同一個(gè)core的超線程。
2.具有相同physical id的cpu是同一顆cpu封裝的線程或者cores。
英文版:
1.Physical id and core id are not necessarily consecutive but they are unique. Any cpu with the same core id are hyperthreads in the same core.
2.Any cpu with the same physical id are threads or cores in the same physical socket.
實(shí)例:
LunarPages的CPU信息:
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.881
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 constant_tsc pni monitor ds_cpl cid xtpr
bogomips : 6006.73
processor : 1
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.881
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 constant_tsc pni monitor ds_cpl cid xtpr
bogomips : 5999.40
processor : 2
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.881
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 constant_tsc pni monitor ds_cpl cid xtpr
bogomips : 5999.08
processor : 3
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Xeon(TM) CPU 3.00GHz
stepping : 3
cpu MHz : 3000.881
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 constant_tsc pni monitor ds_cpl cid xtpr
bogomips : 5999.55
顯示4個(gè)邏輯CPU,通過(guò)physical id ,前面兩個(gè)邏輯cpu的相同,后面兩個(gè)的相同,所以有兩個(gè)物理CPU。前面兩個(gè)的 core id相同,后面的兩個(gè)core ID相同,說(shuō)明這兩個(gè)CPU都是單核。也就是說(shuō)兩個(gè)單核cpu,啟用了超線程技術(shù)。
通過(guò)intel的cpu的參數(shù)可以初步判斷 使用的是兩個(gè) Xeon奔騰4CPU ,有點(diǎn)差。。。。
如何獲得CPU的詳細(xì)信息:
linux命令:cat /proc/cpuinfo
用命令判斷幾個(gè)物理CPU,幾個(gè)核等:
邏輯CPU個(gè)數(shù):
# cat /proc/cpuinfo | grep “processor” | wc -l
物理CPU個(gè)數(shù):
# cat /proc/cpuinfo | grep “physical id” | sort | uniq | wc -l
每個(gè)物理CPU中Core的個(gè)數(shù):
# cat /proc/cpuinfo | grep “cpu cores” | wc -l
是否為超線程?
如果有兩個(gè)邏輯CPU具有相同的”core id”,那么超線程是打開的。
每個(gè)物理CPU中邏輯CPU(可能是core, threads或both)的個(gè)數(shù):
# cat /proc/cpuinfo | grep “siblings”
其他特征:
目前intel新的多核心cpu都會(huì)在后面顯示具體的型號(hào)數(shù)字,例如:
model name : Intel(R) Xeon(R) CPU X3230 @ 2.66GHz
說(shuō)明是 Xeon 3230的cpu,而不顯示型號(hào)的具體數(shù)字的,大部分都是奔騰的CPU
很多主機(jī)商都騙人,用奔騰的cpu,卻說(shuō)是多核心的CPU。
探針看到的數(shù)據(jù):
類型:Intel(R) Xeon(TM) CPU 2.80GHz 緩存:1024 KB
類型:Intel(R) Xeon(TM) CPU 2.80GHz 緩存:1024 KB
類型:Intel(R) Xeon(TM) CPU 2.80GHz 緩存:1024 KB
類型:Intel(R) Xeon(TM) CPU 2.80GHz 緩存:1024 KB
沒(méi)有具體的型號(hào),緩存1M,一般都是奔騰系列的cpu,或者是intel假雙核的cpu,具體要根據(jù)上面說(shuō)的去判斷。新的多核心cpu都能看到具體的型號(hào)。
另外多核心的xeon的CPU,一般主頻都不高,達(dá)到2.8和3.0的只有很少的幾個(gè)高端CPU型號(hào),一般主機(jī)商不會(huì)用這么好的
相關(guān)文章
通過(guò)shell腳本對(duì)mysql的增刪改查及my.cnf的配置
這篇文章主要介紹了通過(guò)shell腳本對(duì)mysql的增刪改查及my.cnf的配置,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-07-07Linux中SELinux、Shell簡(jiǎn)介、touch命令的應(yīng)用小結(jié)
SELinux(Security-Enhanced Linux)是美國(guó)國(guó)家安全局(NSA)對(duì)于強(qiáng)制訪問(wèn)控制的實(shí)現(xiàn),是Linux歷史上最杰出的新安全子系統(tǒng),這篇文章主要介紹了Linux中SELinux、Shell簡(jiǎn)介、touch命令的應(yīng)用知識(shí)總結(jié),需要的朋友可以參考下2023-02-02解決VirtualBox中Ubuntu 14.04屏幕分辨率不能設(shè)置的問(wèn)題
下面小編就為大家?guī)?lái)一篇解決VirtualBox中Ubuntu 14.04屏幕分辨率不能設(shè)置的問(wèn)題。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-05-05普通用戶啟動(dòng)supervisor報(bào)HTTP錯(cuò)誤(strace)解決分析
這篇文章主要為大家介紹了普通用戶啟動(dòng)supervisor報(bào)HTTP錯(cuò)誤strace的問(wèn)題解決分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07Shell腳本中讓進(jìn)程休眠的方法(sleep用法)
這篇文章主要介紹了Shell腳本中讓進(jìn)程休眠的方法,本文講解的就是sleep的用法,可以實(shí)現(xiàn)睡覺(jué)若干秒、若干分鐘、若干小時(shí),需要的朋友可以參考下2014-11-11Shell腳本實(shí)現(xiàn)監(jiān)控iptables運(yùn)行狀態(tài)
這篇文章主要介紹了Shell腳本實(shí)現(xiàn)監(jiān)控iptables運(yùn)行狀態(tài),本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下2014-12-12