Why does top show a different number of cores than cpuinfo?

The X5560 is a single chip. It looks like this:

enter image description here

grep "physical id" is telling you that you have ONE physical processor installed.

If you take the heat spreader off of the top you can see this - a single physical die (face down) :

enter image description here

If you could remove that die and flip it over, it would look like this :

enter image description here

On that single physical die there are four physical CPU cores built onto the silicon :

enter image description here

grep "cpu cores" is telling you that your processor has four physical cores built onto it.

Each core is a single processor with a floating point unit, a number of integer execution units, a pair of register stacks, and some other wizardry that allows each single core to effectively execute two independent instruction streams (threads) at a time.

enter image description here

top is telling you that all the processors and cores on your computer, collectively, can execute eight independent workflows at a time - it's telling you that the operating system is able to schedule eight simultaneous threads for execution at any given time.


What CPU are you using? How many thread present per physical core?

cat /proc/cpuinfo shows number of physical core whereas top shows total no of threads present.

I think your CPU has 4 physical core and 2 logical core per physical core. So it's top showing 8.

Moreover contents of /proc/cpuinfo is somewhat implementation dependent. Like in rooted android shell the cpuinfo file doesn't contain any term cpu cores.

However in cpuinfo each thread is named as processor : X, Where X is thread no. So the last thread no shall be same as top/htop output.

Result of nproc --all shall also be consistent with top/htop


top shows one “CPU” per logical CPU; on x86, that’s the product of the number of sockets in the system, by the number of physical cores per socket, by the number of threads per core.

The cpu cores entry in /proc/cpuinfo, again on x86, shows the number of physical cores. To find the number of logical cores, as used in top, you should look at the siblings value instead:

cat /proc/cpuinfo | grep "siblings" | uniq

This is described in detail in the kernel documentation.

lscpu provides information on the installed CPU(s) which is easier to understand than /proc/cpuinfo (or rather, it presents the same information in a simpler fashion).

Tags:

Linux

Cpu