How-to determine the number of physical CPUs under both Windows and Linux

5

2

When running cat /proc/cpuinfo under Linux, a variety information is kicked-back. For example:

> cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 15
model name  : Intel(R) Xeon(R) CPU            5130  @ 2.00GHz
stepping    : 6
cpu MHz     : 1995.069
cache size  : 4096 KB
physical id : 0
siblings    : 2
core id     : 0
cpu cores   : 2
fpu     : yes
fpu_exception   : yes
cpuid level : 10
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 constant_tsc pni monitor ds_cpl vmx tm2 cx16 xtpr lahf_lm
bogomips    : 3991.76
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 15
model name  : Intel(R) Xeon(R) CPU            5130  @ 2.00GHz
stepping    : 6
cpu MHz     : 1995.069
cache size  : 4096 KB
physical id : 3
siblings    : 2
core id     : 0
cpu cores   : 2
fpu     : yes
fpu_exception   : yes
cpuid level : 10
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 constant_tsc pni monitor ds_cpl vmx tm2 cx16 xtpr lahf_lm
bogomips    : 3989.46
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

First, what does all of that actually mean? I see I have a processor 0 and processor 1. Does that mean Linux is reporting both cores of the CPU, or, since it is a VM, the two that I happen to have right now (even if they're on physically different CPUs)?

Second, how can I get a similar information dump form the command line in Windows?

Third, is there a way using either platform to determine the number of physical CPUs versus total CPU cores?

warren

Posted 2010-09-09T18:22:24.663

Reputation: 8 599

Answers

7

To answer your first question: http://www.richweb.com/cpu_info describes all the cpuinfo output in good detail with some interesting discussion following the article.

In your case it's reporting that your VM is configured to show itself to the OS as a two-physical-core VM. The bare metal under the VM might be 1 core or 100 cores but as far as the OS in the VM is concerned you've got a machine with two physical processors that it can play with. It knows nothing of how threads that it assigns to those processors are actually being run on the physical hardware underneath the VM.

To get somewhat similar information from a Windows CMD shell you can try the systeminfo command from a CMD shell. It displays a whole lot more than the /proc/cpuinfo stuff in Linux, but also not quite as much detail about the actual processors themselves.

I don't know the answer to your third question, sorry.

Ian C.

Posted 2010-09-09T18:22:24.663

Reputation: 5 383

was not familiar with systeminfo .. very cool tool, though :) – warren – 2010-09-09T18:48:56.207

AmirW was able to find the info in cpuinfo that has the physical IDs (http://superuser.com/questions/186682/how-to-determine-the-number-of-physical-cpus-under-both-windows-and-linux/187123#187123)

– warren – 2010-09-10T19:20:42.840

7

Re third question:

in cpuinfo, there is a field "physical id", it's unique per physical CPU. Cores of the same CPU are reported as different processors with the same physical id, while physically separate processors will have different physical ids.

Notice that if you're on a VM, you cannot know anything about the actual hardware (CPU, etc), all you know is what the VM tells you. So, for example, if your physical machine has 1 Quad core CPU, and your VM is configured to report 2 single core CPUs, you'll see 2 single core CPUs in cpuinfo (i.e. 2 processors with different physical id).

AmirW

Posted 2010-09-09T18:22:24.663

Reputation: 183

2thanks, AmirW - the exact command I'm using that returns that to me is: cat /proc/cpuinfo | grep physical | grep id | sort -u | wc -l – warren – 2010-09-10T19:20:08.943

1

One liner:

dmidecode | grep CPU | grep -i 'socket designation' | wc -l

This command parses the extensive information provided by dmidecode to determine the number of physical processors based on the unique 'socket designation' value assigned to each physical cpu. You can use it to get a number of physical cpus on a given host. Trying to cat /proc/cpuinfo doesn't always work out. On a PowerEdge R420 with 2x6C 2.4GHz server the cpuinfo erroneously reported one processor.

Gregory Patmore

Posted 2010-09-09T18:22:24.663

Reputation: 121

It parses the extensive information provided by dmidecode to determine the number of physical processors based on the unique 'socket designation' value assigned to each physical cpu. You can use it to get a number of physical cpus on a given host. trying to cat /proc/cpuinfo doesn't always work out. On a PowerEdge R420 with 2x6C 2.4GHz server the cpuinfo erroneously reported one processor. – Gregory Patmore – 2014-05-09T21:00:40.343