# Automatically throttle CPU frequency on high core temperatures?



## GxyNva (May 5, 2022)

I don't usually have my CPU on 100% load for extended periods of time, but I've been recently getting into mining monero and so have been running my FreeBSD machine overnight while the mining software maxes out the CPU usage. I was pretty surprised when I woke up to the computer having shut itself down because of the high temperature since I have a pretty decent cooler and plenty of ventilation in my computer case.

How can I get FreeBSD to automatically throttle down the CPU frequency when it gets too hot as to prevent crashing? Linux and Windows both have this feature and I think it's pretty crucial to prevent long term damage to the CPU.


----------



## sko (May 5, 2022)

AFAIK this is usually handled by the CPU/firmware itself at least on halfway recent Intel CPUs (i.e. from the last ~10 years or even longer). You can even check the number of throttling events via the dev.cpu.[N].coretemp.throttle_log sysctl. (of course, the coretemp module has to be loaded for this those sysctls to show up)
Actually I haven't seen a thermally caused shutdown or forced power-off with intel hardware for many years now. Even with a completely detached cooler, due to 3 out of 4 plastic pins being snapped off, on a skylake xeon the system still chugged along - horribly slow and throwing alarms everywhere, but still up and (somewhat) running and still a good few degrees under its rated tjmax.

A complete shutdown usually only occurs when reaching the threshold for unrecoverable critical temperature (mostly set to tjmax).
For server hardware this is usually controlled by the BMC and can be read/set with sysutils/ipmitool - for desktop hardware you have to deal with what weird or broken UEFI/BIOS implementation (and often crappy UI) the vendor has shipped with your board and hope they have included some settings for thermal events.


----------



## Styrsven (May 5, 2022)

I use sysutils/powerdxx on a Ryzen 3900x with this:

```
powerdxx_enable="YES"
powerdxx_flags="-n adaptive -a hiadaptive -b adaptive -H 75C:80C"
```
in rc.conf
It never exceeds 75.1C even when running at 100% load for a long time.


----------



## GxyNva (May 6, 2022)

Styrsven Thank you! This was exactly what I was looking for!


----------

