Power saving in Linux devices
Chris Simmonds
2net Limited
Class 5.5
Embedded Systems Conference UK. 2009
Copyright © 2009, 2net Limited
Overview
Power saving is important because
Extends battery life
Conforms to regulations for consumer and office
equipment
Micro power management
Reduce clock speeds, sleep during idle - little impact
on overall performance
Macro power management
Suspend and hibernate
Chris Simmonds 2net Ltd
2
Micro power management
Techniques that have low latency
i.e. Low overhead in time and power switching from
one state to another
CPUFreq
Scale core clock frequency dependant on load
Dynatick (Tickless operation)
Fewer timer interrupts, more time sleeping
CPUIdle
Deeper sleep when idle
Chris Simmonds 2net Ltd
3
CPUFreq
Requires chip support to set core frequency
Need to know latency (overhead) of changing
frequency
Policy set by “governor”
Typically:
Increase frequency as processor load increases
Reduce frequency when load drops
Chris Simmonds 2net Ltd
4
CPUFreq governors
powersave - always select the lowest frequency
performance - always select the highest frequency
ondemand - change frequency based on utilisation: if the
CPU is idle < 20% of the time set the frequency to the
maximum; if idle >=30% drop the frequency down in
5% decrements
conservative - as “ondemand”, but switches to higher
frequencies in 5% steps rather than going immediately
to the maximum
userspace - frequency is set by a userspace application
Chris Simmonds 2net Ltd
5
CPUFreq settings
In /sys/devices/system/cpu/cpu0/cpufreq/
scaling_max_freq and scaling_min_freq and
scaling_available_frequencies
scaling_available_governors which lists the names of
the built-in governors
scaling_governor which tells you the current
governor and allows you to set a new one
scaling_setspeed allows you to set the speed if the
governor is set to “userspace”
Chris Simmonds 2net Ltd
6
User space governors
The “userspace” governor allows the frequency
to be set by writing to scaling_setspeed
Examples
cpuspeed [2], cpudyn [3] and cpufreqd [4]
Chris Simmonds 2net Ltd
7
Dynamic tick
Historically Linux has a regular timer tick
HZ from 100 to 1000
Can create unnecessary wakeups
Dynamic tick mode means timer interrupts
occur only when needed
CONFIG_NO_HZ in Linux 2.6.21
Chris Simmonds 2net Ltd
8