Linux/Dual Core vs Dual Proc

From Omnia
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

cores.sh

cores.sh:

#!/bin/sh
# Programmed by Kenneth Burgener 2010

LOGICAL=$( grep "processor" /proc/cpuinfo | wc -l )
PHYSICAL=$( grep "physical id" /proc/cpuinfo | sort | uniq | wc -l )
SIBLINGS=$( grep "siblings" /proc/cpuinfo | head -n 1 | awk '{ print $3 }' )
CORES=$( grep "cpu cores" /proc/cpuinfo | head -n 1 | awk '{ print $4 }' )
LM=$( grep "lm" /proc/cpuinfo >/dev/null ; echo $? )
PHYSICAL_ALT=$(( $PHYSICAL / $SIBLINGS ))
MCORE=no
HT=no
X64=no

if [ $PHYSICAL -eq 0 ] ; then
  PHYSICAL=$LOGICAL
  SIBLINGS=1
  CORES=1
fi
if [ $SIBLINGS -eq $CORES -a $CORES -ge 2 ] ; then
  MCORE=yes
  HT=no
fi
if [ $SIBLINGS -ge 2 -a $CORES -eq 1 ] ; then
  MCORE=no
  HT=yes
fi
if [ $SIBLINGS -gt $CORES -a $CORES -gt 1 ] ; then
  MCORE=yes
  HT=yes
fi
if [ $LM -eq 0 ] ; then
  X64=yes
fi



echo "Logical CPUs:     $LOGICAL"
echo "Physical CPUs:    $PHYSICAL (or $PHYSICAL_ALT)"
echo "Package Siblings: $SIBLINGS (HT+Cores)"
echo "Package Cores:    $CORES"
echo "Multi-core:       $MCORE"
echo "Hyper-threading:  $HT"
echo "64bit capable:    $X64"
echo
echo "Summary:          $PHYSICAL proc + $CORES core + $HT ht = $LOGICAL threads"


cpuinfo_cores.sh:

grep -e "\(model name\|processor\|physical id\|siblings\|core id\|cpu cores\)" /proc/cpuinfo

Dual Core vs Dual Proc

"As you can see, the move to dual-core is definitely a win for consumers. Since they are more affordable than dual processor systems, but offer the same or better performance, they are becoming the standard for modern computer systems." [1]


(Howto: Linux detect or find out a dual-core cpu)


"The 'ht' in 'flags' field of /proc/cpuinfo indicate that the processor supports the Machine Specific Registers to report back HT or multi-core capability. Additional fields (listed down below) in the CPU records of /proc/cpuinfo will give more precise information about the CPU topology as seen by the operating system." [2]

/proc/cpuinfo

"physical id"	Physical package id of the logical CPU
"siblings"	Total number of logical processors(includes both threads and cores) in the
		physical package currently in use by the OS
"cpu cores"	Total number of cores in the physical package currently in use by the OS
"core id"	Core id of the logical CPU

"To identify if the physical package is purely multi-threaded or purely multi-core capable or both, then in addition to the "ht" flag, applications need to parse all the above mentioned fields. Following logic can be used to identify the CPU capabilities as seen by the OS." [3]

/proc/cpuinfo

"siblings == cpu cores >= 2"
  - Indicates that the physical package is multi-core capable and is not Hyper-threading capable
"siblings >= 2" && "cpu cores == 1"
  - Indicates that the physical package is Hyper-threading capable and has one cpu core
"siblings > cpu cores > 1"
 - Indicates that the physical package is both Hyper-threading and multi-core capable


"More recent Linux Kernels [LK] (like 2.6.17) have the CPU topology exported in sysfs as well. This mechanism is simpler and faster compared to the previously mentioned /proc interface. Below listed fields exported under /sys/devices/system/cpu/cpuX/topology/ provide the complete topology information." [4]

/sys/devices/system/cpu/cpuX/topology/

physical_package_id	Physical package id of the logical CPU
core_id		Core id of the logical CPU
core_siblings		Siblings mask of all the logical CPUs in a physical package
thread_siblings	Siblings mask of all the logical CPUs in a CPU core

Hamming Weight (number of bits set) of siblings mask will give the physical package capabilities.

“HW(core_siblings) == HW(thread_siblings) >= 2”
 - Indicates that the physical package is Hyper-threading capable and has one cpu core
“HW(core_siblings) >= 2” && “HW(thread_siblings) == 1”
 - Indicates that the physical package is multi-core capable and is not Hyper-threading capable
“HW(core_siblings) > HW(thread_siblings) > 1”
 - indicates that the physical package is both Hyper-threading and multi-core capable


