# enable C3 and/or use powerd in FreeBSD 11.2?



## romanaOne (Aug 3, 2018)

Are you not supposed to use powerd if you have enabled C3 state?

```
sysctl hw.acpi.cpu.cx_lowest=C3
```

There is no mention of C-states in the powerd() manpage. There is also a cpu scaling and power saving HOWTO in the forums which says that powerd with C3 enabled might even use more power (post #46), but the thread is very old.

The TuningPowerConsumption wiki seems to imply you should either enable C3 OR leave hw.acpi.cpu.cx_lowest=C2 and use powerd. :


> Result of effective C3 state usage, comparing to C2+powerd, is about 2W.



Is this outdated or specific to FreeBSD 8.X?  Do I not need powerd if C3 is enabled?

`powerd  -a adaptive -b min` is running and I enabled C3. Err, well... nothing bad happened but I don't have a good way to measure power directly; just listening for annoying fan and looking at temperature sensor sysctls.   This is on a laptop with  i7-6700HQ processor and HD530 graphics.


----------



## k.jacker (Aug 4, 2018)

Yes, you need powerd as well.
You defined C3 as lowest C-state which then is handled by the CPU itself what parts to turn of in different idle situations.
/sbin/powerd handles frequency scaling (p-states) of the CPU. Higher CPU temperatures are the result of extensive use of high frequencies through aggressive freqency scaling (e.g. running powerd -a/b hiadaptive) and even more from what Intel calls Turbo Boost. Turbo Boost will allways apply the highest possible frequency (as long as tmax isn’t reached, usually 100-105C) and even go far beyond the specified TDP of the CPU. Even short tasks like starting your browser, can produce massive amounts of heat. That‘s even more the case for top of the line CPUs. That’s why I use to disable Turbo Boost on laptops.

Running `powerd -b min` does the right thing, but isn’t optimal. For sure, very little heat is produced, but task take very long time to get done. The sweatspot between heat output and performance for every CPU is somewhere im the middle between idle (800MHz mostly) and the base frequency (highest freq without Turbo Boost applied).

It‘s usually a good thing to just disable Turbo Boost, as everything above the base frequency, produces just unnecessary amounts of heat for a performance gain not worth it (on a laptop, which by nature has no room for a sufficient cooling solution).

That is because high voltages need to be applied to the CPU to make it reach such high frequencies. Even more on a mobile CPU, where the temperature rises up to 90C easily.
The heat can make the CPU become unstable, so even higher voltages have to be applied to make the CPU run stable. which then.... yes, produce more heat and even higher temperatures in turn.

That must have been the longest text I‘ve ever written on my phone.
Cheers
The pinmodder


----------



## Crivens (Aug 4, 2018)

Also, power consumption scales with the square of the voltage. And since voltage roughly scales with frequency, power scales with f^3 (roughly).


----------



## romanaOne (Aug 4, 2018)

Subjectively, I'm not noticing any, um, quality of life issues (hot, noise, unresponsiveness) so I decided to do some testing. Stopping powerd just doesn't  seem to make a huge difference.

Running powerd verbose (powerd -v -a adaptive) at  a terminal, I see that it keeps setting 800MHz when things are idle.

I wrote a shell script to see how temperature varies with the system mostly idle; I'm just running the script and browsing the forums:



Then I started powerd -a adaptive and ran the same script under the same light load conditions:



```
#!/usr/local/bin/bash

# The script just spits out rows of 8 numbers
# It's up to you to process them with gnuplot
# or whatever.
lastcore=8
runs=100
delaytime=20

for i in `seq 1 $runs`;
do

    cores=0
    #Inner loop polls all 8 cores
    until [ $cores -eq $lastcore ];
    do
        echo -n `sysctl -n dev.cpu.$cores.temperature | sed 's/C//' ` "  "
        cores=$((cores+1))
    done
    echo
    sleep $delaytime
done
```

Seems like `powerd -a adaptive` is making things a little cooler.
I also notice in /var/run/dmesg.boot stuff about "enhanced speedstep frequency control" on each core.   Isn't this already throttling? It doesn't seem like powerd is all that needed.

Is there a sysctl variable to disable turbo? Or do you just specify a lower frequency with powerd -M <something less than turbo boost freq. > ?


----------



## Maxnix (Aug 4, 2018)

You just limit maximum frequency with powerd(8)'s *-M *option.


----------



## romanaOne (Aug 4, 2018)

I just found sysutils/powerdxx. Going to give it a try.  After that, I think I am going to sell this laptop 
Nice, quiet laptops like HP Elitebook 8470p, Thinkpad X201 just have adequate heatsinks and quiet fans even under heavy load while this Clevo no-name hunk of junk sounds like a shop vac every 15 minutes just reading a web forum.


----------

