Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
76 Views

How to disable Hyperthreading in HASWELL EP v3 from linux command

Jump to solution

Can anyone please suggest me? How to disable it?

0 Kudos

Accepted Solutions
Highlighted
Black Belt
64 Views

HyperThreading can only be disabled by the BIOS -- before the operating system is booted.

Linux has mechanisms to ignore certain cores -- many of these are Linux boot-time options.

It is difficult to reliably measure any performance difference between a system with HyperThreading disabled and a system with HyperThreading enabled, but user processes restricted to one Logical Processor per core.

"Dr. Bandwidth"

View solution in original post

0 Kudos
2 Replies
Highlighted
Black Belt
65 Views

HyperThreading can only be disabled by the BIOS -- before the operating system is booted.

Linux has mechanisms to ignore certain cores -- many of these are Linux boot-time options.

It is difficult to reliably measure any performance difference between a system with HyperThreading disabled and a system with HyperThreading enabled, but user processes restricted to one Logical Processor per core.

"Dr. Bandwidth"

View solution in original post

0 Kudos
Highlighted
36 Views

You can turn off hyperthreading at the linux command line on any processor (Intel or AMD) by first identifying which threads belong to which cores and then disabling one of the threads in each core.

To determine the threads in each core run the following script

#!/bin/bash
num_vcpus=$(ls /sys/devices/system/cpu | grep -v cpuidle | grep cpu|wc -l)
for ((i=0;i<num_vcpus;i=i+1))
do
    cat /sys/devices/system/cpu/cpu$i/topology/thread_siblings_list
done

 

On my 64 vCPU skylake, the script produces

0,32
1,33
2,34
3,35
4,36
5,37
6,38
7,39
8,40
9,41
10,42
11,43
12,44
13,45
14,46
15,47
16,48
17,49
18,50
19,51
20,52
21,53
22,54
23,55
24,56
25,57
26,58
27,59
28,60
29,61
30,62
31,63
0,32
1,33
2,34
3,35
4,36
5,37
6,38
7,39
8,40
9,41
10,42
11,43
12,44
13,45
14,46
15,47
16,48
17,49
18,50
19,51
20,52
21,53
22,54
23,55
24,56
25,57
26,58
27,59
28,60
29,61
30,62
31,63

 

This shows you that CPUs 0 and 32 are siblings, as are 1 and 33, 2 and 34, and so forth.

So to disable hyperthreading on this machine you could to disable CPUs 32 through 63 or CPUs 0 through 31, or some combination.

To disable CPU 32 you execute as root

echo 0 > /sys/devices/system/cpu/cpu32/online

To disable CPU 33 you execute as root

echo 0 > /sys/devices/system/cpu/cpu33/online

and so forth.

You could disable the whole shebang with a simple for loop.

To enable CPU 32 you execute as root

echo 1 > /sys/devices/system/cpu/cpu32/online

and so forth.

richard gostanian
0 Kudos