How-to determine the number of physical CPUs under both Windows and Linux
Solution 1
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.
Solution 2
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).
Solution 3
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.
Related videos on Youtube
David Yates
I'm a hobbyist programmer, part-time sysadmin, and full-time analytics, big data, data center management, automation, and cloud computing architect and delivery engineer.
Updated on September 17, 2022Comments
-
David Yates over 1 year
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?
-
David Yates over 13 yearswas not familiar with
systeminfo
.. very cool tool, though :) -
David Yates over 13 yearsthanks, AmirW - the exact command I'm using that returns that to me is:
cat /proc/cpuinfo | grep physical | grep id | sort -u | wc -l
-
David Yates over 13 yearsAmirW was able to find the info in
cpuinfo
that has the physical IDs (superuser.com/questions/186682/…) -
Gregory Patmore almost 10 yearsIt 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.