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…

Update 21st of March 2010 for Ubuntu Karmic 9.10. The solution for this for Karmic was posted by Markus in the comments below, I’m replicating it here for convenience. Thanks Markus!

Karmic introduces the new grub2 so there isn’t any menu.lst anymore. In grub2 some things (like default kernel options) are done in /etc/default/grub, so you have to edit this file:

sudo pico /etc/default/grub

search for a line GRUB_CMDLINE_LINUX=”” and change to (or add if it doesn’t exist):

GRUB_CMDLINE_LINUX=”processor.max_cstate=2″

press STRG+x and y to save and exit and execute the grub update:

sudo update-grub

After a reboot the max cstate should then be C2!

27 thoughts on “Fixing noise on Ubuntu Hardy 8.04, aka setting max_cstate

  1. Well done! I build a custom kernel for the express purpose of getting rid of the initramfs, but this is a fantastic find.

  2. 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.

  3. 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.

  4. 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!

  5. Excellent post :).

    Did this on my X61s running Debian Lenny and it worked like a charm.
    Thank you!

  6. Pingback: Sistemas Operativos SOS » Cómo instalar Ubuntu (8.04) en un MacBook

  7. THis did NOT work for me. When I run the command : I see the following output
    cat /proc/acpi/processor/CPU0/power |grep max_cstat
    max_cstate : C8.

    It does not make it C2.
    I am a newbie to Ubuntu. Please help

  8. Never mind. It worked for me after a restart.
    This has tremendously helped my vmware performance.

    Incredible help. Thanks a Million

  9. Works under Intrepid too.
    Thank you.

    However, this reduces battery lifetime; I have a x300 Thinkpad and compared with having C4 enabled power usage is about 1 W higher.

  10. Good job! this works also for Macbook with ubuntu 8.10 🙂

  11. Thank You! It’s realy works on my asus u5f with ubuntu 8.10:)

  12. Nice fix mate!
    I used to have problems with VmWare being painfully slow. Now the pain has subsided…. somewhat….

    Cheers!

  13. It doesn’t work in Jaunty(
    Does anybody know how to fix it?

  14. In Jaunty the method no longer works. However, if you add ‘processor.max_cstate=2’ to the kernel line in /boot/grub/menu.lst you can set you max_cstate and thus prevent the annoying whine.

  15. Hi,

    Karmic introduces the new grub2 so there isn’t any menu.lst anymore. In grub2 some things (like default kernel options) are done in /etc/default/grub, so you have to edit this file:

    sudo pico /etc/default/grub

    search for a line GRUB_CMDLINE_LINUX=”” and change to (or add if it doesn’t exist):

    GRUB_CMDLINE_LINUX=”processor.max_cstate=2″

    press STRG+x and y to save and exit and execute the grub update:

    sudo update-grub

    that will rewrite your actual grub configuration with the new kernel option. This method will affect all kernels in /boot. Works for me on Fuckb…srz…Macbook 2,1 under Karmic.

    Greets, markus.

  16. The solution for Karmic is not working for me, the whine is still there …. actually I had removed the whine (not sure what I did) but when I installed a new kernel version now I cant remove it ….. I have brand new sony vaio vpcf111fx with an i7 porocessor … any suggestions?

  17. Pingback: HOW-TO install a Miminal Ubuntu and XBMC with sound over HDMI on the AppleTV | Vui Lang Thang

  18. thank you and markus, it worked for me on a t61 with ubuntu 14.04
    but i have a way different “solution” that also worked:
    play a video in the background, it won’t let the cpu rest. 🙂 a small video causing 5% cpu consumption is enogh.

Comments are closed.