While I'm about releasing power scripts, I've quickly written this script to monitor power usage on various Linux systems. It needs bash and sysfs. It can use bc and gnuplot for more comfort.
Showing posts with label power management. Show all posts
Showing posts with label power management. Show all posts
Automatically Resume from Suspend to Ram and Suspend to Disk to Save Battery in Linux
Suspending to RAM is allows the system to quickly wake up. But Suspend to Disk allows the system to completely power off, saving more power. That's why I've written a small script for modern Linux systems, which wakes up the system from S3 (memory sleep) and puts it into S5 (hibernation) mode. Also, it prevents you from losing data, because eventually your system's battery will run out.
Tips for saving power on Intel Notebooks with i915 driver
Phoronix published some intel laptop linux power saving tips you might want to read: i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 and i915.lvds_downclock=1
Logging and Graphing Power Consumption of Embedded Linux Systems -- Busybox and GnuPlot analyzing the Kindle 3
Actually this should've been really easy. A small script loop on the kindle to log the battery consumption and then plug that data into gnuplot. But it turned out gnuplot afaik doesn't support to output the difference between values. Thanks to apo_ from #gnuplot I've got it running with the help of awk now. The great thing is that this script runs in busybox and can hence easily be adapted for pretty much any kind of portable devices including Android phones, Kindles, Tablets, Notebooks, Netbooks, etc. And that's how it looks.
![]() |
| Kindle 3 Battery Consumption Measurement points are marked with an x. |
Charging Devices During Suspend Using your Notebook's USB Port with Linux
You probably have done this before: Plug your phone or mp3 into your Notebook's USB port to charge it. E.g. the Kindle usually only comes with a USB cable and no seperate charger. Did you know you can do this even when your system is in standby mode? I will show you how - without the need to modify anything but software!
Minimal Powertop as Bash Script esp. for Embedded Environments
I wrote this for my kindle and android devices. It's a nice, easy script though and should be great especially for embedded environments, where you have a shell but not all of the powertop dependencies. It works wonderfully on my notebook and netbook, but you may have to slightly adjust the path names to work on your system.
It turns out that this wasn't needed for either, as the kindle comes with powertop preinstalled. But it can't work on either of my devices, as timer_stats are disabled in their kernels.
I do wonder: Why do they disable the timer_stats? Is the overhead of timer_stats too high? Let me know how you use it!
It turns out that this wasn't needed for either, as the kindle comes with powertop preinstalled. But it can't work on either of my devices, as timer_stats are disabled in their kernels.
I do wonder: Why do they disable the timer_stats? Is the overhead of timer_stats too high? Let me know how you use it!
Is the Linux Desktop getting slower and more bloated?
In his "failure of logic" post "K. Mandla" writes that the Linux Desktop is not getting faster even though all the hardware around it is getting faster, pointing to an article with the same argument 10 years ago. The ensueing discussion was much too abstract for my taste. ("Why are clouds?" "What clouds, where?") But if you split up the question you get answers:
0.4 Watt Less During Audio Playback - (Updated:) Power Performance: Pulseaudio + Interrupt-Less Alsa
(Skip to the update)
Ok, so with some help from Pierre-Louis from Intel I've managed to get it working and do some performance/power tests. But let me start at the beginning: Recently, pulseaudio not only switched to a more power efficient (and otherwise) timing system, as far as I understand a callback API. It also provided the infrastructure to use ALSA devices without causing any interrupts ("period wakeup disabling"), so you CPU can stay longer in standby mode (e.g. "C6 residency"), saving you power and avoiding playback glitches at the same time. See here and here or more background information. With kernel 2.6.38 the first driver (snd-hda-intel) supports this infrastructure out of the box, the snd-hda-intel driver. This combination is what I tested for power efficiency...
Ok, so with some help from Pierre-Louis from Intel I've managed to get it working and do some performance/power tests. But let me start at the beginning: Recently, pulseaudio not only switched to a more power efficient (and otherwise) timing system, as far as I understand a callback API. It also provided the infrastructure to use ALSA devices without causing any interrupts ("period wakeup disabling"), so you CPU can stay longer in standby mode (e.g. "C6 residency"), saving you power and avoiding playback glitches at the same time. See here and here or more background information. With kernel 2.6.38 the first driver (snd-hda-intel) supports this infrastructure out of the box, the snd-hda-intel driver. This combination is what I tested for power efficiency...
Pulseaudio Power Efficiency
Using pulseaudio in combination with alsa is already more power efficient and avoids many interrupts on current systems. In my experience the interrupts created by hda_intel decreased from 60-80 down to 6 per second. The sleep residency increased from about 3 ms to about 8 ms. This already makes a difference of about .25 Watts. I wonder if and how the difference will be with the new patches that went into 2.6.38, disabling even more interrupts.
Update: Also check how to save 0.4 Watts and more with pulseaudio and alsa.
Update: Also check how to save 0.4 Watts and more with pulseaudio and alsa.
Saving 2 W power by Making Sure Laptop_Mode oesn't destroy your HD
Laptop_mode is actually a great thing, as it activates a few powerful power saving modes in Linux, most importantly disk power saving and delayed writes. But if you use it with out of the box settings, there are two major bugs in Laptop Mode Tools, which could cause your disk to crash and are the reason it's normally disabled. Now let me show you how to work around them and easily save 2 W of power:
What to do if you mobile has battery problems
Sometimes mobile phones with Li-Ion battery have a problem that causes them not to provide anywhere near the expected run time. A possible problem is that not all cells are charged equally. This can happen especially if you have not charged your phone until it said it's full the first time you charged it. But it can happen in any case.
Now a great workaround for this problem is to follow this guide posted on the xda-developers forum: You fully charge the phone. (until it says it's full) and then power it off and then:
1. Wait until it shows its fully charged.
2. Unplug the phone and wait for it to turn off lights and display.
3. Replug the phone and go to No. 1. (Repeat about 10 times)
Now a great workaround for this problem is to follow this guide posted on the xda-developers forum: You fully charge the phone. (until it says it's full) and then power it off and then:
1. Wait until it shows its fully charged.
2. Unplug the phone and wait for it to turn off lights and display.
3. Replug the phone and go to No. 1. (Repeat about 10 times)
Make your Android power efficient in any situation (for free!)
In the following post I will explain how to use cpu tuner, a completely free and open source app for android. All you need is root and some time. It's a follow up on and summary of my various related posts you can mostly see below ("related posts") on working with governors to increase power efficiency in Linux. This is of course something that a) Linux and b) Android and c) your phone manufacturer should already have done. But as they didn't...
What can Governor Adjustments do for your Battery Mileage?
After my previous post about Android saving power with Linux governor tweaking, I did some governor tweak testing on my netbook with a tweaked phoronix test suide (pts) and came up with these results:
The first two show the power usage in Watts, the third shows the frequencies used during the test.
The first two show the power usage in Watts, the third shows the frequencies used during the test.
Reduce Power Consumption Extend Battery Life of your Android with CPUfreq Governor Tweaks
CPUfreq is the part of the Linux kernel that changes your CPU's frequency to save power or increases it to make your system run faster. Obviously the settings you use there are essential for you performance and battery consumption. I read an extensive article by IBM some time ago analysing the different Linux cpu frequency governors. It makes lots of fancy tests and has great diagrams etc. What it boils down to is that these are the perfect setttings for low power at high performance in Linux. (Also check out this article where I tested these settings on my netbook.)
Atom Power Usage Reduced with kernel 2.6.36
As expected, the intel_idle driver includes ATM-C4 and ATM-C6 CPU power saving modes in kernel 2.6.36, even if your BIOS doesn't announce them. Check it out!
I'm sure it'll lower your power consumption by at least 0.5W on average loads. Of course there might be no difference at all if your BIOS already supports them. But often the BIOS disables the states when the AC adapter is plugged in. They still work, though, when using intel_idle. This makes your netbook less power hungry and more importantly: quieter. For some netbooks this will definitely be a big difference in run time as well.
Let me know how it works for you in the comments.
I'm sure it'll lower your power consumption by at least 0.5W on average loads. Of course there might be no difference at all if your BIOS already supports them. But often the BIOS disables the states when the AC adapter is plugged in. They still work, though, when using intel_idle. This makes your netbook less power hungry and more importantly: quieter. For some netbooks this will definitely be a big difference in run time as well.
Let me know how it works for you in the comments.
Disabling Fsync in Laptop_Mode
There are several libraries that help you to disable fsync temporarily so your hard disk doesn't always spin up to save your notebooks battery. Of course that is not very flexible as you need to preload the libraries meaning you have to restart the programs.
New Low Power Record - Power Management Progress in 2.6.35
I just wanted to test how low the system can go in it's power usage with the power management framework of kernel 2.6.35 and the results amaze me. A test just showed that the system can save an additional 0.8 watts with the new kernel. Before the minimum battery usage without wifi was 5.6 W. Now in kernel 2.6.35 this has gone down another 0.8 W to 4.8 W - or 8.3 hours with just over 70 % battery. This is amazing. Even with wifi active the system now goes down to about 6 W - significantly increasing the amount of time you can be online surfing on battery. I wonder how much energy recent kernels save on other systems.
Fixing Suspend for the MSI Wind U110 in 2.6.34 and 2.6.35
The MSI Wind U110 suddenly stopped going into suspend more in newer kernels starting at 2.6.34. A kernel developed found where the issue is located. Actually the system did go into suspend mode, but it came right back immediately.
The issue is very easy and quickly solved, though, with a single simple command:
echo LID | sudo tee /proc/acpi/wakeup
Now I can go into suspend again, and the system still comes back from suspend as expected, nice! :)
Unfortunately for some reasons this does still not mean that suspend is working in Ubuntu 10.04 for me. Probably an issue related to the updated Xserver in 10.04. Though I can suspend and resume now, X crashes and restarts after resume.
The issue is very easy and quickly solved, though, with a single simple command:
echo LID | sudo tee /proc/acpi/wakeup
Now I can go into suspend again, and the system still comes back from suspend as expected, nice! :)
Unfortunately for some reasons this does still not mean that suspend is working in Ubuntu 10.04 for me. Probably an issue related to the updated Xserver in 10.04. Though I can suspend and resume now, X crashes and restarts after resume.
Backlight Control on MSI U110 Netbook
I've managed to get the backlight working roughly as well! All I needed to do was to load msi-laptop with the parameter force=1. The problem is that there is so far very little scaling, I can only set brightness to 0 (very dark) or 1-8 (all "very bright"). Check for updates to get it working well with KDE.
I've contacted the driver developers and I hope we can make some progress on the drivers soon.
I've contacted the driver developers and I hope we can make some progress on the drivers soon.
Saving 33% or 3 Watts of Power with your Netbook (here a Poulsbo system)
I've tried around a lot to see how much more power I can save on my system. An easy step with lots of success was to configure the laptop tools to run automatically. Check /etc/defaults/acpi-support and looks for LAPTOP_MODE, set it to true. Then you have to go to /etc/laptop-mode/ and configure first laptop-mode.conf and then the additional settings in the conf.d subdirectory. This could already save me at least 1 watt of power with very, very little hassle.
Poulsbo
I've tried around a lot with my X system, because it can draw a lot or little power depending on its settings. E.g. if you reduce the backlight you can save at least 2 watt power. Unfortunately the backlight controls on my system don't work - I'm happy I've managed to get the driver to run at all. (Check my special article on the MSI Wind U110 for more on that.) Hence at least for now I need to set my backlight to the level I want before booting Linux.
But I did find out that disabling vsync saves quite a substantial amount of power, I think about 0.5 watt. Most of the savings come from the cpu staying in idle longer on average then (about 22 msecs instead of about 4-8 ms). The catch is that with that setting enables, xvideo and vaapi no longer work after standby. Browsing is still fine, but probably no youtube, either. The whole system hangs when an application tries to use xv. So I had to disable the setting again - which actually was the step to put my netbook in a lower power mode than the carefully customized windows installation can manage, too bad.
If I pass it or any options (except debug) to the psb module during load, or load it myself during boot, X or suspend won't work at all or properly or properly after standby.
In the xorg.conf I have the standard settings for psb:
Ralink Wifi
Another big one was the wifi adapter. Disabling it saves about 1.5-2 watts power, but of course I wanted to be able to have it running and save energy as well. I installed the newest driver from ralink's homepage. The important step was to go into the os/linux/ directory and edit the config.mk file to enable HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y, otherwise NetworkManager would no longer work with it. Then I studied the documentation and found the command "iwpriv ra0 set PSMode=Fast_PSP" put my card into a low power mode which still keeps a good and rather fast connection - better than in Windows, there this powersaving mode does not exist and the MAX_PSP is unusable.
Last Hint
A last additional hint is to kill knotify4.
Conclusion
In the end my system runs with 5.7 watts in a full KDE 4.3.2 X session. With mplayer and VAAPI I can now watch movies for at least 8 hours. A great demonstration of how far Linux has already come in saving power.
The only thing missing now is a working backlight control and a working XVideo without vsync would be great. Ok, an SSD would be great, too. So let me know if you have one you no longer need! ;) Or if you know how to fix the backlight control on a poulsbo system.
Maybe I should try to compile the IEGD driver for my system.
Update
I've manged to get it all running, including no_vsync, and videoacceleration before and after suspend. The trick is to do a double console switch after resume. Then VAAPI still works even after the suspend and resume - at least with xserver-xorg-video-psb version 0.36.0-0ubuntu1ppa9.10+1.
Update2
I've managed to get the backlight working roughly as well! All I needed to do was to load msi-laptop with the parameter force=1. The problem is that there is so far very little scaling, I can only set brightness to 0 (very dark) or 1-8 (all "very bright").
Update3
Check out this article with more general advice including how ensure your battery lives long and prospers. Backlight is fixed by now, I've written a patch for the psb driver (in testing at the ppa right now). With recently kernels, the power usage dropped down to 4.8 Watts without wifi! This means it lasts much longer in Linux than in Windows now.
Poulsbo
I've tried around a lot with my X system, because it can draw a lot or little power depending on its settings. E.g. if you reduce the backlight you can save at least 2 watt power. Unfortunately the backlight controls on my system don't work - I'm happy I've managed to get the driver to run at all. (Check my special article on the MSI Wind U110 for more on that.) Hence at least for now I need to set my backlight to the level I want before booting Linux.
But I did find out that disabling vsync saves quite a substantial amount of power, I think about 0.5 watt. Most of the savings come from the cpu staying in idle longer on average then (about 22 msecs instead of about 4-8 ms). The catch is that with that setting enables, xvideo and vaapi no longer work after standby. Browsing is still fine, but probably no youtube, either. The whole system hangs when an application tries to use xv. So I had to disable the setting again - which actually was the step to put my netbook in a lower power mode than the carefully customized windows installation can manage, too bad.
If I pass it or any options (except debug) to the psb module during load, or load it myself during boot, X or suspend won't work at all or properly or properly after standby.
In the xorg.conf I have the standard settings for psb:
Option "AccelMethod" "EXA"
Option "DRI" "on"
Option "MigrationHeuristic" "greedy"
Option "IgnoreACPI" "yes"
Ralink Wifi
Another big one was the wifi adapter. Disabling it saves about 1.5-2 watts power, but of course I wanted to be able to have it running and save energy as well. I installed the newest driver from ralink's homepage. The important step was to go into the os/linux/ directory and edit the config.mk file to enable HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y, otherwise NetworkManager would no longer work with it. Then I studied the documentation and found the command "iwpriv ra0 set PSMode=Fast_PSP" put my card into a low power mode which still keeps a good and rather fast connection - better than in Windows, there this powersaving mode does not exist and the MAX_PSP is unusable.
Last Hint
A last additional hint is to kill knotify4.
Conclusion
In the end my system runs with 5.7 watts in a full KDE 4.3.2 X session. With mplayer and VAAPI I can now watch movies for at least 8 hours. A great demonstration of how far Linux has already come in saving power.
The only thing missing now is a working backlight control and a working XVideo without vsync would be great. Ok, an SSD would be great, too. So let me know if you have one you no longer need! ;) Or if you know how to fix the backlight control on a poulsbo system.
Maybe I should try to compile the IEGD driver for my system.
Update
I've manged to get it all running, including no_vsync, and videoacceleration before and after suspend. The trick is to do a double console switch after resume. Then VAAPI still works even after the suspend and resume - at least with xserver-xorg-video-psb version 0.36.0-0ubuntu1ppa9.10+1.
Update2
I've managed to get the backlight working roughly as well! All I needed to do was to load msi-laptop with the parameter force=1. The problem is that there is so far very little scaling, I can only set brightness to 0 (very dark) or 1-8 (all "very bright").
Update3
Check out this article with more general advice including how ensure your battery lives long and prospers. Backlight is fixed by now, I've written a patch for the psb driver (in testing at the ppa right now). With recently kernels, the power usage dropped down to 4.8 Watts without wifi! This means it lasts much longer in Linux than in Windows now.
Subscribe to:
Posts (Atom)

