I recently switched to using an LG Gram laptop. Current Linux kernels have a bug with this series of laptops, which cause the CPU load to spike when a USB-C device is attached, which includes the power supply. The CPU load spike in turn overheats the CPU, maxes out the fan, and reduces battery life. Apparently a fix is expected from the mainline kernel soon, but in the meantime, I needed a way of mitigating it.
The answer is to disable Intel's Turbo Boost technology. This is enabled by default in Ubuntu. When it's disabled, although the kernel bug is still present and CPU runs at much higher load than it should, at least it doesn't overheat or run the fan constantly.
To temporarily disable Turbo Boost, simply run
sudo -E bash echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
Unfortunately this change doesn't persist across reboots, and unlike changes in
/proc, it can't easily be managed with
sysctl.conf either. However, it can be managed using SystemD. Simply create the file
/etc/tmpfiles.d/noturbo.conf (as root) and put in the following contents:
# Path Mode UID GID Age Argument w /sys/devices/system/cpu/intel_pstate/no_turbo - - - - 1
Turbo Boost should then remain turned off even after you reboot.
Thank you, it worked very well on a Lenovo Legion Y520 with Ubuntu 22.04.3, when playing some games the laptop overheat, since disabled TurboBoost no longer get that high temps