# Thermal Management Issues with Laptop (Toshiba Satellite C650d)



## zennybsd (Mar 15, 2012)

Hi:

I see some 15 degrees of difference of CPU temperature between FreeBSD9 and Debian GNU/Linux with the same hardware (Toshiba Satellite C650d). 

GNU/Linux usually shows (with cpufreq utils) 40-50 degrees cel*s*ius whereas FreeBSD9 shows at least 54-63 degrees of cel*s*ius when starting up. At this point of writing it is showing 55.5 degrees cel*s*ius.

The CPU is with amdtemp enabled:


```
# dmesg | grep CPU
CPU: AMD Athlon(tm) II P320 Dual-Core Processor (2094.87-MHz K8-class CPU)
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
cpu0: <ACPI CPU> on acpi0
cpu1: <ACPI CPU> on acpi0
SMP: AP CPU #1 Launched!
amdtemp0: <AMD CPU On-Die Thermal Sensors> on hostb4
```

Added to /boot/loader.conf, the following:


```
#for laptop power manangement
amdtemp_load="YES"
hint.p4tcc.0.disabled=1
hint.acpi_throttle.0.disabled=1
#for reduction of power by sound device
hint.pcm.0.buffersize=65536
hint.pcm.1.buffersize=65536
hw.snd.feeder_buffersize=65536
hw.snd.latency=7
```

/etc/rc.conf has:


```
#for laptop power management
powerd_enable="YES"
powerd_flags="-i 85 -r 60 -p 100"
performance_cx_lowest="C2"
economy_cx_lowest="C2"
```

What else can I do or where do I look up further to bring down the temperature? I feel thermal management is pretty important in any OS (both for lengthening the life of physical hardware and green technology).

Update: Tried with loading acpi_toshiba kernel module, neither it brings down the temperature nor it allows the toshiba keyboard combinations (with Fn + Fx where x is 1-12) works as stated in the acpi_toshiba(4) man pages!


----------



## bbzz (Mar 15, 2012)

acpi_toshiba(4)

Use fan control to force fan speed if all else fails.


----------



## zennybsd (Mar 15, 2012)

*Nope, acpi_toshiba didn't work!*

Loaded the acpi_toshiba module, but it does not seem to affect anything including keyboard combinations of Toshiba laptops. 

The acpi_toshiba(4) man pages seems to be only for FreeBSD 8.2, may not apply for FreeBSD 9-RELEASE, I guess, but not sure! ;-)


----------



## zennybsd (Mar 17, 2012)

*some more inputs about the problem*

[CMD="sysctl -vm l"]sysctl -vm l[/CMD]
outputs:


```
1 users    Load  0.40  0.17  0.05                  Mar 17 15:48

Mem:KB    REAL            VIRTUAL                       VN PAGER   SWAP PAGER
        Tot   Share      Tot    Share    Free           in   out     in   out
Act  783020   18568  3258736    23152 1551644  count
All  877528   19892 1077075k    37104          pages
Proc:                                                            Interrupts
  r   p   d   s   w   Csw  Trp  Sys  Int  Sof  Flt        cow     682 total
            103      3004  976  11k   46  428   10      1 zfod        atkbd0 1
                                                          ozfod       psm0 12
 2.3%Sys   0.1%Intr 12.2%User  0.0%Nice 85.5%Idle        %ozfod    41 hdac0 ath0
|    |    |    |    |    |    |    |    |    |    |       daefr     3 ehci0 ehci
=>>>>>>                                                   prcfr       ohci0 ohci
                                           dtbuf          totfr   365 cpu0:timer
Namei     Name-cache   Dir-cache    123248 desvn          react     2 ahci0 257
   Calls    hits   %    hits   %     55755 numvn          pdwak   271 cpu1:timer
      44      44 100                 30811 frevn          pdpgs
                                                          intrn
Disks  ada0   da0   cd0 pass0 pass1 pass2          294116 wire
KB/t   0.00  0.00  0.00  0.00  0.00  0.00          421584 act
tps       0     0     0     0     1     0          506892 inact
MB/s   0.00  0.00  0.00  0.00  0.00  0.00            5464 cache
%busy     0     0     0     0     0     0         1546180 free
                                                   295904 buf
```

[CMD="vmstat -i"]vmstat -i[/CMD]
outputs:


```
interrupt                          total       rate
irq1: atkbd0                        9948          1
irq12: psm0                        58539          9
irq16: hdac0 ath0                 197395         30
irq17: ehci0 ehci1+                25661          3
irq18: ohci0 ohci1+                    2          0
cpu0:timer                       2025760        313
irq257: ahci0                      49724          7
cpu1:timer                       1163138        180
Total                            3530167        546
```

[CMD="uptime"]uptime[/CMD]
outputs:


```
3:51PM  up  1:49, 1 user, load averages: 0.09, 0.11, 0.04
```

Right at the average temperature is 57 degrees which is about 10 degrees higher than what GNU/Linux reports with much higher workload.

