About CPU: The logical and physical cores

This post will demonstrate a detailed method of enumerating processors in a running linux server. Before delving into the topic, some terms should be defined:

  • Physical Package: The physical package is a microprocessor. For each physical package, it plugs into a physical socket on a mainboard, and may contain one or more processor cores.
  • Processor Core: The circuitry that provides ability to decode and execute instructions. A processor core may contain one or more logical processors.
  • Logical Processor: The basic unit of processor hardware that allows the software executive in the operating system to dispatch a task or execute a thread context. Each logical processor can execute only one thread context at a time.
  • Hyper-Threading: A feature within the IA-32 family of processors, where each processor core provides the functionality of more than one logical processor.
  • Multi-Core Processor: A physical package that contains more than one processor core.

(The above definitions come from Intel’s website, it would be decent to identify what we’re talking.)

As we know, on a running Linux/UNIX system, a detailed information of CPU can be retrieved from /proc/cpuinfo, but how can we identify the logical processors and the physical cores smartly?  Basically, there are two rules that will help you achieve these info.

1. Any CPU with the same “core id” are hyperthreads in the same processor core, which means this process core has Hyper-Threading enabled.
2. The “physical id” identifies physical package. Any cpu with the same physical id are threads or cores in the same physical socket.

Let me take Dell PowerEdge 2950 as an example, we’re running Red Hat Enterprise Linux AS release 4 Update 7 on this server.

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5405  @ 2.00GHz
stepping        : 10
cpu MHz         : 1995.005
cache size      : 6144 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl tm2 cx16 xtpr lahf_lm
bogomips        : 3992.87
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:                                                                   

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5405  @ 2.00GHz
stepping        : 10
cpu MHz         : 1995.005
cache size      : 6144 KB
physical id     : 1
siblings        : 4
core id         : 4
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl tm2 cx16 xtpr lahf_lm
bogomips        : 3990.03
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:                                                                   

processor       : 2
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5405  @ 2.00GHz
stepping        : 10
cpu MHz         : 1995.005
cache size      : 6144 KB
physical id     : 0
siblings        : 4
core id         : 2
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl tm2 cx16 xtpr lahf_lm
bogomips        : 3990.01
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:                                                                   

processor       : 3
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5405  @ 2.00GHz
stepping        : 10
cpu MHz         : 1995.005
cache size      : 6144 KB
physical id     : 1
siblings        : 4
core id         : 6
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl tm2 cx16 xtpr lahf_lm
bogomips        : 3990.03
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:                                                                   

processor       : 4
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5405  @ 2.00GHz
stepping        : 10
cpu MHz         : 1995.005
cache size      : 6144 KB
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl tm2 cx16 xtpr lahf_lm
bogomips        : 3989.99
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:                                                                   

processor       : 5
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5405  @ 2.00GHz
stepping        : 10
cpu MHz         : 1995.005
cache size      : 6144 KB
physical id     : 1
siblings        : 4
core id         : 5
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl tm2 cx16 xtpr lahf_lm
bogomips        : 3990.02
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:                                                                   

processor       : 6
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5405  @ 2.00GHz
stepping        : 10
cpu MHz         : 1995.005
cache size      : 6144 KB
physical id     : 0
siblings        : 4
core id         : 3
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl tm2 cx16 xtpr lahf_lm
bogomips        : 3990.01
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:                                                                   

processor       : 7
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Xeon(R) CPU           E5405  @ 2.00GHz
stepping        : 10
cpu MHz         : 1995.005
cache size      : 6144 KB
physical id     : 1
siblings        : 4
core id         : 7
cpu cores       : 4
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm pni monitor ds_cpl tm2 cx16 xtpr lahf_lm
bogomips        : 3990.03
clflush size    : 64
cache_alignment : 64
address sizes   : 38 bits physical, 48 bits virtual
power management:

From the outputs, we can see that, there’re 8 processor-cores in 2 physical packages (in other words, there’re two quad-cores CPU on this server), and none of them has Hyper-Threading enabled. Here’s a quick explanation for some keywords that listed above:

  • The processor entry contains a unique identifier for this logical processor.
  • The physical id entry contains a unique identifier for each physical package.
  • The core id entry holds a unique identifier for each core.
  • The siblings entry lists the number of logical processors that exist on the same physical package.
  • The cpu cores entry contains the number of cores that exist on the same physical package.
  • The vendor id entry holds the string. GenuineIntel if the processor is an Intel processor, and AuthenticAMD if it’s an AMD processor.

There are some commands here to help identify these type of information quickly on a running Linux:

  1. Total amount of processors including the logical ones:
    # cat /proc/cpuinfo | grep "processor"| wc -l
  2. Total amount of CPU package:
    # cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
  3. How many cores for each CPU. (Here we should call CPU as physical package as we mentioned above):
    # cat /proc/cpuinfo | grep "cpu cores" | wc -l
  4. For each physical CPU, the amount of Logical CPU (the logical CPU can be physical cores, soft cores like threaded, or both).
    # cat /proc/cpuinfo | grep "siblings"

Finally, please note that the msg from /proc/cpuinfo depends on your operating systems, which means it’s not always right or up-to-date. If you faced any issues, please create a thread at our support forum, thanks!


Joseph chen is a system administrator from south China. He has a keen interest in Open Source and system administration solutions.

3 Responses to “About CPU: The logical and physical cores”

  1. [...] I'd say it should be possible. It would be better to disable other cores and leave only 8 cores. I ever did similar things on Dell r410/r710 servers, turned off some unwanted cores with the help of OMSA, but not sure whether it's supported by Sun 4450. As Sun Fire X4450 has 4 CPUs, you probably need to make sure whether they are hyper-threaded or just physical core. [...]

  2. Abe Zaidel says:

    Great post. I was checking continuously this blog and I am impressed! Very useful info particularly the final part :) I care for such information a lot. I used to be seeking this particular information for a very long. Thank you and good luck. – Elegant London Escorts, 65-67 Brewer Street, Floor: 2, London W1F 9UP. Phone: 020 3011 2941

  3. Rajdeep says:

    Thanks for publishing this, but this works only in physical machine. In a VMware environment, if you see /proc/cpuinfo file doesnot show cores, siblings or physical id.

    So what is they way to find the details from a vmware host?

Leave a Reply

© 2006-2010 Admon Linux. All rights reserved.
Powered by Linode Japan