[olug] Determining cores and sockets on Linux...

Carl Lundstedt clundst at unlserve.unl.edu
Thu Nov 20 23:00:45 UTC 2008


I think you're on the right track here.  Can't you get number of sockets
from number of 'cpu cores' lines divided by the value, and the number of
cores total by counting the number of core id lines.  Perhaps comparing?

>From a dual socket quad core AMD:
physical id     : 1
siblings        : 4
core id         : 3
cpu cores       : 4
So I have 2 cpus, 4 cores each.

-bash-3.00$ cat /proc/cpuinfo | grep "core id"
core id         : 0
core id         : 1
core id         : 2
core id         : 3
core id         : 0
core id         : 1
core id         : 2
core id         : 3
-bash-3.00$ cat /proc/cpuinfo | grep "cpu cores"
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4

8 lines /4 = 2 procs

Maybe this only works for AMD chips?  Grep against vendor_id?

The only intel I have access to is my desktop, a single quad  core Q9300
core id         : 0
core id         : 2
core id         : 3
core id         : 1
clundst at unlcms1:~> cat /proc/cpuinfo | grep "cpu cores"
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4
cpu cores       : 4

no funny business there...script away?

Carl Lundstedt
UNL
On Thu, 2008-11-20 at 16:52 -0600, Obi-Wan wrote:
> > Those two core lines should do the trick, I would think.  Here's my
> > dual-core Athlon64x2:
> > 
> > # grep core /proc/cpuinfo
> > core id         : 0
> > cpu cores       : 2
> > core id         : 1
> > cpu cores       : 2
> 
> And in case I was two quick on the trigger and it wasn't obvious,
> just count the number of "core id" lines to get the number of
> course, and count the number of "core id : 0" lines to get the
> number of sockets.
> 
> ... then again, here's a Core 2 Duo E8400 at work:
> 
> $ grep core /proc/cpuinfo
> core id         : 255
> cpu cores       : 1
> core id         : 255
> cpu cores       : 1
> 
> Never mind.
> 




More information about the OLUG mailing list