1. 程式人生 > 其它 >Linux系統檢視物理CPU個數、核數、邏輯CPU個數

Linux系統檢視物理CPU個數、核數、邏輯CPU個數

檢視物理CPU個數、核數、邏輯CPU個數

總核數 = 物理CPU個數 X 每顆物理CPU的核數

總邏輯CPU數 = 物理CPU個數 X 每顆物理CPU的核數 X 超執行緒數

# 檢視物理CPU個數
這個伺服器有2個物理CPU
[root@salt ~]# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
2
# 檢視每個物理CPU中core的個數(核數)
[root@salt ~]# cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores : 8
# 檢視邏輯CPU的個數
[root@salt ~]# cat /proc/cpuinfo| grep "processor"| wc -l
32
這個伺服器一共32個邏輯CPU,也就是我們常說的執行緒數,也就說每個核可以提供2個執行緒。
# 檢視CPU資訊(型號)
[root@salt ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
32 Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz

lscpu命令檢視cpu的詳細資訊

[root@salt ~]# lscpu
Architecture: x86_64 #指CPU的架構
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 32 #指CPU的核數
On-line CPU(s) list: 0-31
Thread(s) per core: 2 #指的每個 Core 的硬體執行緒數,超執行緒,數值為1,表示不支援超執行緒
Core(s) per socket: 8 #指的是CPU的核心(單個CPU的核心)
Socket(s): 2 #指的是主機板上CPU的插槽,伺服器通常會有多個
NUMA node(s): 2
Vendor ID: GenuineIntel
CPU family: 6
Model: 79
Model name: Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz #cpu型號
Stepping: 1
CPU MHz: 2100.046
BogoMIPS: 4199.39
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 20480K
NUMA node0 CPU(s): 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
NUMA node1 CPU(s): 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31