This daemon sets the cpufreq scale_max_freq setting and scales it down when the CPU reaches a given temperature.
I recently bought a new mainboard, an Asrock J5040-ITX.
This board has a passively cooled CPU which means heat can build up when you
give it a GPU or CPU intensive task. It will happily heat itself up to over
95°C, and since i'm a Gentoo user, that happens quite a lot :-). I thought
it's wasn't a good idea to leave it running for hours at 95°C. One
solution could be to add a small fan, but I hate fans and that's why i got a
fanless mainboard in the first place. The other solution is to reduce CPU heat
generation when the temperature is too high, and the best way to do that is to
reduce it's frequency as can be done with cpufreq within linux.
When discovered there is no program to do that i deciced to write it myself.
It's basic function is simple: It reads the CPU's temperature sensor and if the temperature is above a certain threshold it will lower scale_max_freq to lower the CPU speed and allow it to cool down. When the temperature drops below the threshold it will increase scalea_max_freq again to allow it to reach it's full speed.
There is a lot you can tune and do with this basic function, these are the options you can pass to cputemp2maxfreq:
To use the CSV file with libreOffice first stop the daemon to make sure all data has been written. Then use LibreOffice Calc to open the CSV file. In the text import dialog use the following options:
The preview should already show a nicely formed table, so click Ok.
If the document is opened read-only, click the Edit Document button. Select the whole sheet, open the Insert menu and choose Chart...
Now select Chart Type XY (Scatter) and subtype Lines Only and click Finish.
You should now have a graph and depending on the number of data points it might beusefull to make it wider to give the graph some more space. Becaue the CPU temperatures are much lower numbers than the frequencies it's useful to add a second Y axis, to do so click on the background and choose Insert/Delete axes and enable the secondary Y axis. Now click the first temperature line (usually at the bottom of the chart) and choose Format Data Series, and set Allign Data Series to Secondary Y axis. Do the same for the second temperature line.
The resulting graph should look like this:
You can clearly see the scaling this daemon does between 12:37:26 and 12:40:19.
Since i'm a Gentoo user i made an ebuild provided in the gentoo directory of the source code. Place it in your own overlay to use it, the suggested category is sys-power. The ebuild will install the binary in /usr/sbin and install an initscript so you can start the daemon on boot.
To install from source manually the best way is to git clone https://code.pa4wdh.nl.eu.org/tools/cputemp2maxfreq. Change to the source directory and type make to start the build proces. It shouldn't take long since this is a very small program. The result should be an executable called cputemp2maxfreq.
The daemon has two uses: Get the maximum performance from your CPU when the temperature allows it, and protect the hardware from overheating.
Since i'm a Gentoo user there is a topic about this program on thei Gentoo forums.
Happy computing!