Ozgur's Blog

Random ramblings of personal nature

Disabling Intel Turbo Boost in Linux


Preamble

My venerable Clevo W220ST gained some quirks during its service with me. One of them is faulty temperature sensors reporting that cpu is 99 degrees celcius for a second. It is faulty because the next second it reports as 60 degrees. I managed to trace it down to turbo boost. As in when TB is enabled it tends to report these degrees and when it is not, all is normal as in the temperature shows sane values: Idling gives me 40-50 degrees and load gives me 70 degrees celcius.

In Windows I used a third party app to disable this feature. In Linux we need to create our own disabler.

Preparation

To do that we need to install msr-tools. In manjaro this translates to:

sudo pacman -S msr-tools

Then we need to create a script to enable/disable all the turbo boosts in all of our cpu cores. This is found via askubuntu but works for our purposes here as well.

I put this into a folder called .bootscripts under my home folder.

turbo-boost.sh

#!/bin/bash

if [[ -z $(which rdmsr) ]]; then
    echo "msr-tools is not installed. Run 'sudo apt-get install msr-tools' to install it." >&2
    exit 1
fi

if [[ ! -z $1 && $1 != "enable" && $1 != "disable" ]]; then
    echo "Invalid argument: $1" >&2
    echo ""
    echo "Usage: $(basename $0) [disable|enable]"
    exit 1
fi

cores=$(cat /proc/cpuinfo | grep processor | awk '{print $3}')
for core in $cores; do
    if [[ $1 == "disable" ]]; then
        sudo wrmsr -p${core} 0x1a0 0x4000850089
    fi
    if [[ $1 == "enable" ]]; then
        sudo wrmsr -p${core} 0x1a0 0x850089
    fi
    state=$(sudo rdmsr -p${core} 0x1a0 -f 38:38)
    if [[ $state -eq 1 ]]; then
        echo "core ${core}: disabled"
    else
        echo "core ${core}: enabled"
    fi
done

Then, of course, we need to make it an executable:

sudo chmod +x turbo-boost.sh

now we can run it with:

./turbo-boost.sh disable
./turbo-boost.sh enable

Note - Update

If you get something like

wrmsr: open: No such file or directory
rdmsr: open: No such file or directory

you need to modprobe msr module via:

sudo modprobe msr

Modprobbing MSR on startup

To load our disable turbo boost script, we first need to modprobe the msr-tools on boot. To do it we need to create a file (msr.conf) in /etc/modules-load.d:

/etc/modules-load.d/msr.conf

and this conf file will include only this:

msr

Now on boot we'll have our tools modprobbed and ready to be used.

Enabling turbo boost as a service

To make it run on boot we need to create a service file in /etc/systemd/system that contains these information:

disable-turbo-boost.service

[Unit]
Description=Disable Turbo Boost on boot
After=default.target

[Service]
Type=oneshot
ExecStart=/home/f4stjack/.bootscripts/turbo-boost.sh disable

[Install]
WantedBy=default.target

I wrote my own path in ExecStart variable. You should change this for your own system.

Then we can start this service via:

sudo systemctl start disable-turbo-boost.service

And get it to run on boot via:

sudo systemctl enable disable-turbo-boost.service

References

  • https://askubuntu.com/questions/619875/disabling-intel-turbo-boost-in-ubuntu/620114