Power management

From PacBSD Wiki
Jump to: navigation, search

The purpose of this page is to provide general overview of power management in PacBSD.

File:Tango-document-new.png This article is a stub.
Notes: This page needs expanded with information on powerd and other power saving tools. (Discuss)
File:Tango-document-new.png

Powerd

Powerd(8) is a utility that monitors the system state, whether the system is running on battery or AC and current system load, and sets various power control options accordingly. Different power-saving modes can be set for operation on AC power (focus more on performance at the cost of consuming more power) or batteries (focus on less power consumption at the cost of performance).

Valid modes for powerd are

maximum Choose the highest performance values. May be abbreviated as max.
minimum Choose the lowest performance values to get the most power savings. May be abbreviated as min.
adaptive Attempt to strike a balance by degrading performance when the system appears idle and increasing it when the system is busy. It offers a good balance between a small performance loss for greatly increased power savings. May be abbreviated as adp.
hiadaptive Like adaptive mode, but tuned for systems where performance and interactivity are more important that power consumption. It increases frequency faster, reduces frequency less aggressively, and will maintain full frequency for longer. Maybe abbreviated as hadp.

The default mode is adaptive for battery power and hiadaptive for the rest. While this setting will work for a desktop, allowing the system to run at its full potential while being used and cut down on power consumption while idle. Laptop users may want to set power to operate at a more conservative mode while running off battery.

Configuration via FreeBSD-Init

If using the FreeBSD init system powerd is enabled/disabled and configured via /etc/rc.conf. Configuration is done via two settings in /etc/rc.conf the first, powerd_enable, takes a boolean "YES" or "NO", the second, powerd_flags, takes a string that is passed to powerd as flags to set the different modes, frequencies, and CPU load percent levels to act on.

Example of setting powerd to use hiadaptive mode while on AC but use minimum when running off of batteries:

# sysrc powerd_enable="YES"
# sysrc powerd_flags="-a hiadaptive -b minimum"

Another common setting for powerd is telling which mode to use incase it is unknown to the system if it is running off of AC or battery, this is done with the -n flag

# sysrc powerd_flags+="-n adaptive"


Note: This example shows using sysrc to append new values to a configuration option using +=. This tells sysrc to append the new value(s) to any existing values for this option, sysrc will only add the new value(s) if it is not present in the current settings thus avoiding duplicates. Thus making this command the same as running # sysrc powerd_flags="-a hiadaptive -b minimum -n adaptive". For more information on this see sysrc(8).

This tells powerd that we want it to use hiadaptive mode when on AC, minimum when on battery, and adaptive in times when/if it unable to detect the current power state.

To start powerd immediately without rebooting the system run:

service powerd start

Configuration via OpenRC

If using OpenRC as the init system, powerd is configured via /etc/conf.d/powerd.

/etc/conf.d/powerd
# Mode allowed: maximum, minimum, adaptive, hiadaptive
# Default unless specified is hiadaptive
powerd_ac_mode="hiadaptive"
#powerd_battery_mode="minimum"

# Additional arguments for powerd - see the man page for details
powerd_args=""

This will cause powerd to operate in hiadaptive mode, at least while on AC. When OpenRC starts powerd it will pass the values set for powerd_ac_mode and powerd_battery_mode to the -a and -b flags respectively.

If any other settings are desired to be set, such as setting a mode to use when powerd is unable to determine the current power state, these options are set in powerd_args.

/etc/conf.d/powerd
# Mode allowed: maximum, minimum, adaptive, hiadaptive
# Default unless specified is hiadaptive
powerd_ac_mode="hiadaptive"
powerd_battery_mode="minimum"

# Additional arguments for powerd - see the man page for details
powerd_args="-n adaptive"

Once powerd has been configured it can be enabled with

# rc-update add powerd default

and be started immediately with

# rc-service powerd start

See Also