Interpreting output of cat/proc/cpuinfo

The entries are logical processors; objects used by the kernel internally, not necessarily tied to physical devices. (Note that they all have the same physical id.)

In other words, they represent the four cores of a single Intel i3 CPU.

Also, as noted on this post (which is not exactly a duplicate but closely related), those cores are logical as well – the CPU has two cores physically but supports hyperthreading.

Note that some Intel processors (the i5 included) use hyperthreading, a system where a single processor has (for example) 2 pyhsical cores, but will provide 4 logical cores - allowing the operating system to treat the processor as having more cores than it really does.


If your system has the lscpu tool (part of recent util-linux), it would output a more human-readable summary of the CPUs installed, for example:

Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1

Here is an inline awk script to pretty-print and extract relevant data from /proc/cpuinfo :

cat /proc/cpuinfo | \
awk -v FS=':' '                                       \
  /^physical id/ { if(nb_cpu<$2)  { nb_cpu=$2 } }     \
  /^cpu cores/   { if(nb_cores<$2){ nb_cores=$2 } }   \
  /^processor/   { if(nb_units<$2){ nb_units=$2 } }   \
  /^model name/  { model=$2 }                         \
                                                      \
  END{                                                \
   nb_cpu=(nb_cpu+1);                                 \
   nb_units=(nb_units+1);                             \
                                                      \
   print "CPU model:",model;                          \
   print nb_cpu,"CPU,",nb_cores,"physical cores per CPU, total",nb_units,"logical CPU units" \
 }'

Output for a high-performance server:

CPU model:  Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz
2 CPU,  6 physical cores per CPU, total 24 logical CPU units

Output for a Core i5 laptop:

CPU model:  Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
1 CPU,  2 physical cores per CPU, total 4 logical CPU units

Tags:

Linux

Cpu