如何查看有幾個處理器,是否多核?是否超執行緒?

來源:互聯網
上載者:User

邏輯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
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

linux 下CPU數量、核心數量、是否支援超執行緒的判斷

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

判斷依據:
1.具有相同core id的cpu是同一個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.

執行個體:

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個邏輯CPU,通過physical id,前面兩個邏輯cpu的相同,後面兩個的相同,所以有兩個物理CPU。前面兩個的 core id相同,後面的兩個core ID相同,說明這兩個CPU都是單核。也就是說兩個單核cpu,啟用了超執行緒技術。
通過intel的cpu的參數可以初步判斷 使用的是兩個 Xeon奔騰4CPU ,有點差。。。。
如何獲得CPU的詳細資料:

linux命令:cat /proc/cpuinfo

用命令判斷幾個物理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'
其他特徵:

目前intel新的多核心cpu都會在後面顯示具體的型號數字,例如:

model name : Intel(R) Xeon(R) CPU           X3230   @ 2.66GHz

說明是 Xeon 3230的cpu,而不顯示型號的具體數位,大部分都是奔騰的CPU

很多主機商都騙人,用奔騰的cpu,卻說是多核心的CPU。

探針看到的資料:

類型: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

沒有具體的型號,緩衝1M,一般都是奔騰系列的cpu,或者是intel假雙核的cpu,具體要根據上面說的去判斷。新的多核心cpu都能看到具體的型號。
另外多核心的xeon的CPU,一般主頻都不高,達到2.8和3.0的只有很少的幾個高端CPU型號,一般主機商不會用這麼好的。

一些作業系統的最新版本已經更新了 /proc/cpuinfo 檔案,以支援多路平台。如果您的系統中的 /proc/cpuinfo 檔案能夠正確地反映出處理器資訊,那麼就不需要執行上述步驟。反之,可採用本文中的資訊進行解釋。

/proc/cpuinfo 檔案包含系統上每個處理器的資料區段落。/proc/cpuinfo 描述中有 6 個條目適用於多核心和超執行緒(HT)技術檢查:processor, vendor id, physical id, siblings, core id 和 cpu cores。

processor 條目包括這一邏輯處理器的唯一識別碼。
physical id 條目包括每個物理封裝的唯一識別碼。
core id 條目儲存每個核心的唯一識別碼。
siblings 條目列出了位於相同物理封裝中的邏輯處理器的數量。
cpu cores 條目包含位於相同物理封裝中的核心數量。

如果處理器為英特爾處理器,則 vendor id 條目中的字串是 GenuineIntel。

1.擁有相同 physical id 的所有邏輯處理器共用同一個物理插座。每個 physical id 代表一個唯一的物理封裝。

2.Siblings 表示位於這一物理封裝上的邏輯處理器的數量。它們可能支援也可能不支援超執行緒(HT)技術。

3.每個 core id 均代表一個唯一的處理器核心。所有帶有相同 core id 的邏輯處理器均位於同一個處理器核心上。

4.如果有一個以上邏輯處理器擁有相同的 core id 和 physical id,則說明系統支援超執行緒(HT)技術。

5.如果有兩個或兩個以上的邏輯處理器擁有相同的 physical id,但是 core id 不同,則說明這是一個多核心處理器。cpu cores 條目也可以表示是否支援多核心。

例如,如果系統包含兩個物理封裝,每個封裝中又包含兩個支援超執行緒(HT)技術的處理器核心,則 /proc/cpuinfo 檔案將包含此資料。(註:資料並不在表格中。)

linux 下CPU數量、核心數量、是否支援超執行緒的判斷

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.