Throttled
Workaround for Intel throttling issues in Linux.
Install / Use
/learn @erpalma/ThrottledREADME
Fix Intel CPU Throttling on Linux
This tool was originally developed to fix Linux CPU throttling issues affecting Lenovo T480 / T480s / X1C6 as described here.
The CPU package power limit (PL1/2) is forced to a value of 44 W (29 W on battery) and the temperature trip point to 95 'C (85 'C on battery) by overriding default values in MSR and MCHBAR every 5 seconds (30 on battery) to block the Embedded Controller from resetting these values to default.
On systems where the EC doesn't reset the values (ex: ASUS Zenbook UX430UNR), the power limit can be altered by using the official intel_rapl driver (see Static fix for more information)
Warning!
The latest commit (30 Oct 2021) switched from the legacy name lenovo_fix for the tool/config/system to a more uniform throttled. The install script was updated, but please report back if anything breaks.
Tested hardware
Other users have confirmed that the tool is also working for these laptops:
- Lenovo T470s, T480, T480s, X1C5, X1C6, X1C8, T580, L590, L490, L480, T470, X280, X390, ThinkPad Anniversary Edition 25, E590 w/ RX 550X, P43s, E480, E580, T14 Gen 1, P14s Gen 1, T15 Gen 1, P15s Gen 1, E14 Gen 2, X1 Extreme Gen 4
- Dell XPS 9365, 9370, 9550, 7390 2-in-1, Latitude 7390 2-in-1, Inspiron 16 Plus 7620, Precision 7720(with thermald)
- Microsoft Surface Book 2
- HP Probook 470 G5, Probook 450 G5, ZBook Firefly 15 G7
I will keep this list updated.
Is this tool really doing something on my PC??
I suggest you to use the excellent s-tui tool to check and monitor the CPU usage, frequency, power and temperature under load!
Undervolt
The tool supports undervolting the CPU by configuring voltage offsets for CPU, cache, GPU, System Agent and Analog I/O planes. The tool will re-apply undervolt on resume from standby and hibernate by listening to DBus signals. You can now either use the UNDERVOLT key in config to set global values or the UNDERVOLT.AC and UNDERVOLT.BATTERY keys to selectively set undervolt values for the two power profiles.
===== Notice that undervolt is typically locked from 10th gen onwards! =====
IccMax (EXPERTS ONLY)
The tool now supports overriding the IccMax by configuring the maximum allowed current for CPU, cache and GPU planes. The tool will re-apply IccMax on resume from standby and hibernate. You can now either use the ICCMAX key in config to set global values or the ICCMAX.AC and ICCMAX.BATTERY keys to selectively set current values for the two power profiles. NOTE: the values specified in the config file are the actual current limit of your system, so those are not a offset from the default values as for the undervolt. As such, you should first find your system default values with the --monitor command.
HWP override (EXPERIMENTAL)
I have found that under load my CPU was not always hitting max turbo frequency, in particular when using one/two cores only. For instance, when running prime95 (1 core, test #1) my CPU is limited to about 3500 MHz over the theoretical 4000 MHz maximum. The reason is the value for the HWP energy performance hints. By default TLP sets this value to balance_performance on AC in order to reduce the power consumption/heat in idle. By setting this value to performance I was able to reach 3900 MHz in the prime95 single core test, achieving a +400 MHz boost. Since this value forces the CPU to full speed even during idle, a new experimental feature allows to automatically set HWP to performance under load and revert it to balanced when idle. This feature can be enabled (in AC mode only) by setting to True the HWP_Mode parameter in the throttled config file : https://github.com/erpalma/throttled/blob/master/etc/throttled.conf#L41 .
I have run Geekbench 4 and now I can get a score of 5391/17265! On balance_performance I can reach only 4672/16129, so 15% improvement in single core and 7% in multicore, not bad ;)
setting cTDP (EXPERIMENTAL)
On a lot of modern CPUs from Intel one can configure the TDP up or down based on predefined profiles. This is what this option does. For a i7-8650U normal would be 15W, up profile is setting it to 25W and down to 10W. You can lookup the values of your CPU at the Intel product website.
Requirements
A stripped down version of the python module python-periphery is now built-in and it is used for accessing the MCHBAR register by memory mapped I/O. You also need dbus and gobject python bindings for listening to dbus signals on resume from sleep/hibernate.
Writing to MSR and PCI BAR
Some time ago a feature called Kernel Lockdown was added to Linux. Kernel Lockdown automatically enables some security measures when Secure Boot is enabled, among them restricted access to MSR and PCI BAR via /dev/mem, which this tool requires. There are two ways to get around this: You can either disable Secure Boot in your firmware settings, or disable the Kernel Lockdown LSM.
The LSM can be disabled this way: Check the contents of the file /sys/kernel/security/lsm (example contents: capability,lockdown,yama). Take the contents of the file, remove lockdown and add the rest as a kernel parameter, like this: lsm=capability,yama. Reboot and Kernel Lockdown will be disabled!
As of Linux 5.9, kernel messages will be logged whenever the script writes to MSR registers. These aren't a problem for now, but there's some indication that future kernels may restrict MSR writes from userspace by default. This is being tracked by issue #215. The messages will look something like:
[ 324.833543] msr: Write to unrecognized MSR 0x1a2 by python3
Please report to x86@kernel.org
Note that some kernels (e.g. linux-hardened) will prevent from writing to /dev/mem too. Specifically, you need a kernel with CONFIG_DEVMEM and CONFIG_X86_MSR set.
Thermald
As discovered by DEvil0000 the Linux Thermal Monitor (thermald) can conflict with the purpose of this tool. In particular, thermald might be pre-installed (e.g. on Ubuntu) and configured in such a way to keep the CPU temperature below a certain threshold (~80 'C) by applying throttling or messing up with RAPL or other CPU-specific registers. I strongly suggest to either disable/uninstall it or to review its default configuration.
Note that on some platforms thermald seems to be required. E.g. Dell Latitude 7320 i7-1185G7, Linux 6.6.48, Void Linux musl, still runs into throttling issues unless thermald --adaptive is running. If you are running throttled but still seeing throttling issues, try testing with thermald --adaptive running as well.
Update
The tool is now running with Python3 by default (tested w/ 3.6) and a virtualenv is automatically created in /opt/throttled. Python2 should probably still work.
Installation
Arch Linux community package:
pacman -S throttled
sudo systemctl enable --now throttled.service
Thanks to felixonmars for creating and maintaining this package.
Artix Linux
makepkg -si
sudo rc-update add throttled default
sudo rc-service throttled start
Alpine Linux
You need to be on edge and have the testing repository enabled.
doas apk add throttled
doas rc-update add throttled
doas rc-service throttled start
Debian/Ubuntu
sudo apt install git build-essential python3-dev libdbus-glib-1-dev libgirepository1.0-dev libcairo2-dev python3-cairo-dev python3-venv python3-wheel
git clone https://github.com/erpalma/throttled.git
sudo ./throttled/install.sh
If you own a X1C6 you can also check a tutorial for Ubuntu 18.04 here.
You should make sure that thermald is not setting it back down. Stopping/disabling it will do the trick:
sudo systemctl stop thermald.service
sudo systemctl disable thermald.service
If you want to keep it disabled even after a package update you should also run:
sudo systemctl mask thermald.service
In order to check if the service is well started, you could run:
systemctl status throttled
Fedora
A copr repository is available and can be used as detailed below. You can find the configuration installed at /etc/throttled.conf. The issue tracker for this packaging is available here.
sudo dnf copr enable abn/throttled
sudo dnf install -y throttled
sudo systemctl enable --now throttled
If you prefer to install from source, you can use the following commands.
sudo dnf install python3-cairo-devel cairo-gobject-devel gobject-introspection-devel dbus-glib-devel python3-devel make libX11-devel
git clone https://github.com/erpalma/throttled.git
sudo ./throttled/install.sh
Feedback about Fedora installation is welcome.
Fedora Silverblue
Download the .repo file matching your Fedora on the copr repository page then copy it to /etc/yum.repos.d/.
You can then install the package:
rpm-ostree override remove thermald
rpm-ostree install throttled
systemctl reboot
sudo systemctl enable --now throttled
openSUSE
User brycecordill reported that the following dependencies are required for installing in openSUSE, tested on openSUSE 15.0 Leap.
sudo zypper install gcc make python3-devel dbus-1-glib-devel python3-cairo-
