Get the CPU information in Linux

Multi-core CPU processors are common nowadays, including dual-core processors, quad-core processors, and hexa-core processors. Also, many server physical machines are equipped with more than one CPU processor. In order to find the number CPUs, and the number of cores per CPU, you can refer to /proc/cpuinfo. A sample /proc/cpuinfo of HP Proliant DL 380 G7 server is as follows. 


To find the number of physical CPUs:
$ cat /proc/cpuinfo | grep "^physical id" | sort | uniq | wc -l
2

To find the number of cores per CPU:
$ cat /proc/cpuinfo | grep "^cpu cores" | uniq
cpu cores : 4

The total number of processors available is the number of physical CPUs multiplied by the number of cores per CPU.

To find the total number of processors:
$ cat /proc/cpuinfo | grep "^processor" | wc -l
16

Note that Intel Xeon 5600 series processors have Intel Hyper-Threading capability. So each core shows up as "two" processors in Linux, and thus the total processor count seen by Linux is 16 (= 2 x 4 x 2).

No comments:

Post a Comment