how can i test if ubuntu activated hyperthreading?

20,969

Solution 1

/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):

enter image description here

If you want just a text version of this output, use:

lstopo -

Solution 2

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.

Solution 3

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

Solution 4

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

Solution 5

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.

Share:
20,969
Romain
Author by

Romain

Experiences in Kotlin, Java, Dagger2 and Component Architecture. MVVM and MVP. German native speaker and fluent English. For more information please click given LinkedIn link entered in web presence.

Updated on September 18, 2022

Comments

  • Romain
    Romain almost 2 years

    I have the feeling that hyperthreading is not activated on my pc. I took a look into /proc/cpuinfo and there is described that siblings has the same number than cpu cores. This means that hyperthreading is not activated. How can i activate it?

    Part entries of /proc/cpuinfo:

    processor   : 0
    vendor_id   : GenuineIntel
    cpu family  : 6
    model       : 23
    model name  : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
    stepping    : 6
    cpu MHz     : 2997.000
    cache size  : 6144 KB
    physical id : 0
    siblings    : 2
    core id     : 0
    cpu cores   : 2
    apicid      : 0
    initial apicid  : 0
    fpu     : yes
    fpu_exception   : yes
    cpuid level : 10
    wp      : yes
    
  • Huck Bennett
    Huck Bennett over 11 years
    Not sure why no one has upvoted this yet... This is a really nice utility.
  • Silver Moon
    Silver Moon about 10 years
    this is super cool. you see the total cache, cores, hyperthreads all in 1 image
  • maxschlepzig
    maxschlepzig almost 5 years
    The dmicode output doesn't change if hyperthreading is disabled - it just indicates whether the CPU supports hyperthreading. For example, on a i7-6600U CPU system with disabled hyperthreading dmidecode | grep -i popula also prints Status: Populated, Enabled. See also my answer.
  • maxschlepzig
    maxschlepzig almost 5 years
    This doesn't work. The Thread Count doesn't change if hyperthreading is disabled, e.g. on a i7-6600U system with hyperthreading disabled dmidecode | grep '\(Core\|Thread\).*:' prints Core Count: 2 Core Enabled: 2 Thread Count: 4.
  • thomasa88
    thomasa88 almost 4 years
    Thanks for the link to Intel. It turns out my CPU does not support hyperthreading.