Linux Kernel To Get CPU Idle Cooling Solution
CPUs and system on a chip devices heat up under load. That is a non-issue if you are cooling a desktop computer with liquid nitrogen but it is a problem in space-constrained scenarios. Daniel Lezcano from Linaro has submitted a rather interesting "cooling device" CPU governor to the Linux Kernel Mailing List. It's functionality is as simple as it is beautiful: It will inject CPU idle cycles until the temperature goes down when CPU temperature is above a set threshold.
published 2019-12-05 - last edited 2020-01-04
A red LED fan with neither make the system run hotter or faster.
It is already possible to "cool" (prevent heat build-up) central processing units by limiting their frequency. The new "CPU Cooling Device" patch-set by Linaro employed kernel developer Daniel Lezcano goes beyond that. It proposes two new kernel configurations option called CPU_THERMAL
and CPU_FREQ_THERMAL
which are described in the proposed help-text as:
CPU_THERMAL
: Enable the CPU cooling features. If the system has no active cooling device available, this option allows to use the CPU as a cooling device.CPU_FREQ_THERMAL
: This implements the generic cpu cooling mechanism through frequency reduction. An ACPI version of this already exists. This will be useful for platforms using the generic thermal interface and not the ACPI interface.
The patch-set is accompanied by proposed documentation which describes the "idle injection cooling effect
":
"The base concept of the idle injection is to force the CPU to go to an idle state for a specified time each control cycle, it provides another way to control CPU power and heat in addition to cpufreq. Ideally, if all CPUs belonging to the same cluster, inject their idle cycles synchronously, the cluster can reach its power down state with a minimum power consumption and reduce the static leakage to almost zero. However, these idle cycles injection will add extra latencies as the CPUs will have to wakeup from a deep sleep state.
We use a fixed duration of idle injection that gives an acceptable performance penalty and a fixed latency. Mitigation can be increased or decreased by modulating the duty cycle of the idle injection."
cpu-idle-cooling.rst
documentation for the new CPU Idle Cooling FeatureThe proposed documentation has ascii charts and equations like Power = Capacitance x Voltage^2 x Frequency x Utilisation
.
Cell phones and embedded devices appear to be the target audiences for this CPU scaling governor. The potential applications do go beyond that: A fan-less desktop or HTPC computer using a standard CPU which would otherwise require active cooling seems like an obvious use-case.
Note: The proposed CPU idle patch-set was first submitted early November. It was submitted again on December 3rd, 2019. Linus Torvalds has not merged it into the mainline kernel git tree. It is therefore not clear that this will make it into Linux Kernel 5.5 or any other kernel for that matter. It is a interesting and useful patch-set so it is more likely than not that it will get merged into the mainline kernel at some point. |
The entire CPU idle injection patch-set can be found in a e-mail thread mirrored on LKML.org with the title "PATCH V3 3/4 thermal/drivers/cpu_cooling: Introduce the cpu idle cooling driver".
A Currently Working Solution For A Quiet Fanless PC While We Wait For The CPU Idle Patch-Set To Be Merged[edit]
Those who would like to use a modern off-the-shelf CPU to build a quiet fan-less computer do have one option which does not involve injecting CPU idle cycles: CPU frequency tuning. CPUs run hotter the higher their frequency is at. They will also run faster which is why they increase their frequency under load.
A CPU which is locked at a lower frequency will run slower and cooler. Not as cool as a CPU which has idle cycled injected into it but cool enough to be used with a larger passive heatsink. A CPU with a 65W TDP running at its lower frequencies is easily cooled by a grossly oversized cooler with a TDP of 140W even if the cooler's fan is disabled. It is already quite easy to set this up under Linux. What you need to set this up is the cpupower
program from the kernel-tools
package. It provides a systemd service file called cpupower.service
which can be used to configure the kernel's CPU governor.
First, check what frequencies you can use by running
cpupower frequency-info
which will output something like:
Pstate-P0: 3400MHz Pstate-P1: 2800MHz Pstate-P2: 1550MHz
CPUs will allow you to use frequencies between the P-states but not frequencies outside of the lowest and highest state. It is, with the above example output, possible to lock the CPU to frequencies between 1550 and 2000 MHz to prevent it from getting anywhere near hot - ever (if you have a larger heatsink).
cpupower
allows you to configure the kernel's scaling governor and its scaling frequencies with the frequency-set
option. -g
will let you configure a CPU governor. -d
and -u
lets you specify a minimum and a maximum frequency.
The kernel's sysfs can tell you what governors and frequencies are available:
# cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_governors conservative userspace powersave ondemand performance schedutil # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies 3400000 2800000 1550000
Note: While CPU power will output something like 1550MHz, its -d option needs this set as a full number i.e 1550000
|
The following fine command will set the CPU governor to conservative
which slowly adjusts the CPU frequency up and down and limit the CPU frequency to a range between 1550MHz and 2000MHz:
cpupower frequency-set -g conservative -d 1550000 -u 2000000
It is possible to verify that a new CPU governor and frequency settings are applied by poking in /sys:
# cat /sys/devices/system/cpu/cpufreq/policy0/scaling_governor conservative # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq 2000000 # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq 1550000
It is possible to apply cpupower
settings each boot by adding options to /etc/sysconfig/cpupower
and enabling the systemd cpupower.service
file with systemctl enable cpupower.service
Computers like a HTPCs, which only need to be fast enough to decode and play videos, can benefit from such a setup.
TIP: The fancontrol service lm_sensors can be used to configure a GNU/Linux machine's fan speed. It can be configured to leave a CPU heatsink's fan as well as case fans off unless they are actually needed. It may be a good idea to have fans available in case they are needed as well as something which turns them on automatically even if they are off most of the time.
|
Enable comment auto-refresher