# what is eating my battery?

## akb

hi there,

i just noticed that my laptops battery doesnt last as long as running windows. with windows i got about 2 hours when unplugging the AC. but running gentoo it is just less than 1 1/2 hours. is there something that eats much battery but the cpu that i could tune regarding to acpi and/or power management? i already got the cpufreq-thingy working, its behaving correctly with the ondemand-governor, mostly running at 800mhz (i got a sempron 2800+ with the available steps 800 and 1600mhz).

what else eats up my battery here?  :Sad: 

----------

## sa

you could try emerging app-laptop/laptop-mode-tools and configuing the stuff in /etc/laptop-mode, if you can dim your lcd backlight that would help too.

----------

## akb

okay, i merged, configured and started laptop-mode-tools now... but it seems to be still the same.

i unplugged the AC adapter, dimmed the backlight to the minimum level and the gnome battery icon shows me 1:20h remaining battery power, though my cpu meter shows me only 800mhz.

mysterious.

edit: hmmm... 

```
akb@acer ~ $ cat /proc/sys/vm/laptop_mode 

0

```

where is the option in the kernel config to add support for laptop mode?

----------

## Hypnos

Check if you have any processes chewing up cycles using "top"

For example, in the GNOME 2.12, the network monitor applet sits at a constant 1%.

----------

## akb

and this little usage could cause such a need of battery power? i cant really imagine that...

but yes, exactly this applet i got running...

----------

## Corona688

It's also possible that it's estimating the time wrong.

----------

## Hypnos

Anything that keeps the CPU running _constantly_ at a certain usage level could be a problem.  That said, I often have rhythmbox running without much detriment.  Wireless LAN also kills the battery.

Another possibility is an application that constantly keeps the hard disk spinning.

After tweaking with laptop-mode, I get far superior battery life in Linux than in Windows.

----------

## akb

hmmm... its a pity, but it doesnt seem to work for some reason. even with laptop-mode enabled its no change, even not if watched for several minutes. it starts with about 1:10 to 1:25 remaining battery power. damn.

i also noticed that there is no "1" (for "enabled") in /proc/sys/vm/laptop_mode, even after checking if /etc/init.d/laptop_mode is really started. and when i change it manually (echo 1 > /proc/sys/vm/laptop_mode) it doesnt change anything too.

can it really be my running applications? i know about wireless taking much, but i got wireless enabled in windows too, so it should at least be at one level with windows, though it cant be as good as without wireless.

there's no applications running but irssi, gaim and firefox, where firefox is in idle most of the time, especially when testing around with laptop-mode.

here's a small cap of my top output:

```
top - 22:19:41 up  7:35,  3 users,  load average: 0.12, 0.17, 0.12

Tasks:  77 total,   1 running,  76 sleeping,   0 stopped,   0 zombie

Cpu(s):  0.7% us,  0.0% sy,  0.0% ni, 99.0% id,  0.0% wa,  0.3% hi,  0.0% si

Mem:   1034708k total,  1012940k used,    21768k free,   242968k buffers

Swap:   698788k total,       92k used,   698696k free,   228968k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND           

16146 akb       15   0  239m 137m  16m S  0.7 13.6   9:41.72 Xgl                

    1 root      16   0  1476  516  452 S  0.0  0.0   0:01.10 init               

    2 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0        

    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0         

    4 root      10  -5     0    0    0 S  0.0  0.0   0:12.99 events/0           

    5 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper            

    6 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kthread            

    8 root      10  -5     0    0    0 S  0.0  0.0   0:00.27 kblockd/0          

    9 root      10  -5     0    0    0 S  0.0  0.0   0:00.04 kacpid             

  154 root      15   0     0    0    0 S  0.0  0.0   0:00.00 pdflush            

  155 root      15   0     0    0    0 S  0.0  0.0   0:00.55 pdflush            

  157 root      12  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0              

  158 root      12  -5     0    0    0 S  0.0  0.0   0:00.00 xfslogd/0          

  159 root      12  -5     0    0    0 S  0.0  0.0   0:00.00 xfsdatad/0         

  160 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 xfsbufd            

  156 root      16   0     0    0    0 S  0.0  0.0   0:00.54 kswapd0            

  244 root      10  -5     0    0    0 S  0.0  0.0   0:00.03 kseriod 
```

edit: where Xgl isnt generally at top, changing mainly with gaim every few seconds

edit2: i now excluded several factors i think. i tried the following...

- unloading gaim, irssi, firefox -> no noticable change

- unloading the network monitor panel applet -> like above

- disabling my wireless chip completely -> still no change

- quitting xgl to start a "normal" x session (startx) -> no change too

so i think it wont be a real "eater" problem, will it? i only could imagine its a config problem (/etc/laptop_mode/*.conf or whatever its located in) or the service just "doesnt work", whatever that means. maybe something with proc fs or something? mmmhhh... i will continue testing around later i think :-/

----------

## Hypnos

I was doing things manually, now I'm using laptop-mode-tools -- everything seems to work, and battery usage is lower than ever (~20-22 watts with wireless, according to /proc/acpi/battery/*/state).