"Hyperthreading (HT) is only a feature of Intel CPUs. Current Intel x86 processors based on the Core microarchitecture (Core2Duo, Core2Quad, etc.) do not have hyperthreading, but there are some earlier Pentium 4-based Pentium and Xeon processors that are both dual-core and hyperthreaded. To determine whether a system is multi-processor, multi-core, hyperthreaded or a combination of the three, look at the "physical id", "siblings" and "cpu cores" values in /proc/cpuinfo while running a non-Xen kernel.* If "siblings" and "cpu cores" match, the system does not have hyperthreading or hyperthreading is turned off in the BIOS. If they differ, the system has hyperthreading. The "cpu cores" value also shows the number of cores per processor. The "physical id" value is different for each processor socket, so the number of unique "physical id" values equals the number of processor sockets in use on the system. It is worth noting that the presence of the "ht" flag in the "cpuflags" section of /proc/cpuinfo does not necessarily indicate that a system has hyperthreading capabilities. That flag indicates that the processor is capable of reporting the number of siblings it has, not that it has hyperthreading." [5]


If you look at /proc/cpuinfo there are two fields of relevance: "siblings" and "cpu cores". [6]

"siblings" = (ht per cpu package) * (# of cores per cpu package)
"cpu cores" = (# of cores per cpu package)
Thus:
ht per cpu package = "siblings" / "cpu cores"

So when I see 4 entries in /proc/cpuinfo, all with "siblings : 2" and "cpu cores : 1", that means I have two single-core hyperthreading CPUs? - yes


/proc/cpuinfo source code is here: linux-mc/arch/i386/kernel/cpu/proc.c [7]

seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]);
seq_printf(m, "siblings\t: %d\n",
		c->x86_num_cores * smp_num_siblings);
seq_printf(m, "core id\t\t: %d\n", cpu_core_id[n]);
seq_printf(m, "cpu cores\t: %d\n", c->x86_num_cores);

Understanding /proc/cpuinfo

How many physical processors are there?

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

How many virtual processors are there?

grep ^processor /proc/cpuinfo | wc -l

Are the processors dual-core (or multi-core)?

grep 'cpu cores' /proc/cpuinfo

cpu cores       : 2
cpu cores       : 2
cpu cores       : 2
cpu cores       : 2

  • "2" indicates the two physical processors are dual-core, resulting in 4 virtual processors.
  • If "1" was returned, the two physical processors are single-core. If the processors are single-core, and the number of virtual processors is greater than the number of physical processors, the CPUs are using hyper-threading. Hyper-threading is supported if ht is present in the CPU flags and you are using an SMP kernel.

Are the processors 64-bit? A 64-bit processor will have lm ("long mode") in the flags section of cpuinfo. A 32-bit processor will not.

grep 'lm' /proc/cpuinfo

What do the CPU flags mean?

  • The CPU flags are briefly described in the kernel header file cpufeature.h.

Source: Understanding /proc/cpuinfo

References

Examples

AMD Athlong 64 X2 Dual Core Processor 5000+

Source: Our kids new Compaq computer system

model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+

processor       : 1
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2

processor       : 1
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2

flags: ht lm

Dual P4 with HT (maybe)

Source

NOTE: I think this is really a single proc with HT.

processor       : 0
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1

processor       : 1
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1

flags: ht

Dual Core AMD X2

Single proc, Dual Core, no HT

Source

model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+

processor       : 0
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2

processor       : 1
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2

flags: ht lm

Dual Proc Dual Core Xeons (maybe)

Source

NOTE: I think this is really a Dual Proc Single Core with HT

model name : Intel(R) Xeon(TM) MP CPU 3.66GHz
cpu MHz : 3670.025

processor   : 0
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1

processor   : 1
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 1

processor   : 2
physical id : 3
siblings    : 2
core id     : 3
cpu cores   : 1

processor   : 3
physical id : 3
siblings    : 2
core id     : 3
cpu cores   : 1

flags: ht lm

Intel Core2 Duo

Single proc, dual core, no HT

Source

Dell inspiron 1420
model name    : Intel(R) Core(TM)2 Duo CPU     T7250  @ 2.00GHz
cpu MHz        : 800.000

processor    : 0
physical id  : 0
siblings     : 2
core id      : 0
cpu cores    : 2

processor    : 1
physical id  : 0
siblings     : 2
core id      : 1
cpu cores    : 2

flags: ht lm

Dual Proc Xeon with HT

Dual proc, single cores, with HT

Source

model name : Intel(R) Xeon(TM) CPU 2.40GHz
cpu MHz : 2400.627

