# Power consumption on FreeBSD



## freemason (Sep 28, 2012)

(I post here and not on "mobile computing" because it may be an issue not only with laptops and notebooks, etc.)

The problem is FreeBSD's power policy which actually does NOT limit cpu power: neither powerd nor power profiles work properly.

For example, I have the following in my configs:

rc.conf:

```
performance_cx_lowest="C3"
economy_cx_lowest="C3"
powerd_enable="YES"
powerd_flags="-n min -b min -a adp -r 90 -m 800 -M 2100"
```

loader.rc:

```
@set hint.p4tcc.X.disabled=1
@set hint.acpi_throttle.X.disabled=1
@set hint.atrtc.X.clock=0
@set hint.apic.X.clock=0
```

As you see, powerd is configured to minimal frequency available on my cpu (without throttling), and lowest possible power states chosen (C3). But instead CPU burns like a hell-fire when it is under load (even on battery) - that is I think main source of all my powersaving-related problems.

Anyone else encountered this? Maybe something in the drivers, because I'm unable to find any power (not frequency) related settings


----------



## break19 (Sep 29, 2012)

powerd works fine for my system.

I don't see where you've listed your actual system specifications here.

My desktop system is a FreeBSD 9-stable amd64 system, with a Callisto 3.1Ghz dual-core PhenomII.  powerd properly modulates the system frequency based on demand for CPU.

From what you seem to want in your message, you want to force the CPU to run at it's slowest speed at all times.  However, you've told powerd (via the -m/-M options) to vary it's speed from 800mhz to 2100mhz based on demand.  So.. if your CPU is running hotter than you expect, maybe something else is using the CPU, and causing powerd to think (rightly or wrongly as the case may be) that your CPU is needed.

It's also possible that due to the hints set in loader.rc, your cpufreq driver is simply not being loaded.

I am having to guess at your specific problem since no mention of the type of CPU can be found anywhere in your post.


----------



## freemason (Sep 29, 2012)

break19 said:
			
		

> I don't see where you've listed your actual system specifications here.


Hi! My dmesg --> http://pastebin.com/GqL8JHaD


			
				break19 said:
			
		

> From what you seem to want in your message, you want to force the CPU to run at it's slowest speed at all times.  However, you've told powerd (via the -m/-M options) to vary it's speed from 800mhz to 2100mhz based on demand.  So.. if your CPU is running hotter than you expect, maybe something else is using the CPU, and causing powerd to think (rightly or wrongly as the case may be) that your CPU is needed.


In configs I say "keep power at minimum in battery state and unknown state, but scale when on AC."


			
				break19 said:
			
		

> It's also possible that due to the hints set in loader.rc, your cpufreq driver is simply not being loaded.


The problem is not in frequency scaling - powerd normally changes frequencies (with cpufreq module loaded).


			
				break19 said:
			
		

> I am having to guess at your specific problem since no mention of the type of CPU can be found anywhere in your post.


to be quick:
CPU is Core i3 2100 Mhz (has Enhanced Speedstep), available frequences with no throttling are: 800 to 2100 Mhz.


