# WARNING: the system temperature is too high, and the system shuts down!



## teo (Sep 13, 2020)

Attempting to update the vulnerable ports detected by the system through recompilation, the fan activity begins to scream, and the temperature begins to rise, automatically shutting down the system. Any solutions?


$ `sysctl -a | grep temperature`

```
hw.acpi.thermal.tz0.temperature: 46,1C
$
```

$ `uname -mrs`

```
FreeBSD 12.1-RELEASE-p9 amd64
$
```


----------



## shkhln (Sep 13, 2020)

_View: https://youtu.be/iQIFF1OVic4?t=216_


----------



## ekvz (Sep 13, 2020)

Generic recommendations: Clean out dust from the ventilation system and maybe replace the thermal paste on your CPU (i guess the sensor in question is related to the CPU?).

Side note: 46,1C doesn't seem to be all that bad but then the practical range pretty much depends on which CPU you are running.


----------



## shkhln (Sep 13, 2020)

ekvz said:


> Side note: 46,1C doesn't seem to be all that bad but then the practical range pretty much depends on which CPU you are running.



This isn't a CPU temp.


----------



## Mjölnir (Sep 13, 2020)

Carefully clean the heat exchanger.  You have to take out the fan if you want to use a hoover, else it can burn through (a fan turns into a generator when you blow into it).


----------



## teo (Sep 13, 2020)

getopt said:


> As you are attributing the problem to vulnerable ports, I'm not sure if you need a hotfix or just a cool answer.



I was trying to update this vulnerable multimedia/gstreamer-ffmpeg port that the system detects, and in the recompilation by the `portupgrade -R` command, it does not complete the task because it automatically turns off the Laptop due to the processing going up to 100% and the high activity of the fan raising the temperature



			
				mjollnir said:
			
		

> Carefully clean the heat exchanger. You have to take out the fan if you want to use a hoover, else it can burn through (a fan turns into a generator when you blow into it).



I cleaned up a few weeks ago back.



			
				ekvz said:
			
		

> Generic recommendations: Clean out dust from the ventilation system and maybe replace the thermal paste on your CPU (i guess the sensor in question is related to the CPU?).
> 
> Side note: 46,1C doesn't seem to be all that bad but then the practical range pretty much depends on which CPU you are running.



46,1C is the temperature of the Laptop without activity, I already cleaned a week ago back,  and replaced the thermal paste.


----------



## ekvz (Sep 13, 2020)

teo said:


> I was trying to update this vulnerable multimedia/gstreamer-ffmpeg port that the system detects, and in the recompilation by the `portupgrade -R` command, it does not complete the task because it automatically turns off the Laptop due to the processing going up to 100% and the high activity of the fan raising the temperature



In this case it comes down to either your cooling system not working in an optimal way (clean it) or the shutdown temperature being unreasonable (be very careful with adjusting this as the CPU can likely get hot enough to basically melt your laptop).


----------



## a6h (Sep 13, 2020)

46 °C is high for HDD, but not for CPU. Also, the normal range of CPU's temperature while it's operating is depends on many factors such as number of cores and manufacturer. I didn't mention clock speed, sensor, fan, etc. because for the most part, you have control over it e.g. `dev.cpu.*.freq` in sysctl.conf.


----------



## kpedersen (Sep 13, 2020)

Is the machine fine during idle?

Perhaps just instruct powerd to keep it at a lower clock speed. It will take longer to compile the ports but it will actually compile the ports rather than shutting down.


----------



## a6h (Sep 13, 2020)

