How do I know which processors are physical cores?

You can know about each processor core by examining each cpuinfo entry:

processor       : 0
[...]
physical id     : 0
siblings        : 8
core id         : 0
cpu cores       : 4
apicid          : 0

processor       : 1
[...]
physical id     : 0
siblings        : 8
core id         : 1
cpu cores       : 4
apicid          : 2 

processor       : 2
[...]
physical id     : 0
siblings        : 8
core id         : 2
cpu cores       : 4
apicid          : 4 

processor       : 3
[...]
physical id     : 0
siblings        : 8
core id         : 3
cpu cores       : 4
apicid          : 6

processor       : 4
[...]
physical id     : 0
siblings        : 8
core id         : 0
cpu cores       : 4
apicid          : 1

[and so on]

physical id shows the identifier of the processor. Unless you have a multiprocessor setup (having two separate, physical processor in a machine), it will always be 0.

siblings show the number of processor attached to the same physical processor.

core id show the identifier of the current core, out to a total of cpu cores. You can use this information to correlate which virtual processor goes into a single core.

apicid (and original apicid) show the number of the (virtual) processor, as given by the bios.

Note that there 8 siblings and 4 cores, so there is 2 virtual processor per core. There is no distinction between "virtual" or "real" in hyperthreading. But using this information you can associate which processors are from the same core.


you can also use lscpu:

# lscpu --all --extended
CPU NODE SOCKET CORE L1d:L1i:L2:L3:L4 ONLINE MAXMHZ    MINMHZ
0   0    0      0    0:0:0:0:0        yes    3200.0000 800.0000
1   0    0      1    1:1:1:0:0        yes    3200.0000 800.0000
2   0    0      2    2:2:2:0:0        yes    3200.0000 800.0000
3   0    0      3    3:3:3:0:0        yes    3200.0000 800.0000
4   0    0      0    0:0:0:0:0        yes    3200.0000 800.0000
5   0    0      1    1:1:1:0:0        yes    3200.0000 800.0000
6   0    0      2    2:2:2:0:0        yes    3200.0000 800.0000
7   0    0      3    3:3:3:0:0        yes    3200.0000 800.0000

here logical cores 0 and 4 go to core 0


The /sys filesystem holds a nice overview of this information. Here is an example from an SMP quadcore box with Hyperthreading:

# grep . /sys/devices/system/cpu/cpu{,1}?/topology/thread_siblings | tr : \\t | sed 's,^,    ,'
/sys/devices/system/cpu/cpu0/topology/thread_siblings   00000000,00000101
/sys/devices/system/cpu/cpu1/topology/thread_siblings   00000000,00000202
/sys/devices/system/cpu/cpu2/topology/thread_siblings   00000000,00000404
/sys/devices/system/cpu/cpu3/topology/thread_siblings   00000000,00000808
/sys/devices/system/cpu/cpu4/topology/thread_siblings   00000000,00001010
/sys/devices/system/cpu/cpu5/topology/thread_siblings   00000000,00002020
/sys/devices/system/cpu/cpu6/topology/thread_siblings   00000000,00004040
/sys/devices/system/cpu/cpu7/topology/thread_siblings   00000000,00008080
/sys/devices/system/cpu/cpu8/topology/thread_siblings   00000000,00000101
/sys/devices/system/cpu/cpu9/topology/thread_siblings   00000000,00000202
/sys/devices/system/cpu/cpu10/topology/thread_siblings  00000000,00000404
/sys/devices/system/cpu/cpu11/topology/thread_siblings  00000000,00000808
/sys/devices/system/cpu/cpu12/topology/thread_siblings  00000000,00001010
/sys/devices/system/cpu/cpu13/topology/thread_siblings  00000000,00002020
/sys/devices/system/cpu/cpu14/topology/thread_siblings  00000000,00004040
/sys/devices/system/cpu/cpu15/topology/thread_siblings  00000000,00008080

Identical content denotes threads of the same core. I.e.

  • cpu0 / cpu8
  • cpu1 / cpu9
  • etc.

There is similar information in the core_siblings pseudo-file, along with yet more topology information.

Tags:

Cpu