centos Linux 正確識別cpu的個數和核心數__Linux

來源:互聯網
上載者:User
判斷依據: 

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.

查看當前作業系統核心資訊
# uname -a

Linux redcat 2.6.31-20-generic #58-Ubuntu SMP Fri Mar 12 05:23:09 UTC 2010 i686 GNU/Linux


查看當前作業系統發行版資訊

#cat /etc/issue
Ubuntu 9.10 \n \l

查看cpu型號

# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
2  Intel(R) Core(TM)2 Duo CPU     P8600  @ 2.40GHz
(看到有2個邏輯CPU, 也知道了CPU型號)

查看物理cpu顆數

# cat /proc/cpuinfo | grep physical | uniq -c 2 physical id    : 0
(說明實際上是1顆2核的CPU)


查看cpu運行模式

# getconf LONG_BIT

32

(說明當前CPU運行在32bit模式下, 但不代表CPU不支援64bit)


查看cpu是否支援64bit

# cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l

2

(結果大於0, 說明支援64bit計算. lm指long mode, 支援lm則是64bit)


查看cpu資訊概要(昨天看aix的時候剛發現的,在ubuntu上竟然也有~):

#lscpu

Architecture:          i686                            #架構686
CPU(s):                2                                   #邏輯cpu顆數是2
Thread(s) per core:    1                           #每個核心線程數是1                 
Core(s) per socket:    2                           #每個cpu插槽核心數/每顆物理cpu核心數是2
CPU socket(s):         1                            #cpu插槽數是1
Vendor ID:             GenuineIntel           #cpu廠商ID是GenuineIntel
CPU family:            6                              #cpu系列是6
Model:                 23                                #型號23
Stepping:              10                              #步進是10
CPU MHz:               800.000                 #cpu主頻是800MHz
Virtualization:        VT-x                         #cpu支援的虛擬化技術VT-x(對此在下一博文中解釋下http://hi.baidu.com/sdusoul/blog/item/5d8e0488def3a998a5c272c0.html)
L1d cache:             32K                         #一級緩衝32K(google了下,這具體表示表示cpu的L1資料緩衝為32k)
L1i cache:             32K                          #一級緩衝32K(具體為L1指令緩衝為32K)
L2 cache:              3072K                      #二級緩衝3072K

最後來個大而全的:

#cat /proc/cpuinfo

processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 23
model name    : Intel(R) Core(TM)2 Duo CPU     P8600  @ 2.40GHz
stepping    : 10
cpu MHz        : 800.000
cache size    : 3072 KB
physical id    : 0
siblings    : 2
core id        : 0
cpu cores    : 2
apicid        : 0
initial apicid    : 0
fdiv_bug    : no
hlt_bug        : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
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 nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm ida tpr_shadow vnmi flexpriority
bogomips    : 4788.60
clflush size    : 64
power management:

processor    : 1
vendor_id    : GenuineIntel
cpu family    : 6
model        : 23
model name    : Intel(R) Core(TM)2 Duo CPU     P8600  @ 2.40GHz
stepping    : 10
cpu MHz        : 800.000
cache size    : 3072 KB
physical id    : 0
siblings    : 2
core id        : 1
cpu cores    : 2
apicid        : 1
initial apicid    : 1
fdiv_bug    : no
hlt_bug        : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
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 nx lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm ida tpr_shadow vnmi flexpriority
bogomips    : 4787.96
clflush size    : 64
power management:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.