processor : 0
physical id : 0
siblings : 2

processor : 1
physical id : 0
siblings : 2

processor : 2
physical id : 3
siblings : 2

processor : 3
physical id : 3
siblings : 2

flags : ht


# Number of logical processors: 4
grep ^processor /proc/cpuinfo | wc -l

# Number of physical processors: 2
grep 'physical id' /proc/cpuinfo | sort | uniq | wc -l

# Number of cores: 0
grep 'cpu cores' /proc/cpuinfo

# Is hyperthreading? yes (2 siblings > 0 cores)
grep 'siblings' /proc/cpuinfo

Dual Proc Single Core Hyper threading Xeon

Dual proc, single cores, with HT

AppLabs - iov-admin1 - 1U Server

Verified 2 processors.

model name      : Intel(R) Xeon(TM) CPU 2.66GHz
cpu MHz         : 2666.009

processor       : 0
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1

processor       : 1
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 1

processor       : 2
physical id     : 3
siblings        : 2
core id         : 0
cpu cores       : 1

processor       : 3
physical id     : 3
siblings        : 2
core id         : 0
cpu cores       : 1

flags           : ht


# Number of logical processors: 4
grep ^processor /proc/cpuinfo | wc -l

# Number of physical processors: 2
grep 'physical id' /proc/cpuinfo | sort | uniq | wc -l

# Number of cores: 1
grep 'cpu cores' /proc/cpuinfo

# Is hyperthreading? yes (2 sib > 1 cores)
grep 'siblings' /proc/cpuinfo

Dual Proc Quad Core Xeon

Dual proc, quad core, no HT

AppLabs - Hitachi BS 1000 - Hypertown Blade (used in Trend Micro testing)

vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Xeon(R) CPU           X5355  @ 2.66GHz
stepping        : 7
cpu MHz         : 2666.806
cache size      : 4096 KB

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 constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
flags           : ht
bogomips        : 5332.34

processor       : 0
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4

processor       : 1
physical id     : 1
siblings        : 4
core id         : 0
cpu cores       : 4

processor       : 2
physical id     : 0
siblings        : 4
core id         : 1
cpu cores       : 4

processor       : 3
physical id     : 1
siblings        : 4
core id         : 1
cpu cores       : 4

processor       : 4
physical id     : 0
siblings        : 4
core id         : 2
cpu cores       : 4

processor       : 5
physical id     : 1
siblings        : 4
core id         : 2
cpu cores       : 4

processor       : 6
physical id     : 0
siblings        : 4
core id         : 3
cpu cores       : 4

processor       : 7
physical id     : 1
siblings        : 4
core id         : 3
cpu cores       : 4

# Number of logical processors: 8
grep ^processor /proc/cpuinfo | wc -l

# Number of physical processors: 2
grep 'physical id' /proc/cpuinfo | sort | uniq | wc -l

# Number of cores: 4
grep 'cpu cores' /proc/cpuinfo | uniq

# Is hyperthreading? no (4 sib = 4 cores)
grep 'siblings' /proc/cpuinfo | uniq

Dell PowerEdge R910 - Quad Proc Eight Core

Dell PowerEdge R910

Logical CPUs:     64
Physical CPUs:    4
Package Siblings: 16 (HT+Cores)
Package Cores:    8
Multi-core:       yes
Hyper-threading:  yes
64bit capable:    yes

Summary:          4 proc + 8 core + yes ht = 64 threads
model name      : Intel(R) Xeon(R) CPU           X7560  @ 2.27GHz
bogomips        : 4521.98
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 46
model name      : Intel(R) Xeon(R) CPU           X7560  @ 2.27GHz
stepping        : 6
cpu MHz         : 2261.060
cache size      : 24576 KB
physical id     : 0
siblings        : 16
core id         : 0
cpu cores       : 8
apicid          : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
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 rdtscp lm constant_tsc ida nonstop_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm
bogomips        : 4522.12
clflush size    : 64
cache_alignment : 64
address sizes   : 44 bits physical, 48 bits virtual
power management: [8]

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 46
model name      : Intel(R) Xeon(R) CPU           X7560  @ 2.27GHz
stepping        : 6
cpu MHz         : 2261.060
cache size      : 24576 KB
physical id     : 1
siblings        : 16
core id         : 0
cpu cores       : 8
apicid          : 32
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
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 rdtscp lm constant_tsc ida nonstop_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm
bogomips        : 4522.03
clflush size    : 64
cache_alignment : 64
address sizes   : 44 bits physical, 48 bits virtual
power management: [8]

...

