cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Etc


Reference














.

os:linux:performance:cpu.html



Linux#Performance

Linux:Performance:CPU

Check CPU Number

The number of physical CPU (The number of Socket)

  • The number don't include core and HT
cat /proc/cpuinfo | grep "physical id" |sort | uniq | wc -l

The number of Cores per Socket

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

The number of Processors.

  • Include HT and don't include core
  • This number equals top, mpstat commands.
cat /proc/cpuinfo | grep processor | wc -l

The number of total core (CPU x core)

cat /proc/cpuinfo |grep "cpu cores" | perl -e 'while(<>){$n+=/(\d+)/?$1:0;}print"$n\n";'


Example1

Intel Xeon /2.333GHz 2CPU 2core

The number of physical CPU

  • This number don't include core and HT.
# cat /proc/cpuinfo | grep "physical id" |sort
physical id     : 0
physical id     : 0
physical id     : 3
physical id     : 3

# cat /proc/cpuinfo | grep "physical id" |sort | uniq
physical id     : 0
physical id     : 3

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

The number of Processors.

  • This number is equal to the cpu numbers of top commands.
  • This number enable HT and don't include core.
# cat /proc/cpuinfo | grep processor
processor       : 0
processor       : 1
processor       : 2
processor       : 3

# cat /proc/cpuinfo | grep processor |wc -l
4

The number of total core

# cat /proc/cpuinfo |grep "cpu cores"
cpu cores       : 2
cpu cores       : 2
cpu cores       : 2
cpu cores       : 2

# cat /proc/cpuinfo |grep "cpu cores" | perl -e 'while(<>){$n+=/(\d+)/?$1:0;}print"$n\n";'
8

top

  • The number of CPU include HT.
top - 08:29:00 up 216 days, 22:29,  1 user,  load average: 0.55, 1.10, 1.17
Tasks: 135 total,   1 running, 134 sleeping,   0 stopped,   0 zombie
Cpu0  :  0.6%us,  0.3%sy,  0.0%ni, 93.6%id,  5.5%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  0.6%us,  0.3%sy,  0.0%ni, 95.5%id,  3.5%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu2  :  1.5%us,  0.6%sy,  0.0%ni, 76.6%id, 21.2%wa,  0.0%hi,  0.1%si,  0.0%st
Cpu3  :  0.8%us,  0.4%sy,  0.0%ni, 94.9%id,  3.8%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   2059340k total,  1730316k used,   329024k free,   151200k buffers
Swap:  2048152k total,      148k used,  2048004k free,   950676k cached


  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      15   0 10344  676  568 S  0.0  0.0   0:10.74 init
    1 root      15   0 10344  676  568 S  0.0  0.0   0:10.74 init
    2 root      RT  -5     0    0    0 S  0.0  0.0   0:43.41 migration/0
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.07 ksoftirqd/0
    4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    5 root      RT  -5     0    0    0 S  0.0  0.0   0:40.33 migration/1
    6 root      34  19     0    0    0 S  0.0  0.0   0:00.06 ksoftirqd/1
    7 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/1
    8 root      RT  -5     0    0    0 S  0.0  0.0   0:42.92 migration/2
    9 root      34  19     0    0    0 S  0.0  0.0   0:01.52 ksoftirqd/2
#abbr

mpstat

# mpstat -P ALL
Linux 2.6.18-274.el5 (centos57)         06/10/16

00:39:06     CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
00:39:06     all   29.12    0.00    4.00    1.26    0.17    0.52    0.00   64.93   1026.93
00:39:06       0   29.12    0.00    4.00    1.26    0.17    0.52    0.00   64.93   1026.93



os/linux/performance/cpu.html.txt ยท Last modified: 2017/05/14 by admin

Page Tools