How to tell if CPU hyperthreading enabled on Linux

Nowadays CPU hyperthreading is not a hot topic but rather common. Generally speaking, for most cases, you can get roughly 10-20% performance gain on HT enabled, however, on the other hand, probably you will notice that power consomption and tempature will increase too(if you are managing a large HPC site, it is important to know before you switch hyperthreading on).
Anyway, how do we quickly get Hyperthreading info on linux ?

To see CPU Hyperthreading capability

1. Using dmidecode

# dmidecode | grep -E "Socket Designation: Node |HTT"
    Socket Designation: Node 1 Socket 1
        HTT (Multi-threading)
    Socket Designation: Node 1 Socket 2
        HTT (Multi-threading)
It tells you that HT is enabled

2. Using info from /proc/cpuinfo

# cat /proc/cpuinfo | grep -i HT
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush 
               dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc
               arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq 
               dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 
               sse4_2 popcnt aes lahf_lm arat epb dts tpr_shadow vnmi flexpriority ept vpid 
Each CPU has its own flags, if 'ht' shows in the list of flags, then the CPU is Hyperthreading capibility.

To see if Hyperthreading enabled on the node

1. Using lscpu output info

# lscpu | grep -i -E  "^CPU\(s\):|core|socket"
CPU(s):                24
Thread(s) per core:    2
Core(s) per socket:    6
Socket(s):             2
As you can see, number of threads per core is 2, so it's HT enabled.

2. Using info from /proc/cpuinfo

# cat /proc/cpuinfo | grep -E "cpu cores|siblings|physical id" |xargs -n 11 echo |sort |uniq      
physical id : 0 siblings : 12 cpu cores : 6
physical id : 1 siblings : 12 cpu cores : 6

In the case above, siblings is 2 times than cores, thus, the host is HT enabled.
#  cat /proc/cpuinfo | grep -E "cpu cores|siblings|physical id" |xargs -n 11 echo |sort |uniq  
physical id : 0 siblings : 2 cpu cores : 2
physical id : 3 siblings : 2 cpu cores : 2
In the case above, HT is disabled

3. Using dmidecode

# dmidecode  | grep Count
    Core Count: 4
    Thread Count: 8
# dmidecode -t processor | grep -E '(Core Count|Thread Count)'
In the case above, HT is enabled for sure.
Note: on old machine, dmidecode may not give you CPU detail info such as Core Count, Thread Count etc..

Nhận xét

Bài đăng phổ biến