Update on processor regulation to limit temperature problems
The processor in my Thinkpad X220 is an Intel i5-2520M (4) @ 3,200GHz, so I don't need to use the acpi-cpufreq module, but the built-in intel-pstate module.
From the Arch Linux Wiki:
Note: The intel_pstate driver only supports two governors: powersave and performance. Although they share the same name as the generic governors, they do not work in the same way as the latter. The two intel_pstate governors provide dynamic scaling similar to that of the generic schedutil or ondemand governors. The performance governor provided by intel_pstate should give better power saving functionality than the old ondemand governor.
So I installed cpupower in addition to thermald:
sudo pacman -S cpupower cpupower-gui
sudo systemctl enable cpupower
sudo systemctl start cpupower
I've found that my computer starts up with pstate=passive. To enable it on startup I added:
GRUB_CMDLINE_LINUX_DEFAULT="intel_pstate=active ...
in /etc/default/grub and run sudo update-grub.
I also edited /etc/default/cpupower with :
governor='performance'max_freq="3.2GHz"
but I want the governor to be "powersave" when I'm running on battery, so I've written a script that is run by crontab, with cpupower as setuid root
*/1 * * * * /home/philip/.local/bin/power-adapt > /dev/null 2>&1
The script:
#!/bin/sh # put the governor in powersave mode if it is disconnected from the mains. ACPI=`acpi -a | cut -d ' ' -f 3` if [ "$ACPI" == "off-line" ] ; then cpupower frequency-set -g powersave; else cpupower frequency-set -g performance ; fi
Update
I didn't like the idea of polling every second, so I wrote an udev rule instead:
/etc/udev/rules.d/99-power.rules
ACTION=="change",SUBSYSTEM=="power_supply",RUN+="/usr/bin/bash /home/philip/.local/bin/power-adapt"
Also, when you reboot to battery, the default is "performance", so I added to .i3/config:
# set the right startup power settings
exec --no-startup-id ~/.local/bin/power-adapt