Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to distinguish between physical CPU, logical CPU and CPU kernels under Linux

Shulou Source: shulou.com Published: 2022-06-01 14:20:41 09月30日 Update

This article mainly explains "how to distinguish physical CPU, logical CPU and CPU kernels under Linux". The explanation in this article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how to distinguish physical CPU, logical CPU and CPU kernels under Linux".

㈠ concept

① physical CPU

Number of CPU on the slot in the actual Server

Number of physical cpu. You can count the number of physical id that are not duplicated.

② logic CPU

Linux users must be familiar with the file / proc/cpuinfo. It is used to store cpu hardware information

The information content lists the specifications of processor 0-n respectively. It should be noted here that if you think n is the real cpu number, you are making a big mistake.

In general, we think that a cpu can have multiple cores, coupled with intel's hyperthreading technology (HT), it can be logically divided into twice the number of cpu core.

Number of logical CPU = number of physical cpu x cpu cores this specification value x 2 (if ht is supported and enabled)

Note: the number of CPU viewed by top under Linux is also the number of logical CPU

③ CPU kernels

The number of chipsets on a CPU that can process data, such as i5760, is a dual-core four-thread CPU, while i5 2250 is a four-core four-thread CPU

Generally speaking, the number of physical CPU × the number of each core should be equal to the number of logical CPU. If it is not equal, it means that the CPU of the server supports hyperthreading technology.

㈡ View CPU Information

When we cat / proc/cpuinfo

A CPU with the same core id is a hyperthread of the same core

A CPU with the same physical id is a thread or core encapsulated by the same CPU

㈢, the following is an example

① to view the number of physical CPU

Cat / proc/cpuinfo | grep "physical id" | sort | uniq | wc-l

② to check the number of logical CPU

Cat / proc/cpuinfo | grep "processor" | wc-l

③ check how many cores CPU is.

Cat / proc/cpuinfo | grep "cores" | uniq

= supplement = =

Number of number of processors cores per cpu

Reference: http://www.aixchina.net/Question/13399

= = supplementary = =

CPUs, Cores, Sockets in AWR

Http://blog.itpub.net/35489/viewspace-742337/

NUM_CPUS 8 represents the number of logical CPU (the initial parameter cpu_count shown in the Oracle database)

NUM_CPU_CORES 8 corresponds to the number of CPU Cores

Number of NUM_CPU_SOCKETS 2 CPU Sockets

-stat_name = NUM_CPUS. This value should correspond to the number of logical CPUs. For systems with CMT or

Hyper-threaded processors, this value should correspond to the total number of hardware threads. For systems with

Multi-core processors, this value should correspond to the total number of hardware threads across all cores in the

System. NUM_CPUS should be greater than or equal to NUM_CPU_CORES and NUM_CPU_SOCKETS.

Number of corresponding logical CPU

For CPU multithreaded or hyperthreaded, the value should refer to the total number of hardware threads.

For multicore processors, the value should correspond to the total number of hardware threads for all cores in the system.

NUM_ CPU value is greater than or equal to NUM_CPU_CORES and NUM_CPU_SOCKETS

So, if the physical number of CPU is 2, then Sockets=2 (initially understood as slot)? Each CPU uses 4 cores and 4 threads per core, so the processor (CMT)

Can support 16 parallel execution of hard threads, corresponding to NUM_CPUS is equal to 2 * 4 * 4 = 32 (according to the second red statement)? NUM_CPU_CORES=2*4 = 8?

Thank you for your reading, the above is the content of "how to distinguish physical CPU, logical CPU and CPU kernels under Linux". After the study of this article, I believe you have a deeper understanding of how to distinguish physical CPU, logical CPU and CPU kernels under Linux. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Logic physics threads number core number information content core processing learning support same processor that is total situation technology data specification Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL macOS Docker Shulou Technology Shulou Information