Hopefully this info helps to debug. Thanks!


----------



## zennybsd (Apr 10, 2012)

Bump! I still could not figure out to lower the temperature of my processors and all time spinning noisy fan of my laptop. 

As I stated earlier, the temperature difference between GNU/Linux and FreeBSD9-RELEASE is about 10 degrees celcius with more load in linux for additional processes it starts (like GDM, libvirt, proxies and a lot of other processes in GNU/Linux, but FreeBSD9 is without any display manager, no additional processes added at runtime).

Any hints? Thanks!


----------



## mav@ (Apr 13, 2012)

Your *systat* output shows that CPU is not idle and has a lot of interrupts. You should check what they are.

Also try switching to different eventtimers(4) driver during boot (HPET preferably). LAPIC ever used since boot blocks C1E states for AMD CPUs. C2/C3 states are not accessible directly for AMD CPUs, but only through the C1E mechanism.


----------



## ring_zero (Apr 14, 2012)

mav@ said:
			
		

> Your *systat* output shows that CPU is not idle and has a lot of interrupts. You should check what they are.
> 
> Also try switching to different eventtimer(4) driver during boot (HPET preferably). LAPIC ever used since boot blocks C1E states for AMD CPUs. C2/C3 states are not accessible directly for AMD CPUs, but only through the C1E mechanism.



How does one switch the event timer?  I have googled my butt off and cannot find an answer. I tried setting it via `sysctl` but no luck.


----------



## mav@ (Apr 14, 2012)

To prevent C1E disabled on AMD CPUs you should set it at boot time by setting kern.eventtimer.timer variable during boot to "HPET" value if your system supports it.


----------



## ring_zero (Apr 14, 2012)

mav@ said:
			
		

> To prevent C1E disabled on AMD CPUs you should set it at boot time by setting kern.eventtimer.timer variable during boot to "HPET" value if your system supports it.



I receive the following error 
	
	



```
/etc/rc: WARNING: unable to set kern.eventtimer.timer=HPET
```
I am guessing that this means HPET is unsupported for me.  I have been looking through the ACPI Mailing List, and I have found your handle attached to quite a few messages dealing with this, so I would like to ask you, a few questions if I may.  Following one of your suggestions, I added the following to loader.conf:
	
	



```
hint.apic.0.clock="0"
```
 Doing so did allow me to use another timer, i8254.  Will using this timer allow the use of C1E, or am I still where I started?  I added a few more items to loader.conf: 
	
	



```
hint.p4tcc.0.disabled="1"
hint.acpi_throttle.0.disabled="1"
kern.hz="100"
```
 following the suggestions detailed here. This has allowed me to lower the core temp from 62 cels to around 54 cels at the lowest, although the machine really never gets that low while in use.  The fan still runs all of the time.  Is there any more that I can do, or have I hit the wall, so to speak?  
If this will help:
`uptime`

```
1:16PM  up 17 mins, 1 user, load averages: 0.39, 0.34, 0.26
```
`vmstat -i`

```
interrupt                          total       rate
irq1: atkbd0                        5425          5
irq0: attimer0                    426870        397
irq12: psm0                       108114        100
irq16: hdac0 ath0                  27369         25
irq17: ehci0 ehci1+                 7274          6
irq18: ohci0 ohci1+                    3          0
irq257: ahci0                      14767         13
Total                             589822        548
```
`systat -vm 1`

```
1 users    Load  0.33  0.31  0.25                  Apr 14 13:19

Mem:KB    REAL            VIRTUAL                       VN PAGER   SWAP PAGER
        Tot   Share      Tot    Share    Free           in   out     in   out
Act  516152   50528  3514608    70740 7032112  count
All  736520   60200 1077374k    98708          pages
Proc:                                                            Interrupts
  r   p   d   s   w   Csw  Trp  Sys  Int  Sof  Flt        cow     488 total
            105      1888  411  15k  487  149   17     11 zfod      5 atkbd0 1
                                                          ozfod   401 attimer0 0
 1.5%Sys   0.0%Intr  1.5%User  0.7%Nice 96.3%Idle        %ozfod     2 psm0 12
|    |    |    |    |    |    |    |    |    |    |       daefr    20 hdac0 ath0
=-                                                      2 prcfr    13 ehci0 ehci
                                        10 dtbuf       85 totfr       ohci0 ohci
Namei     Name-cache   Dir-cache    202584 desvn          react    47 ahci0 257
   Calls    hits   %    hits   %      3156 numvn          pdwak
       7       7 100                  1190 frevn          pdpgs
                                                          intrn
Disks  ada0   da0   da1   cd0 pass0 pass1 pass2    318496 wire
KB/t   5.24  0.00  0.00  0.00  0.00  0.00  0.00    294492 act
tps      45     0     0     0     0     0     1    206560 inact
MB/s   0.23  0.00  0.00  0.00  0.00  0.00  0.00      4612 cache
%busy     1     0     0     0     0     0     0   7027500 free
```
 Tuning ACPI on FreeBSD is still rather new to me, so any help here would be greatly appreciated.


----------



## SocialHaze (Apr 15, 2012)

A shot in the dark but could you set your minimums in powerd?

You can use dev.cpu.freq_levels to gather the stepping for your CPU.  Running powerd in verbose mode will also tell you if your CPU is simply not throttling down enough or if there's something else going on.

I'd also get rid of the hints and other hardware parameter settings for troubleshooting purposes.


----------



## ring_zero (Apr 15, 2012)

Sceak said:
			
		

> A shot in the dark but could you set your minimums in powerd?
> 
> You can use dev.cpu.freq_levels to gather the stepping for your CPU.  Running powerd in verbose mode will also tell you if your CPU is simply not throttling down enough or if there's something else going on.
> 
> I'd also get rid of the hints and other hardware parameter settings for troubleshooting purposes.



I have set the following for powerd  in etc/rc.conf

```
powerd_flags="-a adaptive -b adaptive -i 85 -r 60 -p 100 "
```
 The CPU scales, and the temp adjusts accordinly, i.e at 800 MHz (lowest freq) temp hovers around 54 C, go up to 2200 MHz (highest freq), and temp rises to 68 C.  Running GNU/Linux I was seeing idle temps of around 41 C at 800 MHz, and high fifties at full power.  I am unable to adjust the C states with this processor as it uses C1E, and there are no options in the BIOS to adjust this.  Currently I am researching modifying the BIOS to unlock menus that may or may not allow access to this. As this is a production machine, I am leaning toward leaving it alone, as I almost never have it on my lap, and even 68 C is not that high at full load.  As an aside 
	
	



```
hint.p4tcc.0.disabled="1"
```
 actually isn't doing anything as this is not an Intel machine.  I am curious as to why I cannot use the HPET timer though.  I dumped my ASLs and saw references to HPET in there. I am also having quite a bit of difficulty finding anything detailed about eventtimer(4), there is no man page that I can find and I have not seen any references to it in the handbook.


----------



## ring_zero (Apr 15, 2012)

I will pass.  I am going back to the APIC timer.  The i8254 timer caused the machine to come out of suspend really slowly, and I noticed that the temperature was pretty low after waking up.  So I ran the command `sysctl -a | grep temp`, and got the following output:
	
	



```
hw.acpi.thermal.tz0.temperature: 56.0C
dev.cpu.0.temperature: 49.0C
dev.cpu.1.temperature: 49.0C
dev.amdtemp.0.%desc: AMD CPU On-Die Thermal Sensors
dev.amdtemp.0.%driver: amdtemp
dev.amdtemp.0.%parent: hostb4
dev.amdtemp.0.sensor0.core0: 49.0C
```
 Not sure why the on die temps are around seven degrees cooler on average than the hw.acpi.thermal.tz0.temperature oid, I wonder if this is reporting ambient temp.  The fan is not loud enough to be bothersome, and the system is stable, so I am going to call this one quits.


----------



## wblock@ (Apr 15, 2012)

In 9.0-RELEASE, it was eventtimers(7), moving to eventtimers(4) in 9-STABLE.


----------



## ring_zero (Apr 16, 2012)

Fascinating.  I took the machine apart, and reapplied thermal compound to the CPU and Northbridge, and now I am reporting temperatures in the low forties.  The compound wasn't even applied correctly by the manufacturer.  This begs the question, "Do they design them to fail?"  If you have the requisite skill I seriously recommend checking this.
	
	



```
hw.acpi.thermal.tz0.temperature: 47.0C
dev.cpu.0.temperature: 41.0C
dev.cpu.1.temperature: 41.0C
dev.amdtemp.0.%desc: AMD CPU On-Die Thermal Sensors
dev.amdtemp.0.%driver: amdtemp
dev.amdtemp.0.%parent: hostb4
dev.amdtemp.0.sensor0.core0: 41.0C
```
 This is much better than the 50-60 that I was reporting. Bonus: I even managed to do this without missing screws or left over parts this time!


----------



## CalvinZA (Apr 21, 2012)

I am running FreeBSD 9.0 on an Intel desktop as well as an Intel Toshiba satellite pro, obviously power saving, especially for heat management, is more of a concern for us mobile users.

I have powerd running with "low" flag set for AC power, however my greatest reduction in heat resulted from forcing my GPU to clock down permanently whilst in Xorg.  If you're packing an ATI/AMD Radeon discreet graphics processor then you may configure this in /etc/X11/xorg.conf, adding the following code where appropriate 

```
Option "ForceLowPowerMode" "true"
```
Note I am using radeonhd  as my driver due to problems with the radeon driver with power saving enabled.

Then lastly, I have not tried this for myself yet, this could also help you reduce the heat being generated by your system: wiki.freebsd.org/TuningPowerConsumption


----------

