how can i test if ubuntu activated hyperthreading?
/sys/bus/cpu/devices/cpu*/topology/thread_siblings_list shows the layout of cores and hyperthreads. To make it easier to visualise, I recommend using the lstopo command, install with:
sudo apt-get install hwloc
and run with:
lstopo
My ivybridge desktop has 4 CPUs; each has a hyperthread, so we get a diagram with Cores P#0..3 and each has two PU's (one of these being the hyperthread):
If you want just a text version of this output, use:
lstopo -
Run top
in a terminal, press number 1
in your keyboard to show load per cpu in the header, how many cpus are described there?
If they are the double of actual cores in your CPU hyperthreading is working as it should.
To detect if you are using hyperthreading (aka Intel Hyperthreading Technology) you can use dmidecode.
In a terminal:
sudo dmidecode > /tmp/dmidecode.txt
gksudo gedit /tmp/dmidecode.txt
Look for a Status value of Populated, Enabled (shown below between * ... *) i.e. "Enabled" means that hyperthreading is active
Physical CPU
Handle 0x000C, DMI type 4, 32 bytes
Processor Information
Socket Designation: Socket 1 CPU 1
Type: Central Processor
Family: Xeon
Manufacturer: GenuineIntel
ID: 43 0F 00 00 01 03 00 00
Signature: Type 0, Family 15, Model 4, Stepping 3
Flags:
FPU (Floating-point unit on-chip)
CX8 (CMPXCHG8 instruction supported)
APIC (On-chip APIC hardware supported)
Version: Intel Xeon
Voltage: 1.5 V
External Clock: 200 MHz
Max Speed: 4000 MHz
Current Speed: 3800 MHz
Status: *Populated, Enabled*
Upgrade: ZIF Socket
L1 Cache Handle: 0x0004
L2 Cache Handle: 0x0005
L3 Cache Handle: Not Provided
In a Hyperthreaded logical CPU you will see a Status value of unpopulated (shown below between * ... *):
Handle 0x000D, DMI type 4, 32 bytes
Processor Information
Socket Designation: Socket 2 CPU 2
Type: Unknown
Family: Unknown
Manufacturer: Not Specified
ID: 00 00 00 00 00 00 00 00
Version: Not Specified
Voltage: 1.5 V
External Clock: 200 MHz
Max Speed: 4000 MHz
Current Speed: 3800 MHz
Status: *Unpopulated*
Upgrade: ZIF Socket
L1 Cache Handle: 0x0006
L2 Cache Handle: 0x0007
L3 Cache Handle: Not Provided
source
in the result of dmidecode, you can get something like
Core Count: 6
Core Enabled: 6
Thread Count: 12
on servers with hyper thread set to ON
or
Core Count: 6
Core Enabled: 6
Thread Count: 6
on those set to OFF
Spoiler: your CPU doesn't support hyperthreading.
An alternative to consulting the CPU vendor's database is to check /proc/cpuinfo
for the ht
flag:
$ grep -o '\<ht\>' /proc/cpuinfo
Even if hyperthreading is disabled in the BIOS, the flag should be included in that output.
To check if hyperthreading is actually enabled you can consult another pseudo file:
$ cat /sys/devices/system/cpu/smt/control
Possible values are: on|off|forceoff|notsupported|notimplemented
You can enable/disable hyperthreading by writing on
/off
to that pseudo file, e.g.:
# echo off > /sys/devices/system/cpu/smt/control
Of course, this doesn't work if the cat
previously printed one of forceoff|notsupported|notimplemented
.
Usually, hyperthreading is enabled, by default. And if it's disabled it's commonly done so in the BIOS. If it's disabled in the BIOS that pseudo file likely contains forceoff
and you have to change the setting in the BIOS.