processor       : 47
vendor_id       : GenuineIntel
cpu family      : 6
model           : 46
model name      : Intel(R) Xeon(R) CPU           X7560  @ 2.27GHz
stepping        : 6
cpu MHz         : 2261.060
cache size      : 24576 KB
physical id     : 3
siblings        : 16
core id         : 3
cpu cores       : 8
apicid          : 103
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
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 rdtscp lm constant_tsc ida nonstop_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm
bogomips        : 4522.06
clflush size    : 64
cache_alignment : 64
address sizes   : 44 bits physical, 48 bits virtual
power management: [8]

...

processor       : 63
vendor_id       : GenuineIntel
cpu family      : 6
model           : 46
model name      : Intel(R) Xeon(R) CPU           X7560  @ 2.27GHz
stepping        : 6
cpu MHz         : 2261.060
cache size      : 24576 KB
physical id     : 3
siblings        : 16
core id         : 11
cpu cores       : 8
apicid          : 119
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
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 rdtscp lm constant_tsc ida nonstop_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 popcnt lahf_lm
bogomips        : 4521.98
clflush size    : 64
cache_alignment : 64
address sizes   : 44 bits physical, 48 bits virtual
power management: [8]

Hitachi BS2000

Intel Xeon E5540 Nehalem 2.53GHz 4 x 256KB L2 Cache 8MB L3 Cache LGA 1366 80W Quad-Core Server Processor [8]


Intel® Xeon® Processor E5540 (8M Cache, 2.53 GHz, 5.86 GT/s Intel® QPI) [9]

System Information
        Manufacturer: HITACHI
        Product Name: BladeSymphony E55
        Version: 0020G55100
        Serial Number: 4600C80 T943000149
        UUID: 53EED748-3000-AF87-DD11-31FF00000000
        Wake-up Type: Power Switch
        SKU Number: None
        Family: None

Base Board Information
        Manufacturer: SUPERMICRO
        Product Name: X8DTE-HTC01a
        Version: 555G301041GD1M0
        Serial Number: 93300030
        Asset Tag: None
        Features:
                Board is a hosting board
                Board is replaceable
        Location In Chassis: None
        Chassis Handle: 0x0003
        Type: Motherboard
        Contained Object Handles: 0


vendor_id       : GenuineIntel
cpu family      : 6
model           : 26
model name      : Intel(R) Xeon(R) CPU           E5540  @ 2.53GHz
stepping        : 5
cpu MHz         : 1596.000
cache size      : 8192 KB

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 rdtscp lm constant_tsc ida pni monitor ds_cpl vmx est tm2 cx16 xtpr popcnt lahf_lm
bogomips        : 5066.78


processor       : 0
physical id     : 0
siblings        : 8
core id         : 0
cpu cores       : 4

processor       : 1
physical id     : 0
siblings        : 8
core id         : 1
cpu cores       : 4

processor       : 2
physical id     : 0
siblings        : 8
core id         : 2
cpu cores       : 4

processor       : 3
physical id     : 0
siblings        : 8
core id         : 3
cpu cores       : 4

processor       : 4
physical id     : 1
siblings        : 8
core id         : 0
cpu cores       : 4

processor       : 5
physical id     : 1
siblings        : 8
core id         : 1
cpu cores       : 4

processor       : 6
physical id     : 1
siblings        : 8
core id         : 2
cpu cores       : 4

processor       : 7
physical id     : 1
siblings        : 8
core id         : 3
cpu cores       : 4

processor       : 8
physical id     : 0
siblings        : 8
core id         : 0
cpu cores       : 4

processor       : 9
physical id     : 0
siblings        : 8
core id         : 1
cpu cores       : 4

processor       : 10
physical id     : 0
siblings        : 8
core id         : 2
cpu cores       : 4

processor       : 11
physical id     : 0
siblings        : 8
core id         : 3
cpu cores       : 4

processor       : 12
physical id     : 1
siblings        : 8
core id         : 0
cpu cores       : 4

processor       : 13
physical id     : 1
siblings        : 8
core id         : 1
cpu cores       : 4

processor       : 14
physical id     : 1
siblings        : 8
core id         : 2
cpu cores       : 4

processor       : 15
physical id     : 1
siblings        : 8
core id         : 3
cpu cores       : 4



# Number of logical processors: 16
grep ^processor /proc/cpuinfo | wc -l

# Number of physical processors: 2
grep 'physical id' /proc/cpuinfo | sort | uniq | wc -l

# Number of cores: 4
grep 'cpu cores' /proc/cpuinfo | uniq

# Is hyperthreading? yes (8 sib > 4 cores)
grep 'siblings' /proc/cpuinfo | uniq