I have a system running a financial trading application at a remote facility. I do not have access to the ILO/DRAC, but need to disable hyperthreading. The system runs Intel Westmere 3.33GHz X5680 hex-core CPUs. I can reboot, but want to make sure that the system does not enable hyperthreading due to performance problems. Is there a clean way to do this from within Linux?

Edit: The noht directive added to the kernel boot command line did not work. Same for RHEL.

See: https://bugzilla.redhat.com/show_bug.cgi?id=440321#c9

You can do this at runtime if you want to. I found a nice solution described here: http://www.absolutelytech.com/2011/08/01/how-to-disable-cpu-cores-in-linux/

Step 1: Identify the linux CPUs you want to switch off:

cat /proc/cpuinfo

Look for the CPUs that have the same "core id", you want to switch off one of each pair.

Step 2: Switch off the hyperthreading CPUs (in my case the last four of the total 8 "CPUs" seen by Linux)

echo 0 > /sys/devices/system/cpu/cpu4/online
echo 0 > /sys/devices/system/cpu/cpu5/online
echo 0 > /sys/devices/system/cpu/cpu6/online
echo 0 > /sys/devices/system/cpu/cpu7/online

You could setup yourself a script that you run just after system start.

  • It works almost as I expected. virtual cores are disabled, now when I execute one cpu-consuming thread it loads physical core by 100%. But using sysbench --num-threads=1 --test=cpu run with different num-threads and HT turned on and off says that disabling HT decreases perfomrance when there are many threads, and even if there's just one thread there's no benefit from turning HT off. So I suggest to leave it as it is: it's optimal. – Sergey P. aka azure Dec 31 '14 at 13:43
  • Would you know what the command to switch them back on is? The link at the beginning of your answer is dead~. Thanks! – user189035 Oct 30 '16 at 10:55
  • @user189035: echo 1 instead of echo 0 should turn them back on. – Peter Cordes May 16 '17 at 16:28

A script to disable hyperthreading in the machine startup...

To disable hyperthreading I include a script on machine /etc/rc.local. It is not exaclty clean, but is easy to install, independent of cpu architecture and should work on any modern linux distribution.

nano /etc/rc.local

    # place this near the end before the "exit 0"

    for CPU in /sys/devices/system/cpu/cpu[0-9]*; do
        CPUID=$(basename $CPU)
        echo "CPU: $CPUID";
        if test -e $CPU/online; then
                echo "1" > $CPU/online; 
        COREID="$(cat $CPU/topology/core_id)";
        eval "COREENABLE=\"\${core${COREID}enable}\"";
        if ${COREENABLE:-true}; then        
                echo "${CPU} core=${CORE} -> enable"
                eval "core${COREID}enable='false'";
                echo "$CPU core=${CORE} -> disable"; 
                echo "0" > "$CPU/online"; 

How this works?

Linux kernel information and controls can be accessed as files in /sys directory on modern linux distributions. For example:

/sys/devices/system/cpu/cpu3 contains the kernel information and controls for logical cpu 3.

cat /sys/devices/system/cpu/cpu3/topology/core_id will show the core number this logical cpu belongs to.

echo "0" > /sys/devices/system/cpu/cpu3/online allows to disable logical cpu 3.

Why it works?

I do not know exactly why... but the system become more responsive with hyperthreading off (on my i5 notebook and massive Xeon servers with 60+ cores). I guess that has to do with per-cpu caches, per-cpu memory allocation, cpu scheduler allocation and process priorities complex iterations. I think the benefits of hyperthreading is outweight by the complexity of making cpu schedulers that know how to use it.

For me, the problem with hyperthreading is: If I start as many cpu-intensive threads as I have logical cores, I will have fast context switches for the cpu intensive tasks, but expensive ones for the background tasks since the hyperthreading totally consumed by the cpu intensive tasks. On the other hand, if I start as many cpu-intensive threads as I have physical cores I will have no context switches to those tasks and fast context switches for the background tasks. Seems good, but the background tasks will found free logical processors and will run almost imediatedly. It is like they are realtime performace (nice -20).

In the first scenario the hyperthreading is uselles, the background tasks will use expensive context switches because I maxed out hyperthreading with the normal processing. The second is unaceptable because up to 50% of my cpu power gets prioritized to the background tasks.

The "cpu-intensive" tasks I am talking about are artificial intelligence data mining and authorization servers (my work). Blender rendering in cheap computers and clusters (to sketch my future house).

Also, this is guesswork.

