25

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.

12
  • 1
    Have you played with /sys/devices/system/cpu/cpu*/cpufreq/scaling_*?
    – phemmer
    Feb 16, 2018 at 13:30
  • @Patrick I don't know, I have tried many things. I will have a look at it. If you know how to do this, please post it as an answer.
    – Mephisto
    Feb 16, 2018 at 13:37
  • cpupower frequency-set -u 800MHz should do (assuming 800MHz is the minimum speed of your cpu - so as to set the max the same as the min); to reset it just use the same command and replace 800MHz with whatever the maximum speed of your cpu is; for more information consult the manual for cpupower and cpupower frequency-set Feb 16, 2018 at 15:45
  • @don_crissti Are you sure you don't have intel_pstate=disable in grub? That's the only way I can do that, but then it is using the old acpi_cpufreq driver, which is not my question.
    – Mephisto
    Feb 16, 2018 at 17:30
  • 1
    Works OK with 4.15.3 and the older 4.14.13. If I have the time I'll try also the lts kernel. My cpu is a Sandy Bridge fwiw. Feb 16, 2018 at 18:07

3 Answers 3

26

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.

4
  • How are you verifying that performance governor actually sets a constant cpu frequency? When I do watch -x grep -E '^model name|^cpu MHz' /proc/cpuinfo the numbers bounce around all over, even when I change the governor to performance
    – jberryman
    Nov 21, 2019 at 3:30
  • Sadly doesn't work for me either. cpupower frequency-info has bizarre output like frequency should be within 1.20 GHz and 1.20 GHz....current CPU frequency: 3.16 GHz maybe it's the funky laptop I'm using [dell inspiron]. The only change I notice is if I change /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq then my idle freq. goes down slightly. Under load all cores still go all the way to the CPU max :(
    – rogerdpack
    Jan 25, 2020 at 9:55
  • Did you also tried using cpufrequtils? or tlp?
    – s.k
    Oct 19, 2020 at 12:20
  • It seems like this answer is no longer true. Intel pstate doesn't seem to let you tune the frequency manually if you have hwp enabled.
    – Marco
    Jun 3, 2021 at 7:24
3

It works for me with:

echo "50" | sudo tee /sys/devices/system/cpu/intel_pstate/max_perf_pct

it run only 50% performance/speed while CPU load is 100%

1
  • How can I make these changes persistent between reboots?
    – jap1968
    Apr 24, 2021 at 9:52
2

After wasting many days in searching for a solution to set a constant frequency (to run a scientific experiment), I finally gave up. I've tried many different solutions including the performance governor (as suggested by Mephisto), changing between active and passive mode of the intel_pstate driver, disabling the PPC protection, switching from intel_pstate to acpi-cpufreq, etc.

None of these options have any effect in setting a constant frequency. Then, I've found this comment in the kernel documentation:

For contemporary Intel processors, the frequency is controlled by the processor itself and the P-states exposed to software are related to performance levels. The idea that frequency can be set to a single frequency is fiction for Intel Core processors. Even if the scaling driver selects a single P state the actual frequency the processor will run at is selected by the processor itself.

So, there's no a reliable way to do that, P-States are just suggestions, the hardware would continue to decide on its own. On my processor (Intel J4105), it seems that the hardware completely ignores the settings coming from the software.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .