Profiling Power Consumption on Android
Over the past couple of days, I have been trying to figure out a painless method for collecting energy performance on Android mobile phones. I was really happy to discover that my Galaxy Nexus phone reports power events using ftrace. Moreover, cpu_idle reports the time time spent in each low-power state using sysfs. To capture the time spent in each state, it is just a matter of reading a few files. Pretty sweet.
Since both methods seemed so easy to implement, I ended up implementing it both ways: compute the time spent in each c-state using ftrace (sum up the reported c-state residency) and via the results reported in sysfs. To my surprise, the two results did not match --- if fact they were nowhere close to similar.
While the jury is not yet out, it seems like the difference between the reported statistics are due to the state coupling that is necessary so that the two cores of OMAP to enter the low power state. The following mails seem to validate this hypothesis:
- http://comments.gmane.org/gmane.linux.ports.arm.omap/77416
Below are some notes on tools:
Systrace:
# tracer: function
#
# TASK-PID CPU# TIMESTAMP FUNCTION
# | | | | |
bash-4251 [01] 10152.583854: path_put <-path_walk class="l" span="">-path_walk>
bash-4251 [01] 10152.583855: dput <-path_put class="l" span=""> bash-4251 [01] 10152.583855: _atomic_dec_and_lock <-dput pre="">
The time is in the format
.
CPUFreqUtils:-dput>-path_put>
Very nice description of linux support for power consumption:
http://doc.opensuse.org/products/draft/SLES/SLES-tuning_sd_draft/cha.tuning.power.html#sec.tuning.power.tools.cpufrequtils
The cpuidle subsystem controls when a system goes to sleep. A description of the system can be found
here. The nice part of cpuidle is that it exports a ton of important events on sys-fs. A complete description can be found
here.
http://lwn.net/Articles/473072/
http://comments.gmane.org/gmane.linux.ports.arm.omap/77416
http://scape.cs.vt.edu/wp-content/uploads/2012/08/ITJ12_Android_Energy-Aware.pdf
References:
- Galaxy Nexus Hardware
- Cortex-A9 Power Management