I have the impression that is better, but it may not.

  • I think my scriptlet is a little easier to follow. – Paul M Nov 1 '17 at 11:23

For really old kernels (Linux 2.6.9 or so), append the noht parameter to the kernel on boot.

This kernel command-line option has been removed since at least Linux 2.6.18.

From http://www.faqs.org/docs/Linux-HOWTO/BootPrompt-HOWTO.html :

The `noht' Argument

This will disable hyper-threading on intel processors that have this feature. 

If using lilo edit you /etc/lilo.conf (and run lilo afterwards) or if using grub then edit your /boot/grub/menu.lst .

  • Is this functionally equivalent to disabling HT in the BIOS? – ewwhite Feb 15 '11 at 18:26
  • I don't know that for sure, but yes, I would expect noht to be equivalent to disabling it on the BIOS. – rems Feb 15 '11 at 18:52
  • 2
    This is a Gentoo system. I tried the noht entry in the grub kernel command line. The system did not honor the noht command. Same for RHEL. See: bugzilla.redhat.com/show_bug.cgi?id=440321#c9 – ewwhite Feb 15 '11 at 19:41
  • This is obsolete since at least Linux 2.6.18. The noht kernel option was removed. This is unfortunate, because Linux enables a workaround for some Haswell perf-counter errata (BJ122, BV98, HSD29) only if HT is on, and this happens before initramfs is even loaded. – Peter Cordes May 16 '17 at 16:48

You can use the "thread_siblings_list" for each core to turn off the second core in the HT pair.

The following command pipeline is hacky, not optimised, and done this way hopefully to make it easier to understand.

cat /sys/devices/system/cpu/cpu*/topology/thread_siblings_list | \
awk -F, '{print $2}' | \
sort -n | \
uniq | \
( while read X ; do echo $X ; echo 0 > /sys/devices/system/cpu/cpu$X/online ; done )

so, take all the thread siblings lists, extract the second CPU for each pair, get a unique list, and then turn them off.

does this make sense?

if I do "cat /proc/cpuinfo" after running the above, the number of cores halves.

Lukas' answer is nice but does not really work for disabling HT because core ID cannot serve for identification of HT siblings. This script works instead:

for CPU in /sys/devices/system/cpu/cpu[0-9]*; do
    CPUID=`basename $CPU | cut -b4-`
    echo -en "CPU: $CPUID\t"
    [ -e $CPU/online ] && echo "1" > $CPU/online
    THREAD1=`cat $CPU/topology/thread_siblings_list | cut -f1 -d,`
    if [ $CPUID = $THREAD1 ]; then
        echo "-> enable"
        [ -e $CPU/online ] && echo "1" > $CPU/online
        echo "-> disable"
        echo "0" > $CPU/online
  • your script is a variation of mine. we'd have to check what happens if you have multiple CPUs, just to be sure. – Paul M Sep 27 '17 at 13:07
  • @PaulM That's exactly where I tested and used it for my purposes: 2 socket Haswell system. – Anton Sep 27 '17 at 15:07
up vote 0 down vote accepted

I had to wait until I could get into the ILO/Drac. The kernel boot parameters do not work on current Linux distributions.

In the libsmbios-bin package (Debian, Ubuntu, etc), you have the binaries isCmosTokenActive and activateCmosToken. Together with the token list, you can then try something like this:

# isCmosTokenActive 0x00d1 # CPU_Hyperthreading_Enable
[...] Type 0x00d1  Location 0x46 AND(fe) OR(0)  BITFIELD: 1
# isCmosTokenActive 0x00d2 # CPU_Hyperthreading_Disable
[....] Type 0x00d2  Location 0x46 AND(fe) OR(1)  BITFIELD: 0

Then activate the CPU_Hyperthreading_Disable token:

# activateCmosToken 0x00d2 # CPU_Hyperthreading_Disable
[...] Type 0x00d2  Location 0x46 AND(fe) OR(1)  BITFIELD: 1


# isCmosTokenActive 0x00d1 # CPU_Hyperthreading_Enable
[...] Type 0x00d1  Location 0x46 AND(fe) OR(0)  BITFIELD: 0
# isCmosTokenActive 0x00d2 # CPU_Hyperthreading_Disable
[...] Type 0x00d2  Location 0x46 AND(fe) OR(1)  BITFIELD: 1

Now, the big question is whether or not you simply need a reboot for this to take effect, or if a full power cycle is required. Try it out and see how it goes!

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.