歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> Linux系統下,CPU信息詳解(cpuinfo,多核,多線程)

Linux系統下,CPU信息詳解(cpuinfo,多核,多線程)

日期:2017/3/6 14:28:14   编辑:關於Unix
Linux系統下,CPU信息詳解(cpuinfo,多核,多線程) 軟件測試 在Linux系統中,如何詳細了解CPU的信息呢? 當然是通過cat /proc/cpuinfo來檢查了,但是比如幾個物理CPU/幾核/幾線程,這些問題怎麼確定呢? 經過查看,我的開發機器是1個物理CPU,4核8線程,Intel(

 Linux系統下,CPU信息詳解(cpuinfo,多核,多線程)軟件測試

  在Linux系統中,如何詳細了解CPU的信息呢? 當然是通過cat /proc/cpuinfo來檢查了,但是比如幾個物理CPU/幾核/幾線程,這些問題怎麼確定呢?

  經過查看,我的開發機器是1個物理CPU,4核8線程,Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz

  記錄一下,判斷的過程和知識

  判斷依據:

  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.

  echo "logical CPU number:"

  #邏輯CPU個數

  cat /proc/cpuinfo | grep "processor" | wc -l

  echo "physical CPU number:"

  #物理CPU個數:

  cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l

  echo "core number in a physical CPU:"

  #每個物理CPU中Core的個數:

  cat /proc/cpuinfo | grep "cpu cores" | uniq | awk -F: '{print $2}'

  #查看每個physical cpu上core id的數量,即為每個物理CPU上的core的個數

  cat /proc/cpuinfo | grep "core id"

  #是否為超線程?

  #如果有兩個邏輯CPU具有相同的”core id”,那麼超線程是打開的。

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

  cat /proc/cpuinfo | grep "siblings"

  /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 條目也可以表示是否支持多內核。

  判斷CPU是否64位,檢查cpuinfo中的flags區段,看是否有lm標識。

  Are the processors 64-bit?

  A 64-bit processor will have lm ("long mode") in the flags section of cpuinfo. A 32-bit processor will not.

Copyright © Linux教程網 All Rights Reserved