歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux檢查雙核(及多核)CPU信息

Linux檢查雙核(及多核)CPU信息

日期:2017/2/28 16:23:43   编辑:Linux教程

1. 可以從 /proc/cpuinfo 中獲取CPU的一些信息
[[email protected]]# cat /proc/cpuinfo
processor : 0 -- 邏輯CPU id
vendor_id : GenuineIntel
cpu family : 6
model : 26
model name : Intel(R) Xeon(R) CPU E5504 @ 2.00GHz
stepping : 5
cpu MHz : 1995.000
cache size : 4096 KB
physical id : 16 -- 物理CPU id
siblings : 1
core id : 255
cpu cores : 1
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx rdtscp lm pni monitor ds_cpl est tm2 cx16 xtpr popcnt lahf_lm
bogomips : 3993.24
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 26
model name : Intel(R) Xeon(R) CPU E5504 @ 2.00GHz
stepping : 5
cpu MHz : 1596.000
cache size : 4096 KB
physical id : 0
siblings : 1
core id : 255
cpu cores : 1
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx rdtscp lm pni monitor ds_cpl est tm2 cx16 xtpr popcnt lahf_lm
bogomips : 3990.05
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:
……

2. 獲取物理CPU個數
[[email protected]]# cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
8

3. 獲取邏輯CPU個數
[[email protected]]# cat /proc/cpuinfo | grep "processor" | wc -l

4. 每個物理CPU中Core的個數:每個相同的physical id都有其對應的core id。如core id分別為1、2、3、4,則表示是Quad-Core CPU,若core id分別是1、2,則表示是Dual-Core。
[[email protected]]# cat /proc/cpuinfo | grep "cpu cores" | wc -l
8

5. 每個物理CPU中邏輯CPU(可能是core, threads或both)的個數:

  # cat /proc/cpuinfo | grep "siblings"

它既可能是cores的個數,也可能是core的倍數。當它和core的個數相等時,表示每一個core就是一個邏輯CPU,若它是core的2倍時,表示每個core又enable了超線程(Hyper-Thread)。
比如:一個雙核的啟用了超線程的物理cpu,其core id分別為1、2,但是sibling是4,也就是如果有兩個邏輯CPU具有相同的"core id",那麼超線程是打開的。

綜上所述:實際我們所說的雙核,四核是看物理cpu的個數。

Copyright © Linux教程網 All Rights Reserved