Linux checks the number of physical CPUs, cores, and logical CPUs

from: https://www.cnblogs.com/bugutian/p/6138880.html  


Total number of CPU cores = number of physical CPUs * number of cores per physical CPU 
Total number of logical CPUs = number of physical CPUs * number of cores per physical CPU * number of hyperthreads

copy code
View CPU Information (Model)
[root@AAA ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
     24         Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz

# View the number of physical CPUs
[root@AAA ~]# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
2

# View the number of cores in each physical CPU (ie, the number of cores)
[root@AAA ~]# cat /proc/cpuinfo| grep "cpu cores"| uniq
cpu cores    : 6

# View the number of logical CPUs
[root@AAA ~]# cat /proc/cpuinfo| grep "processor"| wc -l
24
copy code

 

What do these represent, then please look at the CPU architecture

Multiple physical CPUs, the CPU communicates through the bus, and the efficiency is relatively low, as follows:

Multi-core CPU, different cores communicate through L2 cache, storage and peripherals communicate with CPU through bus, as follows:

Multi-core hyperthreading, each core has two logical processing units, and the two cores share the resources of one core, as follows:

From the results of the above execution, it proves that the cpu I am using has 2 * 6 = 12 cores, and each core has 2 hyperthreads, so there are 24 logical cpus.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324629594&siteId=291194637