Improving thermal management with Intel Running Average Power Limit (RAPL) - junaruga/framework-laptop-config GitHub Wiki
This page is about setting up to improve the therm of the CPU with Intel Running Average Power Limit (RAPL). The benefit is to suppress the sound of the loud fan.
I followed the instructions on the Framework community page[1].
- Fedora Linux 36
- Kernel: 5.19.8-200
$ uname -r 5.19.8-200.fc36.x86_64
Install the powercap[2] first. As it seems that there is no RPM package for powercap, install it by building the source. I built on the latest master branch commit 1af02708c0561a622291615e5ee2f3f06a697413
, reading the README.md
.
$ git clone https://github.com/powercap/powercap.git
$ cd powercap
$ git log --pretty=oneline --abbrev-commit | head -1
1af0270 cmake: bump version to 0.6.1
$ mkdir build
$ cd build/
$ cmake .. -DBUILD_SHARED_LIBS=On -DCMAKE_BUILD_TYPE=Release --install-prefix=/usr/local/powercap-0.6.1-1af0270
$ make
$ sudo make install
The installed commands need to be able to find the library path.
$ /usr/local/powercap-0.6.1-1af0270/bin/powercap-info
/usr/local/powercap-0.6.1-1af0270/bin/powercap-info: error while loading shared libraries: libpowercap.so.0: cannot open shared object file: No such file or directory
Add a symbolic file for the installed directory for convenience.
$ cd /usr/local
$ sudo ln -s powercap-0.6.1-1af0270 powercap
Set the library path, and activate it. See the [3] for details.
$ sudo vi /etc/ld.so.conf.d/powercap.conf
/usr/local/powercap/lib64 # <= Add this line.
$ sudo ldconfig
$ sudo ldconfig -v | grep powercap
ldconfig: Can't stat /libx32: No such file or directory
ldconfig: Path `/usr/lib' given more than once
(from <builtin>:0 and <builtin>:0)
ldconfig: Path `/usr/lib64' given more than once
(from <builtin>:0 and <builtin>:0)
ldconfig: Can't stat /usr/libx32: No such file or directory
/usr/local/powercap/lib64: (from /etc/ld.so.conf.d/powercap.conf:1)
libpowercap.so.0 -> libpowercap.so.0.6.1
Set the symbolic link for convenience, as the powercap-set
is used in the systemd config files in a later step.
$ cd /usr/local/bin/
$ sudo ln -s ../powercap/bin/powercap-set .
Set the PATH
for convinience.
.bashrc
...
PATH="${PATH}:/usr/local/powercap/bin"
...
export PATH
You can see the status by the powercap-info
command.
$ powercap-info > powercap_info_orig.txt
Stop the thermald
service.
$ systemctl list-unit-files | grep thermald
dbus-org.freedesktop.thermald.service alias -
thermald.service enabled enabled
$ sudo systemctl stop thermald
$ sudo systemctl status thermald
Run the powercap-set
commands.
$ sudo powercap-set intel-rapl --zone=0 --constraint=0 -l 14000000 -s 10000000
$ sudo powercap-set intel-rapl --zone=0 --constraint=2 -l 36000000
$ powercap-info > powercap_info_new.txt
Here is the difference.
$ diff -u powercap_info_orig.txt powercap_info_new.txt
--- powercap_info_orig.txt 2022-10-16 20:54:33.853487459 +0200
+++ powercap_info_new.txt 2022-10-16 21:03:01.636962970 +0200
@@ -22,8 +22,8 @@
max_energy_range_uj: 262143328850
Constraint 0
name: long_term
- power_limit_uw: 200000000
- time_window_us: 31981568
+ power_limit_uw: 14000000
+ time_window_us: 9994240
max_power_uw: 28000000
Constraint 1
name: short_term
@@ -32,7 +32,7 @@
max_power_uw: 0
Constraint 2
name: peak_power
- power_limit_uw: 121000000
+ power_limit_uw: 36000000
time_window_us: 0
max_power_uw: 0
Zone 0:0
/etc/systemd/system/intel-rapl-balanced.service
[Unit]
Description=Set Intel RAPL power limits (balanced)
Conflicts=intel-rapl-powersave.service thermald.service
[Service]
ExecStart=/bin/sh -c "powercap-set intel-rapl -z 0 -c 0 -l 14000000 -s 10000000 && powercap-set intel-rapl -z 0 -c 2 -l 36000000"
ExecStop=/bin/sh -c "powercap-set intel-rapl -z 0 -c 0 -l 200000000 && powercap-set intel-rapl -z 0 -c 2 -l 121000000"
RemainAfterExit=yes
[Install]
WantedBy=sysinit.target
/etc/systemd/system/intel-rapl-powersave.service
[Unit]
Description=Set Intel RAPL power limits (powersave)
Conflicts=intel-rapl-balanced.service thermald.service
[Service]
ExecStart=/bin/sh -c "powercap-set intel-rapl -z 0 -c 0 -l 10000000 -s 10000000 && powercap-set intel-rapl -z 0 -c 2 -l 20000000"
ExecStop=/bin/sh -c "powercap-set intel-rapl -z 0 -c 0 -l 200000000 && powercap-set intel-rapl -z 0 -c 2 -l 121000000"
RemainAfterExit=yes
[Install]
WantedBy=sysinit.target
$ sudo systemctl daemon-reload
$ sudo systemctl enable intel-rapl-balanced
$ sudo systemctl start intel-rapl-balanced
$ sudo systemctl disable thermal
The acpid is a daemon that dispatches ACPI events to user-space programs. The ACPI is is the acronym for Advanced Configuration and Power Interface.
$ sudo dnf install acpid
$ rpm -q acpid
acpid-2.0.33-2.fc36.x86_64
I enabled the intel-rapl-powersave service, as it will be used.
$ sudo systemctl enable intel-rapl-powersave
$ systemctl list-unit-files | grep intel-rapl-powersave
intel-rapl-powersave.service enabled disabled
/etc/acpi/events/ac-power-on
event=ac_adapter ACPI0003:00 00000080 00000001
action=systemctl start intel-rapl-balanced
/etc/acpi/events/ac-power-off
event=ac_adapter ACPI0003:00 00000080 00000000
action=systemctl start intel-rapl-powersave
$ sudo systemctl restart acpid
That's all.