Ubuntu – Strange cpufreq scaling issues: regardless of governor, max cpufreq drops incrementally on wake

15.10cpucpufreqperformance

I am running Ubuntu Mate 15.10 64bit (kernel 4.2.0) on a Lenovo y5070 with an i7-4710HQ cpu. I noticed recently (possibly after a recent dist-upgrade) that certain programs were really slow. After a bit of investigation it appears that intel_pstate switches to the "powersave" governor by default which correctly scales down my cpufreq to about 600 MHz when I'm not doing anything intensive. However, it no longer scales up the cpufreq when I do something intensive.

To fix this I set GOVERNOR="performance" in:

/etc/init.d/cpufrequtils. 

After booting, cpufreq correctly stays at around 2.5 GHz and the governor is correctly set to "performance". However, after a minute the governor is automatically changed back to "powersave" and the cpufreq drops again. If I then manually set the governor with cpufreq-set it returns to 2.5 GHz.

The second issue I noticed was that every time I suspend and wake my laptop, the max cpufreq drops by an incremental amount (these increments are the same each time):

before suspending:

current policy: frequency should be within 800 MHz and 3.50 GHz.
              The governor "performance" may decide which speed to use
              within this range.
current CPU frequency is 2.20 GHz.

after first wake:

current policy: frequency should be within 800 MHz and 2.10 GHz.
              The governor "performance" may decide which speed to use
              within this range.
current CPU frequency is 1.12 GHz.

after second wake:

current policy: frequency should be within 800 MHz and 1.40 GHz.
              The governor "performance" may decide which speed to use
              within this range.
current CPU frequency is 1.30 GHz.

etc.

Note: the governor is still set to "performance".

Attempting to set the cpufreq max with cpufreq-set:

for ((i=0;i<$(nproc);i++)); do sudo cpufreq-set -c $i -u 3.50GHz; done

has no effect.

Lastly, I also attempted to disable intel_pstate in grub and set the acpi config to "performance"; this suffers from the same suspend/wake problem.

Any insight would be appreciated!

Edit 1: I have tried this which suggests that the problem may be that clock modulation automatically enables on wake, which conflicts with intel_pstate. Indeed it seems that clock modulation is enabled, but disabling it with:

sudo wrmsr -a 0x19a 0x0

does not noticeably change the frequencies, and I am still unable to change the max cpufreq value.

Edit 2: @DougSmythies on my pc those files are elsewhere, these are the respective printouts (I've excluded frequencies for the other 7 cores, they're identical). Note also that I am currently using the acpi driver:

cat /sys/devices/system/cpu/cpu*/cpufreq/cpu_min_freq
800000 

cat /sys/devices/system/cpu/cpu*/cpufreq/cpu_max_freq
2501000

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq                                                 
2501000 

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_min_freq                                                 
800000

I can't find the intel_pstate file anywhere in /sys/devices.

Edit 3: @DougSmythies I have rebooted with the intel_pstate driver and suspended and woken the machine up. The cores are running at about 2000 now on performance mode. The max freq is 2.1 GHz according to cpufreq-info; it was 3.5 GHz before suspending. Here is the output of the files your requested (just for cpu0, they're all the same):

$cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq 
3500000
$cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq                                                 
800000
$cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 
2100000
$cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 
800000

$grep . /sys/devices/system/cpu/intel_pstate/*                                                                                                                                                                                                      
/sys/devices/system/cpu/intel_pstate/max_perf_pct:60
/sys/devices/system/cpu/intel_pstate/min_perf_pct:22
/sys/devices/system/cpu/intel_pstate/no_turbo:0
/sys/devices/system/cpu/intel_pstate/num_pstates:28
/sys/devices/system/cpu/intel_pstate/turbo_pct:36

Best Answer

You're possbily affected by this bug:

https://bugzilla.kernel.org/show_bug.cgi?id=114551

The patch only landed in the mainline kernel v 4.6. In due course, maybe it'll be backported to 16.04LTS, or in Feb 2017, it should arrive in the next LTS Enablement Stack:

https://wiki.ubuntu.com/Kernel/LTSEnablementStack#Kernel.2FSupport.A16.04.x_Ubuntu_Kernel_Support

Related Question