How to scale intel_pstate driver on Ubuntu 15.04?

I nearly tried all the solution to scale the cpu frequency but no success. I have Intel Core i5-3210m 2.5Ghz-3.1Ghz. I want to permanently set it to 1.6Ghz with no turbo boost to improve battery timings. Please tell it accordance with intel_pstate driver.


Solution 1:

To limit the upper CPU frequency with the intel_pstate driver to 52% do:

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

Note 1: In calculating 52%, I have assumed that you have turbo enabled, for a max pstate of 31. Therefore 1.6 / 3.1 = 52%. If you have disabled turbo then the number would be 64%. There is no need to specifically disable turbo, as with this limit, it will never go into the turbo range anyhow.

Note 2: Depending on your applications and processor, limiting CPU frequency might not result in the longest battery life. In some cases, completing the task faster, via higher CPU frequency, and therefore allowing some CPUs to go into deep sleep (highest C state) sooner and for longer, can result in less power consumption overall.

Note 3: The solution is not permanent, and the setting will be lost upon re-boot. I suggest you try it for awhile, report back and then we can think about how to make it permanent. There are other higher level tools for this, but I never use them. Someone else might provide another anwswer involving the higher level tools.

An example (different processor, different numbers). CPU 7 is under 100% load:
Before setting upper frequency limit:

$ grep MHz /proc/cpuinfo
cpu MHz         : 3697.234
cpu MHz         : 3655.796
cpu MHz         : 3699.890
cpu MHz         : 3742.257
cpu MHz         : 3613.562
cpu MHz         : 3670.273
cpu MHz         : 3628.968
cpu MHz         : 3799.898

Now, limit the upper frequency, and check it:

$ echo "50" | sudo tee /sys/devices/system/cpu/intel_pstate/max_perf_pct
50
$ cat /sys/devices/system/cpu/intel_pstate/max_perf_pct
50
$ grep MHz /proc/cpuinfo
cpu MHz         : 1899.882
cpu MHz         : 1900.015
cpu MHz         : 1899.882
cpu MHz         : 1893.906
cpu MHz         : 1899.351
cpu MHz         : 1900.015
cpu MHz         : 1899.750
cpu MHz         : 1899.882

EDIT: Watch for backporting of the intel_pstate driver changes for whatever is your stock kernel. I know backporting is being done, but I do not know the release timelines.

To make the change always occur during boot, first make it a script, for example:

$ cat set_cpu_max_perf_pct
#! /bin/bash

echo 52 >/sys/devices/system/cpu/intel_pstate/max_perf_pct
echo -n "intel_pstate maximum performance request is (percent): "
cat /sys/devices/system/cpu/intel_pstate/max_perf_pct

Test the script, running as sudo. Then refer to one of the many other questions and answers that address making it run during boot. Say, this one.

Alternatively, you can install tools like TLP which have these settings in the configuration file with parameter for battery or ac and automatic switch.