Last month I wrote about the investigations being undertaken to identify any suitable power savings for Ubuntu Precise 12.04 LTS. Armed with a suitably accurate 6.5 digit precision Fluke digital multimeter I worked my way through the Kernel Team Power Management Blueprint measuring many numerous configurations and ways to possibly save power.
A broad range of areas were examined, from kernel tweaks, hardware settings to disk wake-ups and application wakeup events.
Quite a handful of misbehaving applications have been identified ranging from frequent unnecessary wake-ups on poll() and select() calls to rather verbose logging of debug messages that stop the disk from going into power saving states.
We also managed to identify and remove pm-utils power.d scripts that didn't actually save any power and even consumed more power on newer Solid State Drives. By carefully analysing all the PowerTop recommendations we also identified a subset of device power management savings that are shown to be useful and save power across a wide range of machines. After crowd-source testing these tweaks we have now added them into pm-utils for Ubuntu Precise 12.04 LTS by default. I'm very grateful to the Ubuntu community for participating in the testing and feedback.
I've written a brief summary of all the test results, however, the full results can be found in the various subdirectories here. I've also written a very simple set of recommendations to help application developers avoid mistakes that lead to power wasting applications.
We've also set up a Power Management Wiki page that has links to the following:
* Identifying Power Sucking Applications
* Aggressive Link Power Management call for testing
* PCIe Active State Power Management call for testing (now complete)
* Updates to pm utils scripts call for testing (now complete)
..and probably the most useful:
* Power Saving Tweaks
The Power Saving Tweaks page lists a selection of tweaks that can be employed to save power on various machines. Unfortunately with some hardware these tweaks cause lock-ups or rendering bugs, so they cannot be rolled out by default unless we can find either a definitive list of the broken hardware or a large enough whitelist to enable these on a useful set of working hardware. Some of the tweaks cannot be rolled out for all machines as users want specific functionality enabled by default, for example, we need to enable Bluetooth for users with bluetooth keyboards and so it is up to the user to chose to disable Bluetooth to save 1-2 Watts of power.
I've also set-up a PPA with a few tools to help measure power and track down misbehaving wake-up events and CPU intensive applications. These tools don't replace tools like PowerTop and top, but do allow me to track trends on a system over a long running period. You may find these useful too.
We also have a Ubuntu Power Consumption Project set up to help us track bugs related to power consumption issues and regressions.
Last, but no way least, I'd like to thank Steve Langasek and Martin Pitt for all their help with the pm-utils and various fixes to power sucking applications.
Tuesday, 17 January 2012
Monday, 2 January 2012
Commodore 64 is 30
![]() | |
| The C64 boot screen (running in vice) |
The lack of a powerful BASIC interpreter directed my attention to learning 6502 assembler so I could start writing 3D wire frame vector graphics. I learned how to write cycle accurate timing code to drive the VIC II to make side borders disappear and with raster interrupts to make the the top and bottom borders disappear too. I also wedged in my own BASIC tokenizer and interpreter to extend the BASIC to provide better structured programming (while/wend, procedures, repeat/until) and sound, graphics and disk support - all this taught me how to structure large projects in assembler and how to write compact and efficient code.
I spent hours pouring over the disassembled C64 BASIC and Kernal ROMs and learned the art of reverse engineering from the object code. I figured out the tape format, analyzed the read/write characteristics of the tape drive head and re-wrote my own tape turbo loaders.
With the aid of an annotated ROM disassembly of the 1541 floppy drive I figured out how to write disk turbos and I hacked up my own fast formatting tools and my own file system.
By the time I was 17 I had acquired the the Super C Compiler and I learned how to write C on a system that had a 15 minute edit-compile-link-run turnaround cycle(!).
![]() |
| Elite on the C64. |
I was fortunate to have the time and energy and the right hardware available in my formative years, so I am grateful for Commodore for producing the quirky and hackable C64.
See also http://www.reghardware.com/2012/01/02/commodore_64_30_birthday
Wednesday, 28 December 2011
Monitoring /proc/timer_stats
The /proc/timer_stats interface allows one to check on timer usage in a Linux system and hence detect any misuse of timers that can cause excessive wake up events (and also waste power). /proc/timer_stats reports the process id (pid) of a task that initialised the timer, the name of the task, the name of the function that initialised the timer and the name of the timer callback function. To enable timer sampling, write "1\n" to /proc/timer_stats and to disable write "0\n".
While this interface is simple to use, collecting multiple samples over a long period of time to monitor overall system behaviour takes a little more effort. To help with this, I've written a very simple tool called eventstat that calculates the rate of events per second and can dump the data in a .csv (comma separated values) format for importing into a spreadsheet such as LibreOffice for further analysis (such as graphing).
In its basic form, eventstat will run ad infinitum and can be halted by control-C. One can also specify the sample period and number of samples to gather, for example:
.. this gathers samples every 10 seconds for 60 samples (which equates to 10 minutes).
The -t option specifies an events/second threshold to discard events less than this threshold, for example: sudo cpustat -t 10 will show events running at 10Hz or higher.
To dump the samples into a .csv file, use the -r option followed by the name of the .csv file. If you just want to collect just the samples into a .csv file and not see the statistics during the run, use also the -q option, e.g.
With eventstat you can quickly identify rouge processes that cause a high frequency of wake ups. Arguably one can do this with tools such as PowerTop, but eventstat was written to allow one to collect the event statistics over a very long period of time and then help to analyse or graph the data in tools such as Libre Office spreadsheet.
The source is available in the following git repository: git://kernel.ubuntu.com/cking/eventstat.git and in my power management tools PPA: https://launchpad.net/~colin-king/+archive/powermanagement
In an ideal world, application developers should check their code with tools like eventstat or PowerTop to ensure that the application is not misbehaving and causing excessive wake ups especially because abuse of timers could be happening in the supporting libraries that applications may be using.
While this interface is simple to use, collecting multiple samples over a long period of time to monitor overall system behaviour takes a little more effort. To help with this, I've written a very simple tool called eventstat that calculates the rate of events per second and can dump the data in a .csv (comma separated values) format for importing into a spreadsheet such as LibreOffice for further analysis (such as graphing).
In its basic form, eventstat will run ad infinitum and can be halted by control-C. One can also specify the sample period and number of samples to gather, for example:
sudo eventstat 10 60
.. this gathers samples every 10 seconds for 60 samples (which equates to 10 minutes).
The -t option specifies an events/second threshold to discard events less than this threshold, for example: sudo cpustat -t 10 will show events running at 10Hz or higher.
To dump the samples into a .csv file, use the -r option followed by the name of the .csv file. If you just want to collect just the samples into a .csv file and not see the statistics during the run, use also the -q option, e.g.
sudo eventstat -q -r event-report.csv
With eventstat you can quickly identify rouge processes that cause a high frequency of wake ups. Arguably one can do this with tools such as PowerTop, but eventstat was written to allow one to collect the event statistics over a very long period of time and then help to analyse or graph the data in tools such as Libre Office spreadsheet.
The source is available in the following git repository: git://kernel.ubuntu.com/cking/eventstat.git and in my power management tools PPA: https://launchpad.net/~colin-king/+archive/powermanagement
In an ideal world, application developers should check their code with tools like eventstat or PowerTop to ensure that the application is not misbehaving and causing excessive wake ups especially because abuse of timers could be happening in the supporting libraries that applications may be using.
Tuesday, 13 December 2011
Improving Battery Life in Ubuntu Precise 12.04 LTS
Part of my focus this cycle is to see where we can make power saving improvements for Ubuntu Precise 12.04 LTS. There has been a lot of anecdotal evidence of specific machines or power saving features behaving poorly over the past few cycles. So, armed with a 6.5 digit precision multimeter from Fluke I've been measuring the power consumption on various laptops in different test scenarios to try and answer some outstanding questions:* Is it safe to enable Matthew Garrett's PCIe ASPM fix?
* Are the power savings suggested by PowerTop useful and can we reliably enabled any of these in pm-utils?
* How accurate are the ACPI battery readings to estimate power consumption?
* Do the existing pm-utils power.d scripts still make sense?
* Which is better for power saving: i386, i386-pae or amd64?
* How much power does the laptop backlight really use?
* Does halving the mouse input rate really save that much more power?
* Should we re-enable Aggressive Link Power Management (ALPM)?
* Are there any misbehaving applications that are consuming too much power?
* What are the root causes of HDD wake-ups
* Which applications and daemons are creating unnecessary wake events?
* How much does the MSR_IA32_ENERGY_PERF_BIAS save us?
..and many more besides!
From some of the analysis and "crowd sourcing" tests it is clear that the PCIe ASPM fix works well, so we've already incorporated that into Precise.
Aggressive Link Power Management (ALPM) is a mechanism where a SATA AHCI controller can put the SATA link that connects to the disk into a very low power mode during periods of zero I/O activity and into an active power state when work needs to be done. Tests show that this can save around 0.5-1.5 Watts of power on a typical system. However, it has been known in the past to not work on some devices, so I've put a call for testing of ALPM out to the community so we can get a better understanding of the power savings vs reliability.
Some of the PowerTop analysis has shown we can save another 1-2 Watts of power by putting USB and PCI controllers of devices like Webcams, SD card controllers, Wireless, Ethernet and Bluetooth into a lower power state. Again, we would like to understand the range of power savings across a large set of hardware and to see how reliable this is, so another crowd sourced call for testing has been also set up.
So, if you want to contribute to the testing, please visit the above links and spend just a few tens of minutes to see we can extend the battery life of your laptop or netbook. And periodically visit https://wiki.ubuntu.com/Kernel/PowerManagement to see if there any new tests you can participate in.
[UPDATE]
I've written some brief notes on power saving tweaks and also some simple recommendations for application developers to follow too.
The thread continues here (part 2)
Subscribe to:
Posts (Atom)


