The performance governor for cpufreq doesn't seem to behave as advertised

The kernel in use: 3.2.0-23-generic on Ubuntu 12.04LTS

For example, I issue the following command:

sudo cpufreq-set -c 0 -g performance

Then I go to /sys/devices/system/cpu/cpu0/cpufreq and type in the following:

sudo cat cpuinfo_cur_freq

Sometimes I get the max frequency (3600 MHz) when I do this and sometimes I get the min frequency (1600 MHz).

If I do:

cat scaling_governor

The output is performance, showing that the governor is in fact set to performance.

Then, to make it even more weird, if I do:

cpufreq-info

I get:

analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0 1 2 3 8 9 10 11
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 1.60 GHz - 3.60 GHz
  available frequency steps: 3.60 GHz, 3.60 GHz, 3.47 GHz, 3.33 GHz, 3.20 GHz, 3.07 GHz, 2.93 GHz, 2.80 GHz, 2.67 GHz, 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance
  current policy: frequency should be within 3.60 GHz and 3.60 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 3.60 GHz.
...

If you look at the current policy above, you will notice that it is telling me that the CPU should be pegged at 3.60 GHz. Yet, cpuinfo_cur_freq seems to tell a different story.


Sadly, in 12.04, the cpufreqd-deamon overrides any setting you do in other apps, whether in cpufreq-cli or in Unity-applet. The easiest solution I found while browsing the Ubuntu documentation was to edit /etc/cpufreqd.conf and first add a profile called On Demand as follows:

[Profile]
name=On Demand
minfreq=10%
maxfreq=100%
policy=ondemand
[/Profile]

Then you need to scroll down past #basic states, and choose the new On Demand profile as the profile for all the Basic states.

The current problem is that cpufreqd polls acpi for AC state, notices that the AC is connected, and then sets the cpu governor to performance, because that is what is set in the basic rules in the config file. It couldn't care less that you have selected another governor either by command line or by the scaling applet in Unity.

Remember to run

sudo service cpufreqd restart

after editing the config file.

Fun fact: cpufreqd seems to NOT override me if I choose the performance governor in the unity applet. But before I edited the config file, it would always override my choice for on-demand, and fall back to performance. I have no idea why.

I use the powernow-k8 driver, if that means anything to anyone reading this answer later.

Note: The Ubuntu documentation is severely lacking concerning cpufreqd (as well) and there might well be a better/easier/GUI-solution to the problem.