Power management for Linux on the C720

Some notes from my own experience trying to squeeze as much life out of the battery of an Acer C720-2802 with Fedora 20 installed.

The two primary tools I used for this part of the project were powertop and tuned.

Powertop was developed at Intel as a power configuration reporting tool for Linux. It has both an interactive curses based and a script friendly cli mode. One of the options in cli mode is “–auto-tune”, which directs the utility to automatically all power related settings.

Tuned is a daemon developed at Red Hat that is normally invoked as a system service to apply power related settings specified in one of a number of pre-packaged profiles (additional profiles in the tuned-profiles-compat package). Among the utilities available is powertop2tuned (in the optional tuned-utils package), which uses powertop to generate a tuned profile.

I experimented with both powertop and tuned for awhile to determine what combination of settings would result in battery life close to that experienced when the machine ran ChromeOS.

During the time I ran ChromeOS it was normal to get around 6 to 7 hours on a charge.

Using the most aggressive settings recommended by powertop, I was able to get around 4 to 5 hours per charge. Combining use of those settings and tuned’s powersave profile gave me almost 5 to 6 hours.

The settings recommended by powertop (obtained by doing “powertop –html” and then filtering out everything except the “echo auto …” commands reported) were hardcoded into /etc/rc.d/rc.local so they would be applied each time the system started. The additional settings in the tuned profile would be loaded by systemd at the same time.

The final challenge was doing something to reduce the power draw from the LED backlight, which was by far the greatest drain on the battery.

For that I used the xbacklight command to reset brightness to 40% in both /etc/rc.d/rc.local and my Gnome session profile (gnome-session-properties… Startup Programs… Add). At 40%, which under normal indoor lighting was still comfortably bright, I was able to get a solid 7 hours out of the C720’s battery.

What I’m still working on at this point is making my power settings more reactive. In particular I’d like to leverage the machine’s hardware light sensor to better control screen brightness.

POWER CONFIGURATION STEPS:

1. Install powertop and create report.

[root@test1 ~]# yum install powertop
[root@test1 ~]# powertop --html=/tmp/powertop.html

2. Create rc.local with powertop recommended changes:

[root@test1 ~]# grep 'echo auto' powertop.html >/etc/rc.d/rc.local

You will need to clean the resulting text up a bit until it looks something like this (NOT exactly this as the recommended settings will differ depending upon the specific O/S configuration and hardware model:

# Suggestions from PowerTop
echo 1 > /sys/module/snd_hda_intel/parameters/power_save;
echo auto > /sys/bus/usb/devices/2-4/power/control;
echo auto > /sys/bus/pci/devices/0000:01:00.0/power/control;
echo auto > /sys/bus/pci/devices/0000:00:1f.3/power/control;
echo auto > /sys/bus/pci/devices/0000:00:1f.2/power/control;
echo auto > /sys/bus/pci/devices/0000:00:1f.6/power/control;
echo auto > /sys/bus/pci/devices/0000:00:1f.0/power/control;
echo auto > /sys/bus/pci/devices/0000:00:1d.0/power/control;
echo auto > /sys/bus/pci/devices/0000:00:00.0/power/control;
echo auto > /sys/bus/pci/devices/0000:00:03.0/power/control;
echo auto > /sys/bus/pci/devices/0000:00:02.0/power/control;
echo auto > /sys/bus/pci/devices/0000:00:14.0/power/control;
echo auto > /sys/bus/pci/devices/0000:00:15.0/power/control;
echo auto > /sys/bus/pci/devices/0000:00:1b.0/power/control;
echo auto > /sys/bus/pci/devices/0000:00:1c.0/power/control;

Enable rc.local with the commands:

[root@test1 ~]# systemctl start rc-local.service
[root@test1 ~]# systemctl enable rc-local.service

Apparently this does not work for everyone. In that case you can manually create the rc-local.service file and symlink to /etc/systemd/system/rc-local.service before starting and enabling (be sure to make rc.local executable with “chmod ugo+x rc.local”).

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.d/rc.local is executable.
[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
SysVStartPriority=99

3. Install and configure tuned.

[root@test1 ~]# yum install tuned tuned-profiles-compat tuned-utils
[root@test1 ~]# tuned-adm profile laptop-battery-powersave
[root@test1 ~]# systemctl start tuned
[root@test1 ~]# systemctl enable tuned

(if you carefully examine the current laptop-battery-powersave profile you’ll discover that it merely points to the generic powersave profile)

4. Adjust LED backlight brightness.

At boot by adding xbacklight command to /etc/rc.d/rc.local:

xbacklight -set 40

Invoke this same command when logging into the Gnome Shell by opening gnome-session-properties, clicking on the Startup Applications tab, hitting the Add button and creating a startup item. I named mine “Set backlight” and put “xbacklight -set 40” in the Command field.

NOTE: Recent updates to the Gnome shell and supporting software, as well as the bump to the 3.17 kernel, have made C720 power management more… manageable. I’m still using powertop with tuned to fine… tune things, but overall the experience has improved greatly.

This entry was posted in Hardware, System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).