Again, problem is that even on lowest frequency power consumption of CPU remains the same - if load on CPU increases then CPU eats more and more and more! (There was no such problem on Win 7 of course - it forced cpu to "real minimum", so that under load it doesn't eat more power and heat, but... I really hate windows)


----------



## freemason (Oct 1, 2012)

Generally speaking, how do I force cpu power on FreeBSD to be not greater than in idle mode (like it is on Windows)? Now power raises as cpu load increases, so battery life decreases dramatically


----------



## break19 (Oct 1, 2012)

set your upper limit to the same as the lower limit.. and both to the lowest speed,

in other words: powerd_flags="-m 800 -M 800"


----------



## freemason (Oct 1, 2012)

I am talking about POWER, not frequency!

Regardless of frequency cpu power raises under load, is it on battery or on ac.
I've set powerd to always keep frequency at 800 Mhz on battery. It works always keeping frequency at 800 Mhz as it was said.

But this does not help either. When laptop is on battery (so frequency is constant 800 Mhz)- power raises from 11-12 W (when idle) to 16-20 W (when under load).

I need to know if it is possible to adjust actual power of cpu, and not only frequency what powerd already does.

I hope now you understand.
Thanks.



			
				break19 said:
			
		

> powerd_flags="-m 800 -M 800"


Does nothing. Power still raises from 11 W (when idle) to 20 W (when scrolling page of this forum in firefox).


----------



## User23 (Oct 1, 2012)

Did you tried the C1 or C2 state as lowest state too?

http://wiki.freebsd.org/TuningPowerConsumption

"FreeBSD 9.x adds check whether it safe to use specific C-state with present event timer and may automatically block C2/C3 states, making it mostly safe. Nevertheless, due to possible performance degradation on some workloads, C-states use is not enabled by default now, you should enable it manually. Same time, on newer CPUs, enabling deeper C-states allows to use TurboBoost technology, that may increase performance of single-threaded applications."


----------



## freemason (Oct 1, 2012)

C2 has no effect on cpu power consumtion rising under load.

So guys, I decide to give you some more info to think of.

General battery info:

```
acpiconf -i 0
Design capacity:        6352 mAh
Last full capacity:     6300 mAh
Technology:             secondary (rechargeable)
Design voltage:         7400 mV
Capacity (warn):        0 mAh
Capacity (low):         189 mAh
Low/warn granularity:   1 mAh
Warn/full granularity:  1 mAh
Model number:           
Serial number:          
Type:                   LION
OEM info:               SAMSUNG Electronics
```

I ran "*acpiconf -i 0*" with different power consumption states of my laptop on battery, and here are results:

Just after boot, text console, idle:

```
> acpiconf -i 0
State:                  discharging 
Remaining capacity:     80%
Remaining time:         4:31
Present rate:           1115 mA (8815 mW)
Present voltage:        7906 mV
```
Remaining time 4:31 is very close to Windows 7 (which is about 5 hours both idle and under load), but this one is only in idle!

Xorg running, idle:

```
> acpiconf -i 0
State:                  discharging 
Remaining capacity:     79%
Remaining time:         3:26
Present rate:           1444 mA (11362 mW)
Present voltage:        7869 mV
```
1 hour less time than in idle console 

Xorg running, under some load (doing "*cat /dev/random*" in one half-screened urxvt window and "*acpiconf -i 0*" in another)

```
> acpiconf -i 0
State:                  discharging 
Remaining capacity:     76%
Remaining time:         1:17
Present rate:           3687 mA (28290 mW)
Present voltage:        7673 mV
```
This one completely sucks x(

C1 has no effect too, but adds 1 W to CPU in console idle mode.

I also have noticed that doing *cat /dev/random* or *cat /dev/urandom* causes system reboot after some time


----------



## freemason (Oct 1, 2012)

break19 said:
			
		

> It's also possible that due to the hints set in loader.rc, your cpufreq driver is simply not being loaded.


No, cpufreq is loaded because I can change frequences.



			
				freemason said:
			
		

> loader.rc:
> 
> ```
> @set hint.p4tcc.X.disabled=1
> ...


As for *loader.rc* hints, *p4tcc* is outdated and unneeded, *acpi_throttle.X.disabled=1* removes unneeded 100 to 700 Mhz frequences which are very slow but give no powersaving effects, combinations of *[hint.atrtc.X.clock|hint.apic.X.clock]=[0|1]* with different C-states give no effect!


			
				User23 said:
			
		

> Same time, on newer CPUs, enabling deeper C-states allows to use TurboBoost technology, that may increase performance of single-threaded applications."


Mine is Core i3. It has no TurboBoost.

Thanks.


----------



## User23 (Oct 2, 2012)

And if you generate some load on console without Xorg?
Maybe it is a GPU+driver related problem?


----------



## freemason (Oct 2, 2012)

I've done some cpu load opening two terminal windows with command "*cat /dev/random > /dev/null*" run on each of them. So, cpu is loaded and consumption under load only adds about 1 Watt per core.

Yes, it is probably GPU who is such a hungry beast!
Now the only hope is in waiting for some progress on drm-kms modules and xorg intel drivers mainly regarding gpu powersaving.

Or, as there are always alternatives, migrate to gnu/linux.

Thanks.


----------



## Crivens (Oct 2, 2012)

freemason said:
			
		

> Generally speaking, how do I force cpu power on FreeBSD to be not greater than in idle mode (like it is on Windows)? Now power raises as cpu load increases, so battery life decreases dramatically


Not gonna happen.

Anything which is done inside the CPU besides sitting there will consume more power than simply sitting there. So if windows will only allow the CPU as much power as in idle state, it is not to run any code. Nothing. 

I would gess that even windows will eat more power doing anything than it will eat in idle mode.

Find out what is eating the cycles and put the axe there.


----------



## mav@ (Oct 4, 2012)

At different frequencies CPU have different performance-per-Watt rate. So reducing frequency up to some level you may slightly improve summary consumption per task. But as it was told above, you can't do some work and not consume any power. That is impossible.

What's about mentioned test, random device may be slow on some systems to keep it really random. Its performance may not be limited by CPU power.


----------



## m6tt (Oct 5, 2012)

Intel integrated graphics. They also make hellfire on Linux sometimes, but not always. I tried Gentoo on a Sandybridge as well as FreeBSD. With Gentoo I was able to enable fb_6 and some other powersaving GPU options, but sometimes it spits fire anyway at idle. At least on FreeBSD it didn't crash constantly, which it did on Linux until 3.4.something with gpu hangs.


----------



## desshi (Oct 8, 2012)

Your problem is derivate with ACPI!!

I have a problem with my laptop corei3 4 RAM support with ACPI is very bad my BIOS samsung lapto.

The solution is of moment un S.O old,  DesktopBSD 1.07 support disable ACPI. That is my problem with FreeBSD 9


----------



## DAZh (Dec 22, 2012)

Hi,

I had similar problem. Notebook with Intel Core I5 SandyBridge, 2.4 GHz. Even then the CPU frequency was about 200-400 MHz, it was hot like an iron. With idle Xorg acpiconf reported 13000 - 15000 mW. It was GPU. I have added drm.i915.enable_rc6=7 into /boot/loader.conf.

Found it here: http://wiki.freebsd.org/TuningPowerConsumption

Now acpiconf with idle Xorg reports 9000-11000 mW.


----------

