Linux distinguishes between physical CPUs, logical CPUs, and CPU cores

Source: Internet
Author: User

Basis of judgment:

A physically encapsulated CPU (judged by physical ID) can have multiple cores (differentiated by Core ID).

Each core can have multiple logical CPUs (judged by processor).

One core implements this core's own hyper-Threading technology through multiple logical CPUs.

The CPU cores entry contains the number of cores in the same physical package.

The siblings entry lists the number of logical processors in the same physical package.

The proc file is indexed with processor because processor is the smallest unit that has all the information listed below. Easy to see fine-grained information.

For example, if the core ID is indexed, its information processor is a series of values, because a core can correspond to multiple logical CPUs!!

1. CPUs with the same core ID are Hyper-threading of the same core.
2. CPUs with the same physical ID are the same CPU-encapsulated thread or cores.

English version:
1.Physical ID and Core ID is not necessarily consecutive but they is unique. Any CPUs with the same core ID is hyperthreads in the same core.
2.Any CPU with the same physical ID is threads or cores in the same physical socket.

Instance:

Lunarpages CPU Information:

processor:0
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical id:0
Siblings:2
Core id:0
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE s SE2 SS HT TM PBE LM CONSTANT_TSC PNI monitor ds_cpl CID XTPR
bogomips:6006.73

Processor:1
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical id:0
Siblings:2
Core id:0
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE s SE2 SS HT TM PBE LM CONSTANT_TSC PNI monitor ds_cpl CID XTPR
bogomips:5999.40

Processor:2
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical Id:3
Siblings:2
Core Id:3
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE s SE2 SS HT TM PBE LM CONSTANT_TSC PNI monitor ds_cpl CID XTPR
bogomips:5999.08

Processor:3
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical Id:3
Siblings:2
Core Id:3
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE s SE2 SS HT TM PBE LM CONSTANT_TSC PNI monitor ds_cpl CID XTPR
bogomips:5999.55

Displays 4 logical CPUs, with the same physical ID, two logical CPUs in front, and two later, so there are two physical CPUs. The first two cores have the same core ID, followed by the same two core IDs, indicating that the two CPUs are single-core. That is, two single-core CPUs with Hyper-Threading technology enabled.
The parameters of Intel's CPU can be initially judged using two Xeon Pentium 4CPU, a little worse ....
How to obtain detailed information about the CPU:

Linux command: Cat/proc/cpuinfo

Use the command to determine several physical CPUs, several cores, etc.:

Number of logical CPUs:
# Cat/proc/cpuinfo | grep "Processor" | Wc-l

Number of physical CPUs:
# Cat/proc/cpuinfo | grep "Physical ID" | Sort | Uniq | Wc-l

Number of cores per physical CPU:
# Cat/proc/cpuinfo | grep "CPU Cores" | Wc-l

Is it hyper-threading?
If there are two logical CPUs with the same "core ID", then Hyper-threading is turned on.

The number of logical CPUs (possibly cores, threads, or both) in each physical CPU:
# Cat/proc/cpuinfo | grep "Siblings"
Other Features:

At present, Intel's new multi-core CPU will display the specific model numbers later, for example:

Model Name:intel (R) Xeon (r) CPU X3230 @ 2.66GHz

Description is the Xeon 3230 CPU, not the exact number of the model, most of it is the Pentium CPU

Many hosts cheat, with the Pentium CPU, but that is the multi-core CPU.

The data that the probe sees:

Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024x768
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024x768
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024x768
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024x768

No specific model, cache 1M, is generally the Pentium series of CPUs, or Intel fake dual-core CPU, specifically according to the above to judge. The new multi-core CPU can see the specific model.
Another multi-core Xeon CPU, the general frequency is not high, reached 2.8 and 3.0 only a few high-end CPU models, the general host will not use such a good.

The latest version of some operating systems has updated the/proc/cpuinfo file to support multi-channel platforms. If the/proc/cpuinfo file in your system correctly reflects the processor information, you do not need to perform the above steps. Conversely, the information in this article can be used for interpretation.

The/proc/cpuinfo file contains a paragraph of data for each processor on the system. There are 6 entries in the/proc/cpuinfo description for multi-core and Hyper-Threading (HT) Technical checks: processor, vendor ID, physical ID, siblings, core ID, and CPU cores.

The processor entry includes a unique identifier for this logical processor.
The physical ID entry includes a unique identifier for each physical package.
The core ID entry holds a unique identifier for each kernel.
The siblings entry lists the number of logical processors in the same physical package.
The CPU cores entry contains the number of cores in the same physical package.

If the processor is an Intel processor, the string in the vendor ID entry is Genuineintel.

1. All logical processors with the same physical ID share the same physical outlet. Each physical ID represents a unique physical package.

2.Siblings represents the number of logical processors located on this physical package. They may or may not support Hyper-Threading (HT) technology.

