Fixing noise on Ubuntu Hardy 8.04, aka setting max_cstate
Not security related at all, but it took me so much time to figure this out, I want to share this with the world!
I own a Lenovo Thinkpad T60 that I like very much. There is one annoyance, and that is that when on battery, the laptop produces a high pitched noise when idle. It turns out that this has something to do with the ACPI state. States of C3 and higher made my laptop produce the noise. In Ubuntu Gutsy 7.10 there was a simple solution. I could force the laptop to never use anything higher that C2. That was done like this:
echo “2″ > /sys/module/processor/parameters/max_cstate
And everyone was happy! Noise gone, battery life still decent. All was good. Until I upgraded to Hardy. Hardy uses kernel 2.6.24, and for some reason the sysfs interface has been removed. So there is no way to set the max_cstate on the fly. See here for the bug report.
In theory the ‘processor’ module should be able to take an option ‘max_cstate=2′. But setting this option didn’t seem to work. It took some time to figure out why, but the reason is simple. The ‘processor’ module is in the initrd image, and is loaded before /etc/modprobe.d/options is inspected. Luckily, the solution is simple:
Add the following line to your /etc/modprobe.d/options file:
options processor max_cstate=2
Then update the initrd image using the following command:
sudo update-initramfs -u
The initrd image is now updated to include the option. Then reboot. Verify if it works:
$ cat /proc/acpi/processor/CPU0/power |grep max_cstate
max_cstate: C2
Success! Again, no more noise…
Tags: hardy, lenovo, max_cstate, t60, Ubuntu
July 25th, 2008 at 1:41 am
Well done! I build a custom kernel for the express purpose of getting rid of the initramfs, but this is a fantastic find.
July 25th, 2008 at 3:03 am
I did similar with my Lenovo X61 (which I like very much as well), but did have a noticeable battery drop. 45 mins to 1 hour off of my usual 4.5 hour time.
But that wine is annoying. My C2D MacBook has it as well, but the casing on the MacBook must be thicker as you have to put your ear right up to it to notice it. I understand that it is an issue with most, if not all C2D mobile CPUs.
August 5th, 2008 at 8:20 pm
Thank you! I have been working on this with my Macbook CD for days, and now no whine, I haven’t noticed a significant drop in battery life. This is a lifesaver.
August 20th, 2008 at 8:35 pm
Great! I just installed Ubuntu on my Macbook and the whining was really starting to get one my nerves…enough to just stick with OSX for now, but now I don’t have to. Thanks a lot!
September 7th, 2008 at 12:15 pm
Excellent post :).
Did this on my X61s running Debian Lenny and it worked like a charm.
Thank you!
September 17th, 2008 at 9:26 am
Thank you sooooooo much!
October 12th, 2008 at 12:24 pm
Thank you, it helped me with my old Acer Aspire running Archlinux. I can use latest kernel again, and the laptop stays quiet!
I adapted your solution for Archlinux and add link to your blog. http://wiki.archlinux.org/index.php/Acer_Aspire_1691_WLMi#ACPI
Thanks again!
October 17th, 2008 at 2:10 am
[...] *The above solutions indeed do not work for the 2.6.24 kernel, however a workaround which does not require installing Ubuntu Tweak can be found here: http://www.inliniac.net/blog/2008/07/25/fixing-noise-on-ubuntu-hardy-804-aka-setting-max_cstate.html [...]
November 9th, 2008 at 2:41 am
Awesome! You helped me fix the annoying whine on my Macbook!
November 18th, 2008 at 7:28 pm
Helped me too! Thank you!!