how to make cpugovernor intel_pstate stable?

15,285

Solution 1

It is not possible for your processor to always be at your max turbo rate of 3200MHz all the time. If you have many cores active at once, then the max frequency will be only 2.6Ghz, and that limit is fundamental within the processor itself (see also your i7z screenshot - Max Turbo Multiplier line). However you can easily pretty much have all CPUs always at 2.6 GHz by setting the min and max percent numbers accordingly. However, note that you will still observe sometimes less frequency, as the processor can back off by itself under very low load conditions. Even easier would be to set turbo to off and performance mode, effectively makes all CPU run at 2.4 GHz all the time (but again, the processor itself can back off under extremely low load).

Example for setting 2.6Ghz (if I did my math properly):

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

Example for the non-turbo method:

echo "1" | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
powersave
powersave
powersave
powersave
powersave
powersave
powersave
powersave
$ sudo su
# for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "performance" > $file; done
# exit
exit
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
performance
performance
performance
performance
performance
performance
performance
performance

Solution 2

There is a command line tool for that called pstate-frequency.

To install it, simply follow the instructions in the repository.

What the script does is that it allows you to tell your CPU your preferred settings regarding clock speed, governor and turbo boost.

But keep in mind, since newer Intel CPU's are highly optimized and do power management on their own you cannot force your CPU, rather suggest what you want.

See this from the description of pstate-frequency:

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.

To get the highest possible clock speed (permanently 3.2 GHz (ideally)) and the performance governor execute this after installing the script:

sudo pstate-frequency --color -S -p 3

You can use pstate-frequency -G --color to get your currently set power plan.

For me using a intel i7-4790K I get permanently 4400 MHz with all cores.

To check your current CPU clock you can use:

watch -n 0,3 'cat /proc/cpuinfo | grep "MHz"'

This will list the clock speed of all your CPU threads.

In my case after setting power plan '3' ([...] -p 3) (performance) I get:

cpu MHz     : 4399.843
cpu MHz     : 4400.156
cpu MHz     : 4391.093
cpu MHz     : 4400.000
cpu MHz     : 4400.000
cpu MHz     : 4400.468
cpu MHz     : 4400.156
cpu MHz     : 4361.718

Solution 3

With an Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz and an active intel_pstate/status I was only able to set the max frequency - it would still fluctuate between the hardware min freq. (1,2 GHz) and my set max-freq.. I was able to solve that by setting the passive mode beforehand.

echo passive > /sys/devices/system/cpu/intel_pstate/status
cpupower frequency-set --min 2400MHz --max 2400MHz
Share:
15,285

Related videos on Youtube

Sanjoy Basak
Author by

Sanjoy Basak

Updated on September 18, 2022

Comments

  • Sanjoy Basak
    Sanjoy Basak over 1 year

    I am trying to set to a specific frequency in cpu governor. However, I am not being able to do so. My processor is 12*Intel(R) Xeon (R) CPU E5-2620 v3 @2.40 GHz

    With intel_pstate driver it gives freq range of 1.20 GHz -3.20 GHz. The current freq scaling, I can not set to a specific freq. I set the governor to performance. But it does not help. cpufreq-set -r -f 3.2GHz –does not work;

    I tried to set the lower freq; cpufreq-set -r -d 3.2GHz; does not show any error, but even then the freq keeps on varying with time.

    I disabled intel_pstate (on boot) and activated acpi driver. But with acpi, the max I can get is 2.4 GHz at 12 cores. This 2.4 GHz, I can make stable all the time with cpufreq-set -r -f. But I can not set it to 3.2 GHz.

    Could anyone please tell me how to set use the cpugovernor, so I can set frequency to 3.2 GHz? My OS is ubuntu 14.4.3 LTS and kernel version is 3.19.0-25-generic.

    The cpufreq-info shows the following result.

    analyzing CPU 0:
      driver: intel_pstate
      CPUs which run at the same hardware frequency: 0
      CPUs which need to have their frequency coordinated by software: 0
      maximum transition latency: 0.97 ms.
      hardware limits: 1.20 GHz - 3.20 GHz
      available cpufreq governors: performance, powersave
      current policy: frequency should be within 3.20 GHz and 3.20 GHz.
                      The governor "performance" may decide which speed to use
                      within this range.
      current CPU frequency is 2.85 GHz.
    

    For other cores also, the results are like this and current freq varies with time.

    screenshot_i7z

    pstate freq screenshot

    • Admin
      Admin over 8 years
      I checked with i7z. The result is the same. The cpu current freq is varying with time. Is there any way to make freq stable? I attached a screenshot. Please have a look.
    • Admin
      Admin over 8 years
      You can disable pstate and use cpufreq-indicator but you really only have the option to throttle I think. Again you have options like performance and such but also have individual frequency options as well.
    • Admin
      Admin over 4 years
  • Sanjoy Basak
    Sanjoy Basak over 8 years
    Hi..thanks for the suggestions.i tried with pstate, but the result is the same. when i put the cpu governor to max performance it shows min freq 3200 MHz, but when i watch the current cpu freq, i see it changes all the time between 1.5 to 3.2 GHz. Is there any other way to solve this problem? For example, changing any setting in bios or using any other cpu governor?
  • Sanjoy Basak
    Sanjoy Basak over 8 years
    Thanks, I got the point. Actually my application require more processing speed. Yes, I can set freq to 2.4 GHz all the cores even with acpi. But as the application requires more so I was trying to check the possibility if somehow I can set to constant 3 or 3.2 GHz. However, thanks a lot Doug, Flatron and mchid.
  • dat tutbrus
    dat tutbrus almost 7 years
    Underrated answer. You need to insert intel_pstate=enable into the /etc/grub/default though (after quiet splash)
  • Flatron
    Flatron over 6 years
    Only works though if the CPU supports p_states. Not all Intel CPUs do.. Had to find this out the hard way ;)
  • Boscoe
    Boscoe over 5 years
    Keep in mind that your initial statement isn't always true. With features in the BIOS of certain server manufacturers (Dell, for example), it's possible to peg your CPUs to a fixed Turbo above the stock speed. Dell calls this option "Dell Controlled Turbo". Otherwise a great answer. :)
  • WinEunuuchs2Unix
    WinEunuuchs2Unix about 3 years
    Doug I think the newest answer below is worth a look