Author Topic: Optimizing laptop battery life with powertop  (Read 12107 times)

0 Members and 1 Guest are viewing this topic.

Offline betaTopic starter

  • Neuling
  • *
  • Posts: 3
Optimizing laptop battery life with powertop
« on: 07. December 2012, 22:09:00 »
Powertop (https://01.org/powertop/community) is a very mature watt saving tool developed by Intel.

In this tutorial we will look at how to get most out of it.

Code: (bash) [Select]
sudo pacman -S powertop
sudo powertop

Have a look what it  does and other Tunables the changes it suggests.
It is generally assumed that it just makes suggestions, that is not entirely true.



Scenario A - Kernel 3.2 - 3.4


Little know fact, for kernels 3.2 - 3.4, powertop can make changes permanent!
This is how you do it:

  • Fully charge your laptop
  • Unplug
  • Open Terminal
  • sudo powertop
  • let sit idle for > 60 minutes

This should make changes permanent on Intel based laptops.
You can note some of the tunables suggested when you run it the first time, then go through the steps above, and subsequently reboot to see if they were written permanently.


Scenario B - Kernel 3.6
I am running a 3.6 kernel because I have an ivy bridge laptop.
Currently, powertop does not write permanent changes with 3.6.  Hence you have to execute them at every boot.  To automate that process, you need to start it from /etc/rc.local or a systemd startup script (no systemd comments, please)

This command will write the powertop output to an html file, open with browser, copy and paste the suggestions into a plain text file.

Code: (bash) [Select]
sudo powertop -html
Don't worry about
Code: (bash) [Select]
Cannot load from file /var/cache/powertop/saved_parameters.powertop
Open the newly created file with a browser, go to the tunables tab.
Copy and Paste the suggestions:

Code: (bash) [Select]
nano startup.sh
sudo chmod +x startup.sh
sudo cp startup.sh /usr/local/bin/

Name the file what you want and put it where you want.
It will look something like this:

Code: (bash) [Select]
#VM writeback timeout
echo '1500' > '/proc/sys/vm/dirty_writeback_centisecs';
#Enable Audio codec power management
echo '1' > '/sys/module/snd_hda_intel/parameters/power_save';
#Enable SATA link power management for /dev/sda
echo 'min_power' > '/sys/class/scsi_host/host0/link_power_management_policy';
#Wireless Power Saving for interface wlan0
iw dev wlan0 set power_save on
#Enable SATA link power management for /dev/sda
echo 'min_power' > '/sys/class/scsi_host/host0/link_power_management_policy';
#NMI watchdog should be turned off
echo '0' > '/proc/sys/kernel/nmi_watchdog';
#VM writeback timeout
echo '1500' > '/proc/sys/vm/dirty_writeback_centisecs';
#Runtime PM for PCI Device Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode]
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.2/power/control';
#Runtime PM for PCI Device Intel Corporation Centrino Wireless-N 2200
echo 'auto' > '/sys/bus/pci/devices/0000:03:00.0/power/control';
#Runtime PM for PCI Device Ricoh Co Ltd MMC/SD Host Controller
echo 'auto' > '/sys/bus/pci/devices/0000:02:00.0/power/control';
#Runtime PM for PCI Device Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.3/power/control';
#Runtime PM for PCI Device Intel Corporation 3rd Gen Core processor Graphics Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:02.0/power/control';
#Runtime PM for PCI Device Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:14.0/power/control';
#Runtime PM for PCI Device Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1
echo 'auto' > '/sys/bus/pci/devices/0000:00:16.0/power/control';
#Runtime PM for PCI Device Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:1b.0/power/control';
#Runtime PM for PCI Device Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 1
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.0/power/control';
#Runtime PM for PCI Device Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.1/power/control';
#Runtime PM for PCI Device Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3
echo 'auto' > '/sys/bus/pci/devices/0000:00:1c.2/power/control';
#Runtime PM for PCI Device Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1
echo 'auto' > '/sys/bus/pci/devices/0000:00:1d.0/power/control';
#Runtime PM for PCI Device Intel Corporation 82579LM Gigabit Network Connection
echo 'auto' > '/sys/bus/pci/devices/0000:00:19.0/power/control';
#Runtime PM for PCI Device Intel Corporation QM77 Express Chipset LPC Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.0/power/control';
#Runtime PM for PCI Device Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2
echo 'auto' > '/sys/bus/pci/devices/0000:00:1a.0/power/control';
#Wake-on-lan status for device eth0
ethtool -s eth0 wol d;
#Enable Audio codec power management
echo '1' > '/sys/module/snd_hda_intel/parameters/power_save';
echo 'min_power' > '/sys/class/scsi_host/host0/link_power_management_policy';

a) start script with /etc/rc.local (easier)
Code: (bash) [Select]
#!/bin/bash
/usr/local/bin/startup.sh
exit


