天天看點

linux+多核+超線程,LINUX系統 多核CPU小記

實體CPU,多核,超線程

判斷依據:

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. 1.

實體CPU,多核,超線程

1)實體CPU個數

$ cat /proc/cpuinfo | grep "physical id" | uniq

physical id     : 0

=>CPU個數:1個

2)CPU核數

$ cat /proc/cpuinfo | grep "cpu cores" | uniq

cpu cores       : 8

=》CPU核數:8個核

3)是否是超線程

$ cat /proc/cpuinfo | grep "core id"

core id         : 0

core id         : 1

core id         : 2

core id         : 3

core id         : 4

core id         : 5

core id         : 6

core id         : 7

=》core id都不一樣,是以沒有超線程

2。檢視每個CPU的使用率

$top -d 1(數字1)

再按數字1,顯示如下

Tasks: 194 total,   1 running, 193 sleeping,   0 stopped,   0 zombie

Cpu0  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Cpu1  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Cpu2  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Cpu3  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Cpu4  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Cpu5  :  0.0%us,  1.0%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Cpu6  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Cpu7  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

Mem:   3095260k total,  1871716k used,  1223544k free,   622332k buffers

Swap:  4191228k total,        0k used,  4191228k free,   904036k cached

3。檢視程序是哪個CPU上運作

$top -d 1(數字1)f,進入"top Current Fields" j,選中  j: P          = Last used cpu (SMP) 回車 多了一列P,COMMAND前面   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  P COMMAND                                        9978 public    20   0  2632 1196  876 R    1  0.0   0:02.64 5   top                                           4。檢視目前核心是否支援SMP $uname -a Linux  2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux 有SMP