首頁 > 軟體

Linux檢視CPU資訊詳解

2020-06-16 17:23:07

Linux檢視CPU資訊

首先,大家如果看到有什麼不懂的地方,歡迎吐槽!!!

引數說明:

  • Physical id 相同表示為同一個物理CPU
  • Processor 表示邏輯CPU
  • Cpu cores CPU核數,核心個數
  • Core id 核心id號
  • Siblings 每個物理CPU裡面的邏輯CPU個數

物理CPU 兩個

processor  0      processor  2       processor   4          processor   6
core id    0      core id    2       core id     1          core id     3
physical   0      physical   0       physical    0          physical    0
cpu cores  4      cpu cores  4       cpu cores   4          cpu cores   4
siblings   4      siblings   4        siblings   4          siblings    4

processor  1      processor  3       processor   5          processor   7
core id    0      core id    2       core id     1          core id     3
physical   1      physical   1       physical    1          physical    1
cpu cores  4      cpu cores  4       cpu cores   4          cpu cores   4
siblings   4      siblings   4       siblings   4           siblings    4

計算是否開啟超執行緒

邏輯CPU  >  物理CPU  x   CPU核數  #開啟超執行緒
邏輯CPU  =  物理CPU  x   CPU核數  #沒有開啟超執行緒或不支援超執行緒

檢視物理CPU個數

cat /proc/cpuinfo | grep “physical id” | sort -u | wc -l
2

檢視邏輯CPU個數

cat /proc/cpuinfo | grep “processor” | wc -l
8

檢視CPU核心數

cat /proc/cpuinfo | grep “cpu cores” | uniq
4

檢視單個物理CPU封裝的邏輯CPU數量

cat /proc/cpuinfo | grep “siblings” | uniq
4

script檢視CPU資訊

#!/bin/bash

physical=$(cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l)
processor=$(cat /proc/cpuinfo | grep "processor" | wc -l)
cpucores=$(cat /proc/cpuinfo  | grep "cpu cores" | uniq)
siblings=$(cat /proc/cpuinfo  | grep "siblings"  | uniq)

echo "* * * * * CPU Information is a : * * * * *"
echo "physical id is a : $physical"
echo "processor is a   : $processor"
echo "cpu cores is a   : $cpucores"
echo "siblings is a    : $siblings"

判斷CPU是32位元的還是64位元的

cat /proc/cpuinfo | grep lm 
8 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 pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good aperfmperf pni dtes64 monitor ds_cpl vmx tm2 ssse3 cx16 xtpr pdcm dca sse4_1 xsave lahf_lm dts tpr_shadow vnmi flexpriority
lm 表示Long Mode - 64位CPU

判斷系統是32位元的還是64位元的

uname -a 
i386  i686 代表32位元運算系統
X86_64     代表64位元運算系統

本文永久更新連結地址http://www.linuxidc.com/Linux/2017-01/140010.htm


IT145.com E-mail:sddin#qq.com