Querying the number of CPU cores in Linux

Time:2021-11-23

Take a Linux server as an example. This Linux includes twoIntel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz  CPU. A single CPU includes 10 CPU cores and 20 logical CPU cores. Specific official introduction:  E5-2630 V4

Let’s find the corresponding parameters through linux commands to see whether they comply with the official introduction, mainly to check/proc/cpuinfoInformation obtained.

View CPU model

 cat /proc/cpuinfo | grep 'model name' | sort | uniq
Output: Model Name: Intel (R) Xeon (R) CPU e5-2630 V4 @ 2.20GHz

View the number of CPUs

The number of CPUs in the actual server slot and the number of physical CPUs can be non repeated  physical idnumber.

cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l
Output: 2

View CPU cores

The number of chipsets that can process data on a CPU.

cat /proc/cpuinfo |grep "cores"|uniq|awk '{print $4}'
Output: 10

Number of logical CPU cores

Generally, we think that a CPU can have multiple cores, plusintelHyper threading technology (HT) can logically simulate a physical thread into two threads, so that a single core can be used like two cores to give full play to the performance of the CPU,

logicCPUQuantity = physicalcpuquantityx cpu coresThis specification valuex 2(if hyper threading is supported and enabled).

topWhat the command finds is logicCPUNumber of.

cat /proc/cpuinfo |grep "processor"|wc -l
Output: 40

This work adoptsCC agreement, reprint must indicate the author and the link to this article

Recommended Today

Seven solutions for distributed transactions

1、 What is distributed transaction Distributed transaction means that transaction participants, transaction supporting servers, resource servers and transaction managers are located on different nodes of different distributed systems. A large operation is completed by more than n small operations. These small operations are distributed on different services. For these operations, either all of them are […]