

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

Will show the core number this logical cpu belongs to.Įcho "0" > /sys/devices/system/cpu/cpu3/onlineĪllows to disable logical cpu 3. For example:Ĭontains the kernel information and controls for logical cpu 3.Ĭat /sys/devices/system/cpu/cpu3/topology/core_id Linux kernel information and controls can be accessed as files in /sys directory on modern linux distributions. # place this near the end before the "exit 0"įor CPU in /sys/devices/system/cpu/cpu* doĮval "COREENABLE=\"\$\"" It is not exaclty clean, but is easy to install, independent of cpu architecture and should work on any modern linux distribution. To disable hyperthreading I include a script on machine /etc/rc.local. Solution 3: A script to disable hyperthreading in the machine startup. We have tested this with Linux Kernel 4.4.0 You can check the state of SMT with cat /sys/devices/system/cpu/smt/activeĬhange the state with echo off > /sys/devices/system/cpu/smt/control Newer Kernels provide a Simultaneous Multithreading (SMT) control.

You could setup yourself a script that you run just after system start. 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Įcho 0 > /sys/devices/system/cpu/cpu5/onlineĮcho 0 > /sys/devices/system/cpu/cpu6/onlineĮcho 0 > /sys/devices/system/cpu/cpu7/online Look for the CPUs that have the same "core id", you want to switch off one of each pair. Step 1: Identify the linux CPUs you want to switch off: cat /proc/cpuinfo You can do this at runtime if you want to.
