3

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.

AhmedBilal
  • 1,102

1 Answers1

7

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.

Doug Smythies
  • 15,448
  • 5
  • 44
  • 61
  • When I check cpufreq-info it sometime goes above 2Ghz. I think the command didn't work. – AhmedBilal Aug 28 '15 at 04:46
  • I'll edit a method of checking into my answer. – Doug Smythies Aug 28 '15 at 05:13
  • I am not familiar with cpufreq-info. I only trust primitives, as in the example I edited into my answer. I also trust results from turbostat. – Doug Smythies Aug 28 '15 at 05:26
  • When I repeatedly check it using grep command you mentioned it jumped at went to 3 Ghz sometime. – AhmedBilal Aug 28 '15 at 12:00
  • Odd. Did cat /sys/devices/system/cpu/intel_pstate/max_perf_pct ever change? Did the computer ever go into suspend in between? – Doug Smythies Aug 28 '15 at 13:49
  • When I entered the command you told. It changed to 52. And The computer never go into suspend in between. When I repeatedly enter the command grep MHz /proc/cpuinfo . It often jumps to 2-3 Ghz. – AhmedBilal Aug 29 '15 at 10:33
  • I am very interested to understand why you sometimes get a jump in frequency. And max_perf_pct never changed, correct? Are you comfortable compiling the kernel and/or trying different kernels? I'm trying to figure out how to get more information. – Doug Smythies Sep 01 '15 at 18:19
  • Thank you for helping so far. I can compile small program as I am beginner programmer. g++ or gcc. But, I don't think compiling kernel is an easy task for me. But, I can install different kernel. I installed 4.1.6 on Ubuntu 15.04 on this machine after looking in online tutorial. If you need to remotely access my computer to solve this problem, I will allow it to you. Thank you – AhmedBilal Sep 02 '15 at 07:22
  • 1
    Would you be willing to try kernel 4.2, to see if your issue still occurs? It has some changes to the intel_pstate driver. If the issue still occurs, there is also some additional trace information available, and that will be the next step. Are you running anything unusual that might be attempting to adjust target pstates on it own? – Doug Smythies Sep 02 '15 at 14:25
  • 1
    Thank you very much. I installed kernel 4.2 and from advance boot option I select Ubuntu Kernel 4.2 Generic. When I run the above commands it surprisingly limit the frequency. I checked several times. It max at 1.6Ghz which is perfectly fine. Now, please tell me how to limit the frequency permanently. Thank you again :) – AhmedBilal Sep 03 '15 at 05:05
  • If my answer worked for you please accept it. If it didn't mention what is wrong and I'll try to fix it. – Doug Smythies Sep 08 '15 at 23:48