Patrick Patrick - 1 year ago 94
Linux Question

Linux find out Hyper-threaded core id

I spent this morning trying to find out how to determine which processor id is the hyper-threaded core, but without luck.

I wish to find out this information and use

to bind a process to hyper-threaded thread or non-hyper-threaded thread to profile its performance.

Answer Source

I discovered the simply trick to do what I need.

cat /sys/devices/system/cpu/cpu0/topology/thread_siblings_list

If the first number is equal to the CPU number (0 in this example) then it's a real core, if not it is a hyperthreading core.

Real core example:

# cat /sys/devices/system/cpu/cpu1/topology/thread_siblings_list

Hyperthreading core example

# cat /sys/devices/system/cpu/cpu13/topology/thread_siblings_list

The output of the second example is exactly the same as the first one. However we are checking cpu13, and the first number is 1, so CPU 13 this is an hyperthreading core.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download