Is it possible to set a *constant* lowest CPU frequency under the modern PSTATE driver

cpu-frequency

The new pstate Intel driver pisses me off for good, because they have removed the good old powersave governor that allowed me to set the lowest available CPU frequency and run my numerical simulations for hours or days in a nicely silent, cold laptop. To make things worse, what they call now powersave is essentially the old governor ondemand, i.e. a mode in which the CPU frequency rams up with the load, and with it the damn fan noise:

Since these policies are implemented in the driver, they are not same as the
cpufreq scaling governors implementation, even if they have the same name in
the cpufreq sysfs (scaling_governors). For example the "performance" policy is
similar to cpufreq(TM) "performance" governor, but "powersave" is completely
different than the cpufreq "powersave" governor. The strategy here is similar
to cpufreq "ondemand", where the requested P-State is related to the system load.

(Extracted from https://www.kernel.org/doc/Documentation/cpu-freq/intel-pstate.txt)

Now, please, is there any other way to keep my CPU frequency at a minimum? It's really important for me. I just prefer to dump the laptop through the window if I eventually cannot set a constant, lowest CPU frequency. That is how I use my laptop and that is what I want a laptop for, and I have been trying to achieve this for several days already!

I'm trying this, and it doesn't work:

echo 42 | sudo dd of=/sys/devices/system/cpu/intel_pstate/max_pref_pct

to set the maximum speed at 42%, and it doesn't have any affect, the CPU keeps on going to 100% whenever I do something. What am I doing wrong? (should I restart some service or something?)

Is there any way to get this? Also, will a non-Intel CPU allow me to do that? I don't mind buying another laptop it that is going to solve the problem.

Best Answer

Well, well, turns out that the new pstate Intel driver is awesome, but first one needs to practice a bit of the ancient, lost art of reading the documentation.

I'll leave my question as it is because, judging by all the grief and frustration I see scattered all around the internet, I am not the first to have this issues.

The new CPU driver has lots of options, but I will restrict my explanation to something simple and, for me, more than enough and satisfactory. First of all:

sudo apt-get install linux-cpupower

(or the equivalent in your non-debian based distros)

There are now 2 behaviors (governors) with the names powersave and performance but that is quite an unfortunate naming scheme, because these governors have nothing to do with those that bear the same names in the old driver:

  • powersave means now variable frequency that depends on the load, i.e. this is essentially the old ondemand governor. You get to set the minimum and maximum frequency, and if that maximum frequency is set to the maximum frequency your CPU is able of (which I believe it's the default) then you don't save a crap. You may even crank up the minimum frequency to the second highest value, and the result will be the CPU nearly at full throttle 24/7 and the governor will still be named powersave. They should have named this governor VARIABLE or something similar, avoiding a lot of confusion among users and sparing the developers a lot of false reports of kernel bugs.

  • performance means here constant frequency, no matter the load, and this depends on what the user has set as maximum. When this governor is set, the mininum frequency is ignored and the CPU runs at the frequency you set as maximum. If as such you have set a very low frequency, then you will not see any special performance or anything, you just will get a slowed down CPU at constant frequency. So they'd better named this governor CONSTANT or something similar, sparing frustration to many people like me, used to the old scheme.

So, here are some examples that work like a charm, at least with kernel 4.14. I will use as minimum and maximum frequency the values for my CPU: 0.4 and 3.1 GHz. See yours with cpupower frequency-info

CONSTANT, LOWEST FREQUENCY IN ALL CORES

This IS what I wanted! We get that by setting the constant frequency governor and setting the lowest available frequency as the maximum:

sudo cpupower frequency-set -g performance
sudo cpupower frequency-set -u 400MHz

CONSTANT, HIGHEST FREQUENCY IN ALL CORES

(You see this asked very often for desktop computers where it makes sense, although there are also people out there willing to destroy their laptop fan)

sudo cpupower frequency-set -g performance
sudo cpupower frequency-set -u 3100MHz

VARIABLE FREQUENCY BETWEEN THE MINIMUM AND MAXIMUM POSSIBLE FREQUENCIES IN ALL CORES

(this was called ondemand with the old acpi-cpufreq driver)

sudo cpupower frequency-set -g powersave
sudo cpupower frequency-set -d 400MHz
sudo cpupower frequency-set -u 3100MHz

VARIABLE FREQUENCY BETWEEN THE MINIMUM AND A MODERATE FREQUENCY IN ALL CORES

(maybe because you want to get some more speed when required but you don't want to reach the maximum and hear the fan blowing like mad)

sudo cpupower frequency-set -g powersave
sudo cpupower frequency-set -d 400MHz
sudo cpupower frequency-set -u 1200MHz

And so on. It is very easy and works really well. You can set too a constant low frequency in one core where the heavy numerical stuff is running, while you leave a variable frequency in other core where you launch the more usual stuff (email, web browsing...). See taskset for more info.

Related Question