b) with systemd
Now you need a systemd service file, so the script is executed at startup:

Code: (bash) [Select]
[Unit]
Description=Startup
After=tlp-init.service

[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/local/bin/startup.sh

[Install]
WantedBy=multi-user.target

Copy the startup service to the appropriate location
Code: (bash) [Select]
sudo cp startup.service  /usr/lib/systemd/system/
Start the service
Code: (bash) [Select]
sudo systemctl start startup.service
Enable the startup service at boot
Code: (bash) [Select]
sudo systemctl enable startup.service will give you:
ln -s '/usr/lib/systemd/system/startup.service' '/etc/systemd/system/multi-user.target.wants/startup.service'


My X230 is running at 3.6 watts with these changes, yielding a battery life of 14.4 hours fully charged with a 9-cell battery.

PS: My 2nd post here, have mercy...
« Last Edit: 08. December 2012, 13:12:59 by beta »

Offline davedrowsy

  • Vollwertiges Mitglied
  • ***
  • Posts: 142
    • Antibubbles (my band)
Re: Optimizing laptop battery life with powertop
« Reply #1 on: 07. December 2012, 23:58:04 »
Ooh, awesome! Thank you so much for posting this. I recently installed powertop, but didn't quite understand how to use it properly. My Thinkpad SL500 apparently still only gets about 1 hour of battery life fully charged, whereas its advertised battery life is supposed to be something like 3 hours. When I get some time I'll fiddle around with this and see if I can unlock the full potential of my battery!

Offline eskaini

  • Security Team
  • *****
  • Posts: 8998
  • Skill: Novice
Re: Optimizing laptop battery life with powertop
« Reply #2 on: 13. December 2012, 21:56:51 »
It would appear that the systemd method of optimising power usage doesn't work. Here's the outcome when I tried to use it:

Code: (bash) [Select]
[carl@manjaro ~]$ sudo systemctl start startup.service
Job for startup.service failed. See 'systemctl status startup.service' and 'journalctl -xn' for details.
[carl@manjaro ~]$ systemctl status startup.service
startup.service - Startup
  Loaded: loaded (/usr/lib/systemd/system/startup.service; disabled)
  Active: failed (Result: exit-code) since Thu, 2012-12-13 20:51:14 GMT; 6s ago
Process: 617 ExecStart=/usr/local/bin/startup.sh (code=exited, status=203/EXEC)
  CGroup: name=systemd:/system/startup.service

The rc.local method however seems to work. It'll be up on the wiki in the next 15mins from posting this...

Offline Seaco

  • Jr. Mitglied
  • **
  • Posts: 82
  • Kernel: linux310-x64
  • Desktop: XFCE
  • Branch: stable
  • GPU Card: ATI
  • GPU driver: free
  • Skill: Novice
Re: Optimizing laptop battery life with powertop
« Reply #3 on: 12. February 2013, 22:47:23 »
one question.

you say that I have to leave it idle 60 minutes, but I only I have 15 minutes of battery life (yes, its depressing) any suggestions?
XFCE Manjaro

Offline ultima

  • Held Mitglied
  • *****
  • Posts: 1564
Re: Optimizing laptop battery life with powertop
« Reply #4 on: 12. February 2013, 22:52:21 »
Your battery s dead as mine .

Offline Matthias19281

  • Vollwertiges Mitglied
  • ***
  • Posts: 166
  • Kernel: Kernel 3.14 (Laptop) /Kernel 3.13 (PC)
  • Desktop: Openbox
  • Branch: unstable
  • GPU Card: Intel (Laptop)/Nvidia (PC)
  • GPU driver: free
  • Skill: Advanced
Re: Optimizing laptop battery life with powertop
« Reply #5 on: 12. February 2013, 23:21:59 »
I get the following error message after
Code: [Select]
sudo cp startup.service  /usr/lib/systemd/system/:

cp: der Aufruf von stat für „startup.service“ ist nicht möglich: Datei oder Verzeichnis nicht gefunden

Offline dicktater

  • Global Moderator
  • *****
  • Posts: 2058
  • Skill: Novice
Re: Optimizing laptop battery life with powertop
« Reply #6 on: 12. February 2013, 23:43:42 »
I get the following error message after
Code: [Select]
sudo cp startup.service  /usr/lib/systemd/system/:

cp: der Aufruf von stat für „startup.service“ ist nicht möglich: Datei oder Verzeichnis nicht gefunden
What directory were you in when you issued the command? I don't understand. What exactly are you trying to do? AFAIK, something called startup.service as a native systemd service does not exist.
The Manjaro Forum Revised Rules  How to Report Issues Properly   Please Read the Manjaro Wiki

Offline Matthias19281

  • Vollwertiges Mitglied
  • ***
  • Posts: 166
  • Kernel: Kernel 3.14 (Laptop) /Kernel 3.13 (PC)
  • Desktop: Openbox
  • Branch: unstable
  • GPU Card: Intel (Laptop)/Nvidia (PC)
  • GPU driver: free
  • Skill: Advanced
Re: Optimizing laptop battery life with powertop
« Reply #7 on: 12. February 2013, 23:52:02 »
What directory were you in when you issued the command? I don't understand. What exactly are you trying to do? AFAIK, something called startup.service as a native systemd service does not exist.

I just was following the tutorial - I took the 1st version. Seems to work - thank you

Offline dicktater

  • Global Moderator
  • *****
  • Posts: 2058
  • Skill: Novice
Re: Optimizing laptop battery life with powertop
« Reply #8 on: 12. February 2013, 23:57:47 »
OK. I see now what I didn't see before.
The Manjaro Forum Revised Rules  How to Report Issues Properly   Please Read the Manjaro Wiki

Offline mihneadb

  • Neuling
  • *
  • Posts: 1
  • Kernel: linux39-x64
  • Desktop: Cinnamon
  • Branch: stable
  • GPU Card: Intel HD ivy
  • GPU driver: intel open source
  • Skill: Novice
Re: Optimizing laptop battery life with powertop
« Reply #9 on: 06. July 2013, 22:27:55 »
[...]
My X230 is running at 3.6 watts with these changes, yielding a battery life of 14.4 hours fully charged with a 9-cell battery.

Hi,

Do you still get those numbers with linux 3.9? Also, are you using a graphical environment? I have an x230 as well and with all the tweaks I get 10-12W consumption. Seems pretty far from what you are describing.

Thanks!

Offline aaditya

  • OpenRC Team
  • ****
  • Posts: 2649
    • My Website
  • Kernel: Linux-3.18-x86_64
  • Desktop: Xfce
  • Branch: Testing
  • GPU Card: Intel HD 4000
  • Skill: Intermediate
Re: Optimizing laptop battery life with powertop
« Reply #10 on: 30. August 2013, 22:36:25 »
The startup.service is not working ???
Somebody please update it :)

Offline poincare

  • Neuling
  • *
  • Posts: 40
  • Desktop: Gnome 3
  • GPU Card: Radeon 6550 HD
  • GPU driver: Free
  • Skill: Novice
Re: Optimizing laptop battery life with powertop
« Reply #11 on: 14. September 2013, 19:52:28 »
I have also followed the directions in the tutorial and cannot see startup.service working.  Is this still how to get powertop to work for startup?