Try running "lm-profiler" on battery power while using the computer normally to identify possibly troublesome programs.  It noticed that I had cups and cron running.

Beyond that, more ideas:

* tweaking how much you swap in /proc/sys/vm/swappiness (I'm surprised this is not included in the laptop-mode script)

* make sure syslog doesn't sync (pass "-a" in /etc/conf.d/metalog if you use metalog)

More good ideas here.

----------

## akb

i should have done more maths  :Very Happy: 

just for info... maybe you can see something interesting:

```
akb@acer ~ $ cat /proc/acpi/battery/BAT0/state 

present:                 yes

capacity state:          ok

charging state:          discharging

present rate:            1905 mA

remaining capacity:      1917 mAh

present voltage:         15680 mV

```

this is what the profiler told me:

```

acer ~ # lm-profiler       

Profiling run started.

Accesses at 21/600 in run: reiserfs/0                                       

Accesses at 52/600 in run: reiserfs/0                                       

Accesses at 83/600 in run: reiserfs/0                                       

Accesses at 114/600 in run: reiserfs/0                                      

Accesses at 144/600 in run: reiserfs/0                                      

Accesses at 174/600 in run: reiserfs/0                                      

Accesses at 205/600 in run: reiserfs/0                                      

Accesses at 235/600 in run: reiserfs/0                                      

Accesses at 265/600 in run: reiserfs/0                                      

Accesses at 295/600 in run: reiserfs/0                                      

Accesses at 325/600 in run: reiserfs/0                                      

Accesses at 356/600 in run: reiserfs/0                                      

Accesses at 386/600 in run: reiserfs/0                                      

Accesses at 416/600 in run: reiserfs/0                                      

Accesses at 446/600 in run: reiserfs/0                                      

Accesses at 475/600 in run: reiserfs/0                                      

Accesses at 476/600 in run: reiserfs/0                                      

Accesses at 505/600 in run: reiserfs/0                                      

Accesses at 506/600 in run: reiserfs/0                                      

Accesses at 536/600 in run: reiserfs/0                                      

Accesses at 537/600 in run: reiserfs/0                                      

Accesses at 566/600 in run: reiserfs/0                                      

Accesses at 567/600 in run: reiserfs/0                                      

Accesses at 596/600 in run: reiserfs/0                                      

Profiling run completed.                            

Program:     "anacron"

Reason:      standard recommendation (program may not be running)

Init script: none

If you want to disable this program, you should do so manually.

Program:     "cron"

Reason:      standard recommendation (program may not be running)

Init script: /etc/init.d/ntp-client (GUESSED)

Do you want to disable this service in battery mode? [y/N]: 
```

well, ntp-client is not running, must have to do something with ntpd which is calling ntpdate like ntp-client does, i think.

but btw: when i try to interpret this output, it tells me that the hdd didnt have enough time to spin down, right? or do i misunderstand sth?

/proc/sys/vm/swappiness has a value of 60, what does this tell me? is it a time or memory related value?

as syslog i am using syslog-ng. in my /etc/syslog-ng.conf i found the following:

```
options { 

        chain_hostnames(off); 

        [color=red]sync(0);[/color]

        # The default action of syslog-ng 1.6.0 is to log a STATS line

        # to the file every 10 minutes.  That's pretty ugly after a while.

        # Change it to every 12 hours so you get a nice daily update of

        # how many messages syslog-ng missed (0).

        stats(43200); 

};

```

seems to me that sync is already disabled.

well... maybe you see something interesting within this post... i will go to bed before testing any further. tomorrow i'll resolve that lm-profiler mentioned and take a look at your other tipps/the url  :Smile: 

thank you so far.

----------

## Hypnos

* Indicated battery usage:

1.905 A * 15.68 V = 29.87 W !!!  That seems awfully high.  Your current draw should be closer to 1400 mA or 1.4 A.  (This is assuming that you have a normal business laptop, not some Alienware beast.)

* lm-profiler:

Yes, it would seem that the filesystem never calms down, with accesses precisely every 30 seconds.  Check your log files for possible clues.  I have set my logger to ignore any messages below logging level 4, so this eliminated the periodic inconsequential complaints from ntp.

* syslog-ng:

You'll have to look at the syslog-ng startup scripts in /etc/ and read the man pages to learn how to turn off syncing.

* swappiness:

It's some arbitrary linear scale from 0 to 100.  0 means off (which would break swsusp), and 100 means swap data from memory to disk swap very aggressively.  I use a laptop-mode plugin script to set this to 60 on AC power, and 10 on battery power.

----------

## akb

i now were able to reduce it to about 21W... this should be quite normal, right?

one main issue was my graphics chip not reducing its power usage because of Xgl running.

----------

## Hypnos

 *akb wrote:*   

> one main issue was my graphics chip not reducing its power usage because of Xgl running.

 

At least with ATI chips, the OpenGL rendering hardware is powered off when not in use.  This suggests that if it's constantly running, it might draw quite a bit of power.

----------

## Sachankara

 *akb wrote:*   

> okay, i merged, configured and started laptop-mode-tools now... but it seems to be still the same.

 Have you gone through the configuration file and looked over all settings?

----------

