How to set governors for Intel to work as old good ondemand?
Solution 1
For compatible processors, by default Ubuntu now uses the intel_pstate CPU frequency governor, whereas it used to use the acpi_cpufreq CPU frequncy governor.
The intel_pstate drive does not have ondemand
mode, but its powersave
mode should be the equivalent of the acpi_cpufreq ondemand
mode. Your system should default to powersave
mode about 1 minute after boot, and via the /etc/init.d/ondemand
script. In the recent past, that script was not properly dealing with the intel_pstate case, but it should have been fixed for all use cases by now. Reference.
To answer your actual questions:
A.) The master min and max frequencies are stored as percentage numbers.
cat /sys/devices/system/cpu/intel_pstate/min_perf_pct
cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
The interpretation of those numbers is a function of the turbo enabled or disabled flag, and in my opinion there is an inconsistency in the definitions.
cat /sys/devices/system/cpu/intel_pstate/no_turbo
Example from my i7-2600K: min freq 1.6GHz; max non-turbo 3.4GHz; max turbo 3.8GHz.
Therefore as percentages:
Turbo off: max = 100%, min = 47.1%
Turbo on: max = 100%, min = 42.1%
$ cat /sys/devices/system/cpu/intel_pstate/no_turbo
0
$ cat /sys/devices/system/cpu/intel_pstate/min_perf_pct
42
$ cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
100
and
$ cat /sys/devices/system/cpu/intel_pstate/no_turbo
1
$ cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
100
$ cat /sys/devices/system/cpu/intel_pstate/min_perf_pct
42
B.) The intel-pstate powersave
mode should be the equivalent of the acpi-cpufreq ondemand
mode.
C.) There is something wrong, resulting in your grief. There have been other reports similar to yours. Myself, I do not know the root issue, but there have also been reports of incompatibilities with cpufrequtils. I do not know if they are true or not, as I don't use any such things. I only use the most primitive level of controls with the intel-pstate driver.
Solution 2
I have set it in .bashrc
as an alias (and as root
), because I experienced similar problems.
The aliases look like this:
alias performance="echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
alias powersave="echo powersave > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
alias ondemand="echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
You can then write powersave
to enable power-saving option on the BASH
console.
When I want to use a specific scaling governor, i put it in /etc/rc.local
:
#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
for i in `ls -d /sys/devices/system/cpu/cpu*|grep -v cpufreq|grep -v cpuidle`; do echo ondemand > $i/cpufreq/scaling_governor; done
exit 0
You probably have more than one processor, so edit it accordingly. I'm too lazy to write a short script, but I'll do that if you ask me to do so :)
EDIT: I added the script to /etc/rc.local
Related videos on Youtube
kurp
Updated on September 18, 2022Comments
-
kurp over 1 year
I used to work on my laptop on
ondemand
governor, which was switching CPU frequency depending on CPU usage. It worked quite nice for years and had three very important advantages:- low hardware temperatures
- quiet fan
- high performance when needed
Now I've upgraded both my laptop (to Lenovo B5400, Intel Pentium 3550M) and system (Ubuntu 14.10) and I've found that:
- only
performance
andpowersave
governors are available;ondemand
is no longer available and supported - something has been changed in setting files, because current governor and min/max speeds are restored to defaults every time I boot up
In consequence my system:
- still turns governor back to
performance
, which is wrong, I believe - whatever governor is, cpufreq-info tells me that "frequency should be within 2.30 MHz and 2.30 GHz" although available frequencies starts from 800MHz
I've tried to edit
/etc/init.d/cpufrequtils
defining the following setting:ENABLE="true"
GOVERNOR="powersave"
MAX_SPEED="2300000"
MIN_SPEED="800000"
I've also tried to edit
scaling_min_freq
file in/sys/devices/system/cpu/cpu0/cpufreq
and set it to 800000.And, guess what, after restarting system I'm again in
performance
mode with frequency "scaled between" 2.30GHz and 2.30GHz.
Could you, please, explain me:
a) where exactly in Ubuntu 14.10 are a master settings of min/max CPU frequencies?
b) how to define frequencies and governors to achieve the same result as old good
ondemand
? (I would like to work on the lowest frequency possible and go up only on heavy load)c) and how to avoid resetting what I defined, of course.
I'd be grateful for explanations.
-
kurp over 9 yearsOh, and I know that there is a lot of similar questions here, but, please, note that part of them are out-of-date (due to shorten list of available governors for new Intel drivers) and there is also a lot of setting files indicated without clear explanation which of them are "master" and which settings should be changed to set things up definitely without risk of overwriting by some other settings.
-
Admin over 9 yearsI had the same problems and this worked for me: askubuntu.com/questions/541143/…
-
Izkata over 7 yearsAha... Mine was stuck at 50% after upgrading from 14.04 to 16.04 and it took me a half hour to find this answer. This fixed it for me:
sudo sh -c 'echo -n 80 > /sys/devices/system/cpu/intel_pstate/max_perf_pct'
(for 80%, which is far better and appears to be low enough the fan doesn't go crazy) -
WinEunuuchs2Unix over 5 years+1 for "Your system should default to powersave mode about 1 minute after boot". I wrote a script to prove
powersave
was being forced but didn't know/etc/init.d
was causing it: askubuntu.com/questions/1021748/…