Recently I upgraded my trusty Framework 13 laptop to AMD motherboard. It’s not my primary laptop mind you, but it does come handy whenever my F16 is too cubersome to lug around. For me, that often ends with it in my lap.
And this laptop can get hot. AMD CPU always wants to give it all, even when it’s not necessary. Often I will have a long-running task in background, that CPU will try to speed up as much as possible by boosting its clock and fans to max. And those are tasks I care not if they finish in 30 or 35 minutes and thus extra heat is unappreciated.
Easy solution for this is just turning off turbo boost. And that is easy enough by writing 0
to a file:
echo 0 | sudo tee /sys/devices/system/cpu/cpufreq/boost
However, I usually remember to do so only once my legs start smoking. So, I decided that it was about time for my system to use that setting as a default. And, since my Kubuntu uses systemd
, all starts with creating a service
cat << EOF | sudo tee /etc/systemd/system/cpu-noturbo.service
[Unit]
Description=Disable Turbo Boost
[Service]
ExecStart=/bin/bash -c "echo 0 | tee /sys/devices/system/cpu/cpufreq/boost"
ExecStop=/bin/bash -c "echo 1 | tee /sys/devices/system/cpu/cpufreq/boost"
RemainAfterExit=yes
[Install]
WantedBy=sysinit.target
EOF
Whenever service is started, it will disable turbo boost. Once service is stopped, turbo boost will be reenabled.
Of course, to make sure it starts on every boot, we need to enable
it. And because we don’t want to reboot system to apply settings, we might as well start
it immediately.
sudo systemctl daemon-reload
sudo systemctl enable cpu-noturbo
sudo systemctl start cpu-noturbo
PS: The same behavior for Intel CPU can be achieved by using slighly different commands. Note that 1
and 0
are swapped:
echo 1 | tee /sys/devices/system/cpu/intel_pstate/no_turbo
echo 0 | tee /sys/devices/system/cpu/intel_pstate/no_turbo