Article Title: Practical Tips: How to check the number of CPUs in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
# Cat/proc/cpuinfo
Linux
/Proc/cpuinfo
The file displays cpu information.
Processor starts counting from 0 and continues with multiple CPUs
If ht exists in flags, hyper-Threading Technology is supported.
To determine the number of physical CPUs, you can view the physical id value. The same physical CPU
Processor: 4
Vendor_id: GenuineIntel
Cpu family: 15
Model: 4
Model name: Intel (R) Xeon (TM) CPU 3.00 GHz
Stepping: 8
Cpu MHz: 3002.700
Cache size: 2048 KB
Physical id: 9
Siblings: 4
Core id: 19
Cpu cores: 2
------------------------------
Processor: 5
Vendor_id: GenuineIntel
Cpu family: 15
Model: 4
Model name: Intel (R) Xeon (TM) CPU 3.00 GHz
Stepping: 8
Cpu MHz: 3002.700
Cache size: 2048 KB
Physical id: 9
Siblings: 4
Core id: 19
Cpu cores: 2
-----------------------------------------------
Address sizes: 40 bits physical, 48 bits virtual
Power management:
Keywords: SMP linux multi-CPU number Hyper-Threading
Excerpt some online knowledge:
Hyper-Threading Technology uses special hardware commands to simulate two logical kernels into two physical chips, so that a single processor can use thread-level parallel computing, and thus be compatible with multi-threaded operating systems and software, this reduces the idle CPU time and improves the CPU running efficiency.
With hyper-threading, applications can use different chips at the same time. Although a single-thread chip can process thousands of commands per second, it can operate only one command at any time. The hyper-threading technology enables the chip to process multiple threads at the same time, improving the chip performance.
Hyper-threading technology is used to execute multiple programs at the same time on one CPU and share resources in one CPU. Theoretically, we need to execute two threads at the same time like two CPUs, the P4 processor needs to add one more Logical CPU Pointer (Logical processing unit ). Therefore, the new generation of P4 HT die is increased by 5% compared with the previous P4. The remaining parts, such as ALU, FPU, and L2 Cache, remain unchanged.
Although hyper-threading technology can be used to execute two threads at the same time, each CPU has independent resources, not just like two real CPUs. When both threads need a certain resource at the same time, one of them must be temporarily stopped and the resources must be made available until these resources are idle. Therefore, the performance of hyper-threading is not equal to the performance of two CPUs.
Intel P4 hyper-threading has two operating modes: Single Task Mode and Multi Task Mode. When the program does not support Multi-Processing (Multi-processor jobs, the system will stop running one of the logical CPUs and concentrate the resources in a single logical CPU, so that the single-thread program will not reduce performance because one of the logical CPUs is idle, however, because the logical CPU that is stopped will still wait for work and occupy some resources, when the Hyper-Threading CPU runs the Single Task Mode Program Mode, however, there may be insufficient CPU performance without hyper-threading, but the performance gap will not be too large. That is to say, when running a single thread to use software, hyper-Threading Technology may even reduce system performance, especially when a multi-threaded operating system runs a single thread software.