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

2 Answers2

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

Doug Smythies
  • 16,146
2

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