Linux – Why does top show a different number of cores than cpuinfo

cpulinux

When I run top, I show CPU 0-7. When i do:

cat /proc/cpuinfo | grep "cpu cores" | uniq

I get:

cpu cores : 4

If I grep "physical id" I have 1.

I am thinking my command is wrong and top is right. This is not a VM and it a physical server, RedHat. What am I doing wrong?

I am not sure these answer it:

How to know number of cores of a system in Linux?

Number of processors in /proc/cpuinfo

Edit: Am I correct that Physical ID, if it only shows 1, then I have one physical chip in the motherboard?

Edit: It is a Intel(R) Xeon(R) CPU X5560 @ 2.80GHz but the physical id is 1, and I thought it would be 0, but there is no physical id 0 in cpuinfo.

Edit: If it matters, I am trying to figure out licensing where they do .5 the core count.

Best Answer

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

Related Question