4

Recently I've been trying to investigate why my laptop is so slow. I found out that it runs at ~600Mhz, regardless of the power supply being plugged in or not. Note that it's Intel i5-2540M nominally running at 2.60GHz. So I find it very strange to be clocked at ~600Mhz all the time, even if it's loaded with some computations. This even affect web browsing, so it's quite annoying.

I further investigated this issue and it turns out the clock is related to so called CPU governor mode. On my system it's always set to powersave, no matter if the power supply is plugged in or not. I think it should be switched to performance mode (or something in between, if possible) when the power supply is plugged in. Note that switching to performance mode manually solves the problem - the laptop becomes much more responsive.

Does Ubuntu have any support for such automatic switching of CPU governor modes? Is there any package I should install or a configuration file which I need to edit?

I am aware of the pm-utils package which provides some power related notifications so I could use it as the foundation of a simple script which does the CPU governor switching fully automatically. Still I might be unaware of some limitations or gotchas of such an approach. So I want to know if this is the right one.

Thanks in advance!

BTW, my setup is Ubuntu 14.10

$ uname -a
Linux aromanek-laptop 3.16.0-34-generic #47-Ubuntu SMP Fri Apr 10 18:02:58 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

$ cat /proc/cpuinfo 
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i5-2540M CPU @ 2.60GHz
stepping    : 7
microcode   : 0x12
cpu MHz     : 633.242
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
bogomips    : 5188.00
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

UPDATE:

$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver
intel_pstate
intel_pstate
intel_pstate
intel_pstate

$ sudo cat /sys/kernel/debug/pstate_snb/d_gain_pct
0
$ sudo cat /sys/kernel/debug/pstate_snb/p_gain_pct
20
$ sudo cat /sys/kernel/debug/pstate_snb/i_gain_pct
0
6
  • Which frequency scaling driver are you using? Do: cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver and edit your question to include the result. You should not, indeed do not want, to run performance mode with the intel-pstate driver, and powersave mode should ramp up the CPU frequency as required (it is basically the same as ondemand mode for the acpi-cpufreq driver. The question is why doesn't it? Apr 24, 2015 at 20:17
  • If your scaling driver is intel_pstate, then please also add your question the outputs from: sudo cat /sys/kernel/debug/pstate_snb/d_gain_pct and sudo cat /sys/kernel/debug/pstate_snb/p_gain_pct and sudo cat /sys/kernel/debug/pstate_snb/i_gain_pct. (just trying to determine if your processor is Bay Trail or other nick name). Apr 24, 2015 at 20:29
  • Your processor seems to be Sandy Bridge. It should ramp up the CPU frequency as required by increased load. However, there have been reports of issues after resume from suspend. You could try forcing the acpi-cpufreq driver (I'll make an answer with how in a minute). Apr 24, 2015 at 21:38
  • 1
    I think I know what was wrong, and why switching to performance mode "kicks" it out of the stuck state. I have proposed a patch to correct the issue. May 27, 2015 at 15:00
  • Good to know the problem has been identified. May 27, 2015 at 19:43

2 Answers 2

3

You should try forcing the acpi-cpufreq scaling driver. To do so, edit (as sudo) the /etc/default/grub file and change the "GRUB_CMDLINE_LINUX_DEFAULT" line, adding this (and my example has some other stuff for my case that was there before):

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 intel_pstate=disable crashkernel=384M-:128M"

Then run:

sudo update-grub

Then re-boot. You should find that your Ubuntu system will default to the ondemand governor about 1 minute after boot up.

I would be interested to pursue why you seem to be having issues with the intel-pstate driver.

To answer your actual question, look into the laptop-mode-tools package and it configuration

4
  • Indeed, disabling the intel_pstate driver helped - the CPU clock is now correctly managed as the load increases and decreases. What else could I do to investigate the issue with the intel_pstate driver? BTW, I've just started the upgrade procedure to Ubuntu 15.04. We'll see how the intel_pstate driver behaves on this distro. Nevertheless, thanks! Apr 25, 2015 at 19:27
  • The intel_pstate driver is unchanged between the currrent 14.10 and 15.04 kernels, regardless it would be interesting to check. Do you know if current misbehavior only starts after any hibernate or suspend event? Apr 25, 2015 at 19:57
  • Hi, I had a similar problem with a Thinkpad x220 on Ubuntu 14.04. I found the answer in a different question. I had to remove cpufreqd to let the system regain control of the cpu frequency. To recreate the error, I think I need to be in a low battery state, let the laptop suspend, wake up. Then my cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq is set to 800000 askubuntu.com/questions/517844/why-is-my-cpu-frequency-stuck/…
    – Trygve
    Sep 10, 2015 at 16:40
  • @DougSmythies I think it would be best to specify that the intel_pstate=disable parameter is key, and even remove the other ones from your example. Inexperienced users might be unsure which parameters are "other stuff" and add them all.
    – Adrian
    Nov 30, 2016 at 17:45
1

My laptop doesn't seem to come with an "ondemand" scheduler for reasons that eludes me, but my solution was to switch between powersave and performance based on the state of the AC Mains. I've added a udev rule with the following content:

/etc/udev/rules.d/50-scaling-govoner.rules

    SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/usr/bin/cpufreq-set -g performance -r"
    SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/usr/bin/cpufreq-set -g powersave -r"

Br, Martin

You must log in to answer this question.

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