3. Each core ID represents a unique processor core. All logical processors with the same core ID are located on the same processor core.

4. If more than one logical processor has the same core ID and physical ID, the system supports Hyper-threading (HT) technology.

5. If two or more logical processors have the same physical ID, but the core ID is different, this is a multi-core processor. CPU cores entries can also indicate whether multiple cores are supported.

For example, if the system contains two physical packages, and each package contains two processor cores that support Hyper-Threading (HT) technology, the/proc/cpuinfo file will contain this data. (Note: The data is not in the table.) )

Processor

0

1

2

3

4

5

6

7

Physical ID

0

1

0

1

0

1

0

1

Core ID

0

2

1

3

0

2

1

3

Siblings

4

4

4

4

4

4

4

4

CPU Cores

2

2

2

2

2

2

2

2

1. This example shows that logical processors 0 and 4 reside on Kernel 0 in physical package 0. This means that logical processors 0 and 4 support Hyper-Threading (HT) technology.

2. The same work can be used to encapsulate the logical processors 2 and 6 on the 0 core 1, encapsulate the logical processors 1 and 2 on the 1 core 5, and encapsulate the logical processors 1 and 3 on the 3 core 7.

3. This system supports Hyper-threading (HT) technology because two logical processors share the same core.

4. There are two ways to determine if multiple cores are supported:

A. Since cores 0 and 1 exist on package 0, and cores 2 and 3 exist on package 1, this is a multi-core system.

B. In addition, the CPU cores entry is 2, which also indicates that there are two cores residing in a physical package. This is a multi-channel system because there are two packages.

It is important to note that the physical ID and core ID numbers may or may not be contiguous. There are two physical packages on the system that are not uncommon, and the physical ID equals 0 and 3

The following methods can be used to query CPU conditions:

1. Number of logical CPUs:

# Cat/proc/cpuinfo | grep "Processor" | Wc-l

2. Number of physical CPUs:
# Cat/proc/cpuinfo | grep "Physical ID" | Sort | Uniq | Wc-l

3. The number of cores per physical CPU:
# Cat/proc/cpuinfo | grep "CPU Cores" | Wc-l

Is it hyper-threading?
If there are two logical CPUs with the same "core ID", then Hyper-threading is turned on.

4. The number of logical CPUs (possibly cores, threads, or both) in each physical CPU:
# Cat/proc/cpuinfo | grep "Siblings"

Number of logical CPUs: Cat/proc/cpuinfo | grep "Processor" | Wc-l
Number of physical CPUs: Cat/proc/cpuinfo | grep "Physical ID" | Sort | Uniq | Wc-l

"Siblings" refers to a physical CPU that has several logical CPUs
"CPU cores" refers to a physical CPU with several cores

It should not be judged whether the system has hyper-threading capability according to the HT flag in the flags, but should:
If "siblings" and "CPU cores" are consistent, hyper-threading is not supported, or hyper-threading is not open.
If "siblings" is twice Times "CPU cores", then hyper-Threading is supported and Hyper-threading is turned on.

㈠ Concept

① Physical CPU


Number of CPUs on the actual server slots
Number of physical CPUs, number of physical IDs that can be repeated

② Logical CPU

Linux users are certainly not unfamiliar with the/proc/cpuinfo file. It is used to store CPU hardware information.
The information content lists the specifications of the processor 0–n, respectively. It's important to note that if you think n is the actual number of CPUs, it's a big mistake.
In general, we think that a CPU can have multicore, plus Intel's Hyper-Threading Technology (HT), can logically divide the number of CPU core out
Number of logical CPUs = number of physical CPUs x CPU cores This specification value x 2 (if HT is supported and turned on)
Note: Linux top view CPU is also the number of logical CPUs

③cpu number of cores

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

In general, the number of physical CPUs x per core should be equal to the number of logical CPUs, if not equal, it means that the server's CPU support Hyper-Threading Technology

㈡ viewing CPU information

When we are Cat/proc/cpuinfo,
CPUs with the same core ID are Hyper-threading of the same core
CPUs with the same physical ID are the same CPU-encapsulated thread or core


㈢ The following examples illustrate

① View the number of physical CPUs

[Plain]View Plaincopyprint?
    1. #cat/proc/cpuinfo |grep "Physical id" |sort |uniq|wc-l
    2. 2


② View the number of logical CPUs

[Plain]View Plaincopyprint?
    1. #cat/proc/cpuinfo |grep "Processor" |wc-l
    2. 24


③ View CPU is a few cores

[Plain]View Plaincopyprint?
    1. #cat/proc/cpuinfo |grep "Cores" |uniq
    2. 6


I should be 2 CPUs, each CPU has 6 cores, should be Intel's U, support Hyper-threading, so display 24

Linux distinguishes between physical CPUs, logical CPUs, and CPU cores

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.