throttled

throttled

Linux系统Intel CPU性能优化工具

throttled是一款针对Linux系统优化Intel CPU性能的开源工具。它通过周期性覆盖MSR和MCHBAR默认值,调整CPU功率限制和温度阈值,防止嵌入式控制器重置这些参数。此外,throttled还提供CPU降压、IccMax调整和HWP覆盖等高级功能,全面提升CPU性能。该工具适用于多种笔记本型号,可有效解决Intel CPU在Linux系统下的节流问题。

LinuxCPU throttlingIntel功耗限制性能优化Github开源项目

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
  • 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.

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

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-devel cairo-devel python3-gobject-cairo gobject-introspection-devel
git clone https://github.com/erpalma/throttled.git
sudo ./throttled/install.sh

Gentoo

The ebuild is now in the official tree!

sudo emerge -av sys-power/throttled
# when using OpenRC:
rc-update add throttled default
/etc/init.d/throttled start
# when using systemd:
systemctl enable --now throttled.service

Solus

sudo eopkg it -c system.devel
sudo eopkg it git python3-devel dbus-glib-devel python3-cairo-devel libcairo-devel python3-gobject-devel
git clone https://github.com/erpalma/throttled.git
sudo ./throttled/install.sh

Void

The installation itself will create a runit service as throttled, enable it and start it. Before installation, make sure dbus is running sv up dbus.

sudo xbps-install -Sy gcc git python3-devel dbus-glib-devel libgirepository-devel cairo-devel python3-wheel pkg-config make

git clone https://github.com/erpalma/throttled.git

sudo ./throttled/install.sh

Uninstall

To permanently stop and disable the execution just issue:

systemctl stop throttled.service
systemctl disable throttled.service

If you're running runit instead of systemd:

sv down throttled
rm /var/service/throttled

If you're using OpenRC instead of systemd:

rc-service throttled stop
rc-update del throttled default

If you also need to remove the tool from the system:

rm -rf /opt/throttled /etc/systemd/system/throttled.service
# to purge also the config file
rm /etc/throttled.conf

On Arch you should probably use pacman -R lenovo-throttling-fix-git instead.

Update

If you update the tool you should manually check your config file for changes or additional features and modify it accordingly. The update process is then as simple as:

cd throttled
git pull
sudo ./install.sh
sudo systemctl restart throttled.service
OpenRC: sudo rc-service throttled restart

Configuration

The configuration has moved to /etc/throttled.conf. Makefile does not overwrite your previous config file, so you need to manually check for differences in config file structure when updating the tool. If you want to overwrite the config with new defaults just issue sudo cp etc/throttled.conf /etc. There exist two profiles AC and BATTERY and the tool can be totally disabled by setting Enabled: False in the GENERAL section. Undervolt is applied if any voltage plane in the config file (section UNDERVOLT) was set. Notice that the offset is in mV and only undervolting (i.e. negative values) is supported. All fields accept floating point values as well as integers.

My T480s with i7-8550u is stable with:

[UNDERVOLT]
# CPU core voltage offset (mV)
CORE: -105
# Integrated GPU voltage offset (mV)
GPU: -85
# CPU cache voltage offset (mV)
CACHE: -105
# System Agent voltage offset (mV)
UNCORE: -85
# Analog I/O voltage offset (mV)
ANALOGIO: 0

IMPORTANT: Please notice that my system is stable with these values. Your notebook might crash even with slight undervolting! You should test your system and slowly incresing undervolt to find the maximum stable value for your CPU. You can check this tutorial if you don't know where to start.

Monitoring

With the flag --monitor the tool constantly monitors the throttling status, indicating the cause among thermal limit, power limit, current limit or cross-origin. The last cause is often related to an external event (e.g. by the GPU). The update rate can be adjusted and defaults to 1 second. Example output:

./throttled.py --monitor
[I] Detected CPU architecture: Intel Kaby Lake (R)
[I] Loading config file.
[I] Starting main loop.
[D] Undervolt offsets: CORE: -105.00 mV | GPU: -85.00 mV | CACHE: -105.00 mV | UNCORE: -85.00 mV | ANALOGIO: 0.00 mV
[D] IccMax: CORE: 64.00 A | GPU: 31.00 A | CACHE: 6.00 A
[D] Realtime monitoring of throttling causes:

[AC] Thermal: OK - Power: OK - Current: OK - Cross-domain (e.g. GPU): OK  ||  VCore: 549 mV - Package: 2.6 W - Graphics: 0.4 W - DRAM: 1.2 W

Static Fix

You can alternatively set the power limits using intel_rapl driver (modifying MCHBAR values requires Linux 5.3+). Bear in mind, some embedded controllers (EC) control the power limit values and will reset them from time to time):

# MSR
# PL1
echo 44000000 | sudo tee /sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_0_power_limit_uw # 44 watt
echo 28000000 | sudo tee /sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_0_time_window_us # 28 sec
# PL2
echo 44000000 | sudo tee /sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_1_power_limit_uw # 44 watt
echo 2440 | sudo tee /sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_1_time_window_us # 0.00244 sec

# MCHBAR
# PL1
echo 44000000 | sudo tee /sys/devices/virtual/powercap/intel-rapl-mmio/intel-rapl-mmio:0/constraint_0_power_limit_uw # 44 watt
# ^ Only required change on a ASUS Zenbook UX430UNR
echo 28000000 | sudo tee /sys/devices/virtual/powercap/intel-rapl-mmio/intel-rapl-mmio:0/constraint_0_time_window_us # 28 sec
# PL2
echo 44000000 | sudo tee /sys/devices/virtual/powercap/intel-rapl-mmio/intel-rapl-mmio:0/constraint_1_power_limit_uw # 44 watt
echo 2440 | sudo

编辑推荐精选

TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多