How to check whether Hyper Threading is enabled or not in Ubuntu?
Asked Answered
P

4

10

I am using the Ubuntu. How can I check whether Hyper Threading is enabled or not. And if it is disabled, how can I enable it?

Pragmatics answered 13/4, 2015 at 12:25 Comment(0)
L
7

You can check the pseudo file /sys/devices/system/cpu/smt/active - it contains 1 if hyperthreading is enabled and 0 otherwise.

Shell example:

$ printf 'Hyperthreading '; \
      sed -e s/1/enabled/ -e s/0/disabled/ /sys/devices/system/cpu/smt/active

You can either enable it in the BIOS - or in Linux with

# echo on > /sys/devices/system/cpu/smt/control

if and only if

# cat /sys/devices/system/cpu/smt/control

returns off.

Luetic answered 24/8, 2019 at 17:9 Comment(4)
I have a quad core cpu, and have 8 total threads, which is also what i see with lscpu. but i have read on internet that there should be 16 threads if i have hyperthreading enabled. your last command returned on for me. but, why am i only getting 8 threads then?Catacomb
@NaveenKumar - most CPUs that implement hyperthreading implement 2 threads of execution per core. So 8 threads is expected for a quad core CPU then. You can also cross-check by looking up your CPU model name in the vendor's online CPU database.Luetic
I have a 1 in this file, but dmidecode shows 4 for both "Core Count" and "Thread Count".Zampino
@Zampino dmidecode just reads out the DMI tables which are populated by the BIOS at some point during system initialization. Thus the information contained therein isn't necessarily accurate, especially after an operating system kernel (re-)initializes much hardware. If you want to get on the bottom of this you can cross check these numbers against the data sheet of your CPU and the lscpu output.Luetic
N
3

You can check if HyperThreading is enable or not with

dmidecode -t processor|grep Count

if "Core Count" is the same as "Thread Count" ex:

Core Count: 32 Thread Count: 32

The HT is Disabled.

Else HT is Enabled.

Flag "HTT" shows the possibility of HyperThreading.

Nerland answered 8/7, 2021 at 14:34 Comment(0)
C
1

If you have root permission

dmidecode -t processor | grep HTT
Chrysler answered 13/4, 2015 at 12:27 Comment(3)
when i run grep -i 'ht' /proc/cpuinfo its showing flags in cpuinfo....what is the correct onePragmatics
@AnilYadav I read your all comments in Leon's answers also, you have HT capability but it is not enabled. So you have to check in BIOS to find is it enabled or not .Chrysler
This only checks if the CPU supports hyperthreading, i.e. it also prints HTT if it's disabled.Luetic
W
1

You can check cpuinfo

grep -i 'ht' /proc/cpuinfo

The ht flag indicates that Hyper Threading is enabled

Wommera answered 13/4, 2015 at 12:28 Comment(8)
its showing flags row....but when i run dmidecode -t processor | grep HTT command provide by Steephen its not showing anything.Pragmatics
I'm confused... Are you saying that the command above is not working?Wommera
oh, dmidecode requires sudo access... is it raising any errors?Wommera
In that case it could be that HyperThreading is disabled. On the command I gave, is the ht flag there? You can also run dmidecode -t processor without grep and check which flags are setWommera
Processor Information Socket Designation: CPU socket #0 Type: Central Processor Family: Unknown Manufacturer: GenuineIntel ID: D7 06 02 00 FF FB AB 1F Version: Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz Voltage: 3.3 V External Clock: Unknown Max Speed: 30000 MHz Current Speed: 2700 MHz Status: Populated, Enabled Upgrade: ZIF Socket L1 Cache Handle: 0x0054 L2 Cache Handle: 0x0055 L3 Cache Handle: Not Provided Serial Number: Not Specified Asset Tag: Not Specified Part Number: Not Specified Handle 0x0042, DMI type 4, 35 bytesPragmatics
Can you tell me how to Set it...?Pragmatics
Start by checking if it is enabled in the BIOSWommera
This check just checks if the CPU supports hyperthreading. Since /proc/cpuinfo also contains the 'ht' flag if hyperthreading is disabled your grep always matches on CPUs with HT support - even if it's disabled.Luetic

© 2022 - 2024 — McMap. All rights reserved.