You are not logged in.

#1 2012-06-14 11:20:24

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,732
Website

setting powertop tunables manually

Anyone know of a way to see the actual commands to enable some of the tuneables contained in powertop?  For example, what would one type to manually enable the setting corresponding to "Wireless Power Saving for interface wlan0?"  I'd like to place a number of these in my /etc/rc.local.

Offline

#2 2012-06-14 11:32:38

hesse
Member
Registered: 2011-12-08
Posts: 88

Re: setting powertop tunables manually

You should check out the powerdown script, it is in the AUR. Setting the powersaving on for wireless is

# iwconfig wlan0 power on

or with

# iw wlan0 set power_save on

Last edited by hesse (2012-06-14 11:35:17)

Offline

#3 2012-06-14 13:21:43

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,732
Website

Re: setting powertop tunables manually

Thanks for the suggestion, but I want to know the code for all all of the tweaks in powertop, not just that particular one smile

Offline

#4 2012-06-14 13:52:37

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: setting powertop tunables manually

Looking quickly at the powertop 2.0 sourcecode, it's mostly hidden within C++ code to make the commands, under src/tuning/, but there's this:

./src/tuning/tuning.cpp:    add_sysfs_tunable(_("Enable Audio codec power management"), "/sys/module/snd_hda_intel/parameters/power_save", "1");
./src/tuning/tuning.cpp:    add_sysfs_tunable(_("Enable SATA link power management for /dev/sda"), "/sys/class/scsi_host/host0/link_power_management_policy", "min_power");
./src/tuning/tuning.cpp:    add_sysfs_tunable(_("NMI watchdog should be turned off"), "/proc/sys/kernel/nmi_watchdog", "0");
./src/tuning/tuning.cpp:    add_sysfs_tunable(_("Power Aware CPU scheduler"), "/sys/devices/system/cpu/sched_mc_power_savings", "1");
./src/tuning/tuning.cpp:    add_sysfs_tunable(_("VM writeback timeout"), "/proc/sys/vm/dirty_writeback_centisecs", "1500");

Offline

#5 2012-06-14 14:16:04

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,732
Website

Re: setting powertop tunables manually

@brebs - Thank you... this is exactly what I wanted.  Pitty that it is just a subset of 5 sad

Offline

#6 2012-06-16 16:29:33

hesse
Member
Registered: 2011-12-08
Posts: 88

Re: setting powertop tunables manually

You can see what commands to use in the `Tuning` tab in the .html file generated by

# powertop --html

Offline

#7 2012-06-24 19:27:24

bwat47
Member
Registered: 2009-10-07
Posts: 638

Re: setting powertop tunables manually

pm-utils can enable almost all these tunables for you when on battery. I followed the tips on the pm-utils wiki page (enabling sata aplm + activating some of the scripts by making them executable), and post #10 by laloch in this thread to enable "runtime pm" https://bbs.archlinux.org/viewtopic.php?pid=860231

Powertop reports every single tunable 'good' for me when i'm on battery now smile (screenshot: http://i.imgur.com/v6zq7.png). So far this is the battery life I've ever gotten in arch.

Last edited by bwat47 (2012-06-24 19:28:54)

Offline

#8 2012-06-25 23:24:54

laloch
Member
Registered: 2010-02-04
Posts: 186

Re: setting powertop tunables manually

Hi, I've added blacklisting, because my network adapter, probably due to some firmware or driver bug, doesn't "autowake" from suspend. So the script now looks like this:

#!/bin/sh

BLACKLIST=( 8086:10ea )

blacklisted() {
    [[ -f "$1/device" && -f "$1/vendor" ]] || return 1
    DEVICE=$(cat "$1/device")
    VENDOR=$(cat "$1/vendor")
    for ITEM in ${BLACKLIST[@]}; do
        [[ ${VENDOR:2}:${DEVICE:2} == $ITEM ]] && return 0
    done
    return 1
}

device_pm() {
    for DEVICE in /sys/bus/{pci,spi,i2c}/devices/*; do
        [ -d "$DEVICE" ] || continue
        CONTROL="$DEVICE/power/control"
        [ -w "$CONTROL" ] || continue
        blacklisted $DEVICE && continue
        echo $1 > $CONTROL
    done
}

case "$1" in
    true)
        echo "**device power management ON"
        device_pm auto
        ;;
    false)
        echo "**device power management OFF"
        device_pm on
        ;;
esac

exit 0

Offline

#9 2012-06-26 15:46:59

bwat47
Member
Registered: 2009-10-07
Posts: 638

Re: setting powertop tunables manually

laloch wrote:

Hi, I've added blacklisting, because my network adapter, probably due to some firmware or driver bug, doesn't "autowake" from suspend. So the script now looks like this:

#!/bin/sh

BLACKLIST=( 8086:10ea )

blacklisted() {
    [[ -f "$1/device" && -f "$1/vendor" ]] || return 1
    DEVICE=$(cat "$1/device")
    VENDOR=$(cat "$1/vendor")
    for ITEM in ${BLACKLIST[@]}; do
        [[ ${VENDOR:2}:${DEVICE:2} == $ITEM ]] && return 0
    done
    return 1
}

device_pm() {
    for DEVICE in /sys/bus/{pci,spi,i2c}/devices/*; do
        [ -d "$DEVICE" ] || continue
        CONTROL="$DEVICE/power/control"
        [ -w "$CONTROL" ] || continue
        blacklisted $DEVICE && continue
        echo $1 > $CONTROL
    done
}

case "$1" in
    true)
        echo "**device power management ON"
        device_pm auto
        ;;
    false)
        echo "**device power management OFF"
        device_pm on
        ;;
esac

exit 0

nice, looks like that could come in handy if i run into any similar issues. I have run into a sort of similar issue already when runtime pm is enabled, my system hangs on power off (due to a bug with ehci_hcd), I've already managed to work around that one by writing a systemd service file to rmmod it on shutdown though smile

Last edited by bwat47 (2012-06-26 15:47:30)

Offline

Board footer

Powered by FluxBB