I like to have manual control over CPU clock. This is my procedure. The script part is very amateurish (it's even not a script IMHO!) and you should write a well-though one for yourself. I just wanted to present you the whole shebang.
Personal setting/script for my Intel64:

/boot/loader.conf

```
coretemp_load="YES"
```

/etc/sysctl.conf

```
dev.cpu.0.freq=800
```

cpu.sh

```
#!/bin/sh
case $1 in
22) sysctl dev.cpu.0.freq=2200;;
20) sysctl dev.cpu.0.freq=2000;;
19) sysctl dev.cpu.0.freq=1900;;
18) sysctl dev.cpu.0.freq=1800;;
17) sysctl dev.cpu.0.freq=1700;;
16) sysctl dev.cpu.0.freq=1600;;
15) sysctl dev.cpu.0.freq=1500;;
14) sysctl dev.cpu.0.freq=1400;;
13) sysctl dev.cpu.0.freq=1300;;
12) sysctl dev.cpu.0.freq=1200;;
11) sysctl dev.cpu.0.freq=1100;;
10) sysctl dev.cpu.0.freq=1000;;
9)  sysctl dev.cpu.0.freq=900;;
8)  sysctl dev.cpu.0.freq=800;;
00) echo "22 20 19 18 17 16 15 14 13 12 11 9 8 00 0 _ ";;
0)  sysctl -a | grep temper | awk '{print $2}' | sort -ur;;
esac
sysctl dev.cpu.0.freq
sysctl -a | grep temper | awk '{print $2}' | sort -ur | head -n 1
```


----------



## shkhln (Sep 13, 2020)

teo said:


> 46,1C is the temperature of the Laptop without activity



FYI, the cpu temp is represented by a different sysctl. You don't want to measure it at idle either, frequency scaling makes this completely meaningless.



teo said:


> I already cleaned a week ago back,  and replaced the thermal paste.



If quality of your posts is any indicator, _this_ is probably the culprit.


----------



## teo (Sep 13, 2020)

vigole said:


> I like to have manual control over CPU clock. This is my procedure. The script part is very amateurish (it's even not a script IMHO!) and you should write a well-though one for yourself. I just wanted to present you the whole shebang.
> Personal setting/script for my Intel64:
> 
> /boot/loader.conf
> ...



Thanks for the comments, in those files mentioned I have:

# `vi /boot/loader.conf`

```
kern.vty=vt
snd_hda_load="YES"
snd_driver_load="YES"
fuse_load="YES"
sound_load="YES"
coretemp_load="YES"
```

# `vi /etc/sysctl.conf`

```
net.local.stream.recvspace=65536
net.local.stream.sendspace=65536

kern.ipc.shm_allow_removed=1
vfs.usermount=1
kern.coredump=0
```

The cpu.sh file is that the directory? Or the entire directory to create is /etc/cpu.sh ?


----------



## teo (Sep 13, 2020)

shkhln said:


> FYI, the cpu temp is represented by a different sysctl. You don't want to measure it at idle either, frequency scaling makes this completely meaningless.
> 
> 
> 
> If quality of your posts is any indicator, _this_ is probably the culprit.



That doesn't happen with other systems called Linux or windows installed on this old Laptop. The FreeBSD system just started testing on this old Laptop, and apparently it turns off automatically when you want to recompile a port trying to update raising the resources of the hardware to 100%.


----------



## ekvz (Sep 13, 2020)

teo said:


> That doesn't happen with other systems called Linux or windows installed on this old Laptop. The FreeBSD system just started testing on this old Laptop, and apparently it turns off automatically when you want to recompile a port trying to update raising the resources of the hardware to 100%.



This is not overly surprising as those systems usually just install binary packages (Windows sure doesn't compile anything and source based Linux distributions can easily be counted on one hand). Actually compiling sources is bound to be extremely CPU intensive (there is applications that literally take hours at 100% CPU utilization to compile even on quite decent hardware). The reason for those systems not triggering the shutdown is probably just them not stressing the CPU all that much. I don't know what is responsible for setting the cut off temperature but i guess it actually comes from the BIOS so it would likely be the same across all of those systems.

If you absolutely don't want to investigate the base cause for your system overheating (which quite likely comes down to faulty cooling - if one is to rule out a general design error or wrong cutoff temperature) throttling your CPU as demonstrated by vigole seems like the most reasonable course of action.


----------



## T-Daemon (Sep 13, 2020)

teo said:


> That doesn't happen with other systems called Linux or windows installed on this old Laptop.



Which vendor/model is this laptop?

Not problem related:


teo said:


> I was trying to update this vulnerable multimedia/gstreamer-ffmpeg port that the system detects



Why are you trying to update that port? You asked about vulnerabilities in two ports in Thread 76966, one of them _gstreamer-ffmpeg-0.10.13_7_, but that port hasn't been updated since 7 months, graphics/jasper has. The currently installed package on your system is the same as the port.





						[ports] Index of /head/multimedia/gstreamer-ffmpeg
					






					svnweb.freebsd.org


----------



## shkhln (Sep 13, 2020)

ekvz said:


> Actually compiling sources is bound to be extremely CPU intensive (there is applications that literally take hours at 100% CPU utilization to compile even on quite decent hardware).



In reality compilation is pretty tame. For example, my i5 4670 stays around 55 °C with compilation vs 60 °C with video encoding. Specialized CPU benchmarks (Prime95, etc.) will get it into 70+ °C territory.


----------



## ekvz (Sep 13, 2020)

shkhln said:


> In reality compilation is pretty tame. For example, my i5 4670 stays around 55 °C with compilation vs 60 °C with video encoding. Specialized CPU benchmarks (Prime95, etc.) will get it into 70+ °C territory.



It somewhat depends on the codebase/build system settings (and of course on having a functional cooling system) i guess. Actually the sources i am trying to get to build right now are very good at keeping all cores at a constant 100%. Compiling lot's of small sources files tends to be way less intensive from my experience though.

The box that i am compiling on has been at 100% pretty much for days now (every try to takes about 4h and it seems the code is VERY fragile...). Cores all showing something around 75C. It's not like i've taken much care with this system though so it might be a bit lower if i was to replace the thermal paste but i doubt any kind of benchmark would manage to push the temperature much higher.


----------



## a6h (Sep 13, 2020)

When I build large ports e.g. devel/llvm90 I have temperature problem. In addition to reducing clock/freq, changing `-j` flag in make(1) or `-J` in poudriere-bulk(8) may help.


----------



## teo (Sep 13, 2020)

shkhln said:


> In reality compilation is pretty tame. For example, my i5 4670 stays around 55 °C with compilation vs 60 °C with video encoding. Specialized CPU benchmarks (Prime95, etc.) will get it into 70+ °C territory.



Look at the almost 100% increase of the resource of the Laptop, trying to update the vulnerable multimedia/gstreamer-ffmpeg port on its recompilation, and why the laptop automatically shuts down.


----------



## ekvz (Sep 13, 2020)

I don't know what's the point in posting those screenshots is. It's already been established that your CPU is getting hot. shkhln simply shared his opinion that this shouldn't happen during compilation which i somewhat disagree with. It doesn't really matter anyways as it should not get to the point where your system shuts down. So if you think your cooling is 100% alright or don't want to deal with it any further your only option is to throttle the CPU (or install something that automatically throttles it when it gets to hot).


----------



## a6h (Sep 13, 2020)

Can you reduce your CPU frequency? I think your CPU freq. has set to max, maybe it's working on Turbo Speed. For example an Intel Core i7-2670QM has the max Clockspeed of 2.2 GHz. But it also has the Turbo Speed technology. That means, it's possible that your CPU is working at 3.1 GHz speed. It's going to get very warm soon. It doesn't matter how many cores are engaged at any given time.


----------



## shkhln (Sep 13, 2020)

ekvz said:


> It somewhat depends on the codebase/build system settings (and of course on having a functional cooling system) i guess. Actually the sources i am trying to get to build right now are very good at keeping all cores at a constant 100%.



In my case the difference depends on AVX usage, not all 100% workloads are created equal.



ekvz said:


> It's already been established that your CPU is getting hot. shkhln simply shared his opinion that this shouldn't happen during compilation



No, I just wanted to mention this is not the most effective space heating method.


----------



## shkhln (Sep 13, 2020)

vigole said:


> I think your CPU freq. has set to max, maybe it's working on Turbo Speed. For example an Intel Core i7-2670QM has the max Clockspeed of 2.2 GHz. But it also has the Turbo Speed technology. That means, it's possible that your CPU is working at 3.1 GHz speed. It's going to get very warm soon.



Turbo boost should throttle itself automatically.


----------



## teo (Sep 13, 2020)

vigole said:


> Can you reduce your CPU frequency?


I have no idea, looking at the information you posted, what would be the procedure?



			
				vigole said:
			
		

> I think your CPU freq. has set to max, maybe it's working on Turbo Speed. For example an Intel Core i7-2670QM has the max Clockspeed of 2.2 GHz. But it also has the Turbo Speed technology. That means, it's possible that your CPU is working at 3.1 GHz speed. It's going to get very warm soon. It doesn't matter how many cores are engaged at any given time.


This happens when you try to compile or recompile a port on FreeBSD, for example, when watching video on youtube, the consumption of laptop resources is high. In case there is no solution, with which more powerful CPU would be compatible with the hardware?


----------



## a6h (Sep 13, 2020)

teo I have same problem with both my laptops. I hate laptops! the only way I could managed my situation, very similar to yours (compile, video, etc):
reducing my CPU frequency to *800GHz*. With this setting my CPU temperature is ranging from 40 to 65 in winter. 40 is the lowest I get and only on FreeBSD. Windows and most of Linux distro tend to press more pressure on my CPU. In summer, things are getting more complicated. As you may already guess, I hate summer too!


----------



## judd (Sep 13, 2020)

It's amazing the difference between one hardware and another.


vigole said:


> 40 is the lowest I get and only on FreeBSD



In my case 52 ºC at a room temperature of 17 ºC only xon Xterm open, if you add YouTube it rises to 63 ºC maximum. 



vigole said:


> Linux distro tend to press more pressure on my CPU.



Here it's the opposite, 40 ºC and forcing with Chromium, videos or compiling a file, the maximum 55º C and only the fun/fan starts working as soon as it reaches 49/50 ºC



vigole said:


> I hate summer too!



+1 → I hate summer


----------



## a6h (Sep 13, 2020)

judd I forgot to mention: My windows manager is x11-wm/i3 and it's very low CPU usage. 
On Linux temperature: I didn't test many Linux distros, but as far as I remember Arch Linux was as good as FreeBSD in term of CPU usage and temperature. I guess it has something to do with windows manager. On both of them I had i3 for windows manager and a few light-weight programs, mostly text-based. I should mention that my observations are completely anecdotal.


----------



## ekvz (Sep 13, 2020)

vigole said:


> judd I forgot to mention: My windows manager is x11-wm/i3 and it's very low CPU usage.
> On Linux temperature: I didn't test many Linux distros, but as far as I remember Arch Linux was as good as FreeBSD in term of CPU usage and temperature. I guess it has something to do with windows manager. On both of them I had i3 for windows manager and a few light-weight programs, mostly text-based. I should mention that my observations are completely anecdotal.



I agree, it's mostly about what WM/DE is used. I use Devuan (which is really just Debian without systemd) quite regularly and my setup is basically always idle unless some resource intensive process is involved (youtube and so on). If i was running Gnome/KDE/whatever things would likely look different.


----------



## soongrazer (Sep 14, 2020)

kpedersen said:


> Perhaps just instruct powerd to keep it at a lower clock speed. It will take longer to compile the ports but it will actually compile the ports rather than shutting down.





teo said:


> I have no idea, looking at the information you posted, what would be the procedure?



To control the CPU frequency on a capable hardware, you can use powerd(8).

First, get the supported frequencies at which your CPU can run.
`sysctl -a | grep freq_levels`

On my machine, it returns this.
*dev.cpu.0.freq_levels: 2200/35000 1600/23000 1200/15000*

The frequencies here are 2200, 1600 and 1200.

I can set the maximum frequency to 1200 MHz by this command.
`powerd -M 1200`

You can limit the CPU frequency on boot by running these commands which modifies /etc/rc.conf.
`sysrc powerd_enable=YES
sysrc powerd_flags='-M 1200'`


----------



## Mjölnir (Sep 14, 2020)

vigole said:


> I like to have manual control over CPU clock. This is my procedure. The script part is very amateurish (it's even not a script IMHO!) and you should write a well-though one for yourself. I just wanted to present you the whole shebang.
> Personal setting/script for my Intel64:
> 
> /boot/loader.conf
> ...


In general, kernel modules not needed to boot the system should be loaded via rc.conf(5)'s `kld_list`, and not in loader.conf(8).  Some modules refuse to be loaded after boot, but this one does load fine: `sysrc kld_list+=" coretemp"`
Why don't you let powerd(8) do the frequency scaling?


----------



## a6h (Sep 14, 2020)

mjollnir said:


> Why don't you let powerd(8) do the frequency scaling?


I've performed A/B test on powerd(8) and sysctl.conf(5). The powerd(8) provides good optimisation, but even when I set its flags/options to `-a minimum` or `-f 800` I don't get a steady 800 GHz CPU frequency. When CPU works harder, frequency goes higher (of course not to the max). When I add `dev.cpu.0.freq=800` to the sysctl.conf(5), or execute it manually in the terminal `sysctl dev.cpu.0.freq=800` I get an exact 800 GHz frequency regardless of the CPU usage. I know it is inefficient but I have no choice but to steak to lowest frequency. Because any frequency, more than [800, 1200] GHZ causes [75, ∞) degrees CPU overheat!


----------



## ekvz (Sep 14, 2020)

vigole said:


> CPU overheat (75, ∞) degrees!



Wasn't there some old Pentium/Celeron CPUs at some point where 100C was still within an acceptable range and actually seeing those temperatures wasn't even that uncommon? Not saying that would be something i'd tolerate in a laptop. My X220 gets hot enough as is and it's CPU won't even go near 100C. The idea of having a laptop sitting on my lap with it's CPU running at 100C doesn't seem all that comfortable.


----------



## Mjölnir (Sep 14, 2020)

I have `sysrc -e powerd_flags`: `powerd_flags="-a adp -n adp -i 70 -r 95"` and that's doing fine...  In my /etc/csh.alias:

```
alias freq      sysctl dev.cpu.{{0,1,2,3}.cx_usage,0.freq}
alias temp      sysctl hw.acpi.thermal.tz0.temperature dev.cpu.{0,1,2,3}.temperature
```
EDIT The latter requires the coretemp(4) kernel module: `kldload coretemp` & `sysrc kld_list+=" coretemp"`
You could set `sysctl hw.acpi.thermal.user_override` and lower the thermal setpoints.  Maybe `echo hw.acpi.thermal.tz0.passive_cooling=\"1\" >>/boot/loader.conf` is needed for that to work.  RTFM acpi_thermal(4).


----------



## a6h (Sep 14, 2020)

mjollnir said:


> You could set  sysctl hw.acpi.thermal.user_override and lower the thermal setpoints. Maybe  echo hw.acpi.thermal.tz0.passive_cooling=\"1\" >>/boot/loader.conf is needed for that to work. RTFM acpi_thermal(4).


Thanks mjollnir I will try it.



ekvz said:


> Wasn't there some old Pentium/Celeron CPUs at some point where 100C was still within an acceptable range and actually seeing those temperatures wasn't even that uncommon?


I remember, Celeron was working at very high temperature. I saw laptops (Intel CPU), constantly working at 70-80 range for many years, and they are still doing fine. I'm too cautious to operate laptops! Frankly I decided to go back to PC (regular desktop).

I saw peculiar articles on the internet, talking about 30-40 degrees. They are all bogus IMHO! Even in the idle state. Intel CPUs have high tolerance to the high temperature. There's good information on _thermal monitoring and protection_, on intel site: refer to Vol. 3B / Section 14.8 of Intel arch/dev manual:









						Intel® 64 and IA-32 Architectures Developer's Manual: Vol. 3B
					

Architectures Software Developer's Manual: Intel® 64 and IA-32, Vols 3A and 3B: Appendices and Indexing Support.




					www.intel.com
				





14.8.1 Catastrophic Shutdown Detector:
P6 family processors introduced a thermal sensor that acts as a catastrophic shutdown detector. [...] When processor core temperature reaches a factory preset level, the sensor trips and processor execution is halted until after the next reset cycle.
14.8.5.2 Reading the Digital Sensor:
When Critical Temperature Status bit is set, the processor is operating at a critical temperature and immediate shutdown of the system should occur.


----------



## teo (Sep 14, 2020)

Nathan Whoa said:


> To control the CPU frequency on a capable hardware, you can use powerd(8).
> 
> First, get the supported frequencies at which your CPU can run.
> `sysctl -a | grep freq_levels`
> ...



Hello  Nathan Whoa

Can you help me set a frequency and not burn out the CPU? Following what you say, the output frequency is:

$ sysctl -a | grep freq_levels

```
dev.cpu.0.freq_levels: 2534/25000 2533/25000 2399/23390 2266/21835 2133/20334 1999/18817 1866/17351 1733/15937 1599/14528 1466/13163 1333/11835 1199/10512
```
$


			
				vogole said:
			
		

> Intel CPUs have high tolerance to the high temperature.



Not so, you see how tolerant this CPU is from Intel and it goes up when it tries to compile at 100% automatically turning off the laptop without finishing the task, I think the ones with tolerance are the AMD Ryzen CPUs.


----------



## richardtoohey2 (Sep 14, 2020)

teo said:


> Not so, you see how tolerant this CPU is from Intel and it goes up when it tries to compile at 100% automatically turning off the laptop without finishing the task, I think the ones with tolerance are the AMD Ryzen CPUs.


I think there may still be a cooling issue with your hardware/CPU (from the start of this thread).

You might not be triggering the behaviour in Linux/Windows because you aren't pushing the CPU as hard with them as you have been with FreeBSD, or perhaps they have more aggressive default throttling to keep temperatures down - and what you are doing with the frequencies will help.

Or yes, there might be a FreeBSD bug.

If you can find something that accurately reports the actual CPU temperature (IPMI?) could you set that to log to a file every second (IPMI might be a bit too sluggish for that) and then try and port build into another console and see what sort of temperatures you are getting?  You might encounter issues of the file not being updated fast enough (i.e. still buffered) if the shutdown happens quickly, but it might give some indications.  I think your previous measurements have been more the ambient/case temperature rather than the CPU.

I've not encountered many thermal issues but when I have it's been down to cooling (lack of) or something I've missed.


----------



## teo (Sep 15, 2020)

richardtoohey2 said:


> I think there may still be a cooling issue with your hardware/CPU (from the start of this thread).
> 
> You might not be triggering the behaviour in Linux/Windows because you aren't pushing the CPU as hard with them as you have been with FreeBSD, or perhaps they have more aggressive default throttling to keep temperatures down - and what you are doing with the frequencies will help.
> 
> ...


The previous publications visualize the temperature outputs of both a CPU with no compiling activity and a CPU with compiling activity. I was amazed to see the temperature rise almost 100% while compiling and the reason why the laptop was automatically turned off. If I am not wrong, the frequency in FreeBSD is said to   used the maxime, which does not happen the same with linux or windows.


----------



## richardtoohey2 (Sep 15, 2020)

Ah, yes, sorry, I skimmed past the screenshots - was looking in the text.   Just under 100 deg C is rather toasty.

Hopefully the frequency tuning helps (and matches what Linux & Windows are doing to prevent thermal overload).

And maybe you are right to point the finger at Intel  Thought it was their performance-over-security causing issues these days but maybe also too reliant on the OS to handle load-versus-heat? That still seems a bit _odd_. But then the Raspberry Pi 4 can get itself in quite a bit of trouble with heat, too, but that's definitely going off-topic.


----------



## Phishfry (Sep 15, 2020)

There is an alternative to powerd in the ports tree.
sysutils/powerdxx


----------



## soongrazer (Sep 16, 2020)

teo said:


> Can you help me set a frequency and not burn out the CPU? Following what you say, the output frequency is:
> 
> $ sysctl -a | grep freq_levels
> 
> ...



It’s preferable to set the highest frequency at which the CPU can run without shutting down. Try setting the lowest first with the command.
`powerd -M 1199 -v`
Hit control-C to stop powerd(8).

You can run powerd(8) as a daemon if you want to. Just remove *-v* option.
`powerd -M 1199`
To try with a new frequency, kill the running powerd(8) first.

When powerd(8) is running, compile your port and check the temperature.

You can experiment with higher frequency values or you can set the lowest frequency if you are happy with it despite it taking longer time to compile your port. See if it goes to shut down.

When you get the desired frequency, you can set powerd(8) to run automatically at boot. Set the appropriate frequency there.


Nathan Whoa said:


> You can limit the CPU frequency on boot by running these commands which modifies /etc/rc.conf.
> `sysrc powerd_enable=YES
> sysrc powerd_flags='-M 1200'`



And then reboot.

I hope it will work. I have lenovo B450 and it is more than 7 years old. The thermal pads are old and some of them are gone. So I run it with the minimum frequency and it is cool at 50°C-70°C. It’s slow but usable.


----------

