In Linux, you can use "cat /proc/cpuinfo | grep "cpu cores" | uniq" to view the number of CPU cores, that is, the number of cores in each physical CPU.
Course recommendation: "linux course"
1. Introduction to knowledge points
1. The cpu information is recorded in /proc/cpuinfo.
2. Top in Linux is equivalent to the task manager under the win system, and can also be used to query
3. The total number of CPU cores = the number of physical CPUs * the number of each physical CPU Number of cores
4. Total number of logical CPUs = Number of physical CPUs * Number of cores per physical CPU * Number of hyperthreads
2. Query command
查看CPU信息(型号) [root@AAA ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 24 Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz # 查看物理CPU个数 [root@AAA ~]# cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l 2 # 查看每个物理CPU中core的个数(即核数) [root@AAA ~]# cat /proc/cpuinfo| grep "cpu cores"| uniq cpu cores : 6 # 查看逻辑CPU的个数 [root@AAA ~]# cat /proc/cpuinfo| grep "processor"| wc -l 24
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 the CPU through the bus, as follows:
Multi-core hyperthreading, each core has Two logical processing units, two cores share the resources of one core, as follows:
From the above execution results, it proves that the CPU I am using has 2 * 6 = 12 cores, each core has 2 hyperthreads, so 24 logical cpu.
Related recommendations: "Linux Operation and Maintenance"
The above is the detailed content of How to check the number of CPU cores in Linux?. For more information, please follow other related articles on the PHP Chinese website!