Bug 177161

Summary: CPU frequencies in /proc/cpuinfo aren't dynamically updated
Product: Power Management Reporter: Coacher (itumaykin+kernel)
Component: cpufreqAssignee: Len Brown (lenb)
Status: RESOLVED CODE_FIX    
Severity: normal CC: lenb
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.8--4.8.4 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: lspci -nn -k -vvv
lscpu
config-4.8

Description Coacher 2016-10-10 13:15:42 UTC
Created attachment 241281 [details]
lspci -nn -k -vvv

Hello.

Since 4.8 frequencies in /proc/cpuinfo aren't dynamically updated anymore.
I guess they are stuck to the values written during boot as I get different values from boot to boot.

This wasn't the case with 4.7.x or any previous kernel series.

Please fix.
Comment 1 Coacher 2016-10-10 13:15:59 UTC
Created attachment 241291 [details]
lscpu
Comment 2 Coacher 2016-10-10 13:17:55 UTC
Created attachment 241301 [details]
config-4.8
Comment 3 Len Brown 2016-10-11 00:02:22 UTC
I proposed a patch to make /proc/cpuinfo accurate several months ago.
Red Hat didn't like it, arguing that changing values is a support issue.
So there was not agreement on what to do here -- let's go find out if
it changed by mistake...
Comment 4 Len Brown 2016-10-11 00:03:16 UTC
also...
please indicate which cpufreq  driver you are using,
for that can also effect things.  (acpi_cpufreq doesn't update,
but intel_pstate does)
Comment 5 Coacher 2016-10-11 09:43:56 UTC
(In reply to Len Brown from comment #4)
> also...
> please indicate which cpufreq  driver you are using,
> for that can also effect things.  (acpi_cpufreq doesn't update,
> but intel_pstate does)

I don't use intel_pstate as it's for sandy bridge and newer processors,
which I don't have. I use acpi_cpufreq exclusively for a very long time.
Comment 6 Coacher 2016-10-17 10:40:15 UTC
JIC this is important: values in '/sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq' aren't dynamically updated either.
Comment 7 Len Brown 2016-10-18 15:36:50 UTC
please show the output from
grep . /sys/devices/system/cpu/cpu0/cpufreq/*

which will show the governor and the frequency range available.
It is possible that you are running a governor that makes no changes.
Comment 8 Coacher 2016-10-19 15:42:21 UTC
(In reply to Len Brown from comment #7)
> please show the output from
> grep . /sys/devices/system/cpu/cpu0/cpufreq/*

# grep . /sys/devices/system/cpu/cpu0/cpufreq/*
/sys/devices/system/cpu/cpu0/cpufreq/affected_cpus:0
/sys/devices/system/cpu/cpu0/cpufreq/bios_limit:1199000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq:1199000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq:1199000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq:666000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency:10000
/sys/devices/system/cpu/cpu0/cpufreq/freqdomain_cpus:0 1 2 3
/sys/devices/system/cpu/cpu0/cpufreq/related_cpus:0
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies:1199000 1066000 933000 799000 666000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors:powersave schedutil conservative performance
/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq:1199000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver:acpi-cpufreq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor:conservative
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq:1199000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq:666000
/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed:<unsupported>
grep: /sys/devices/system/cpu/cpu0/cpufreq/stats: Is a directory

> which will show the governor and the frequency range available.
> It is possible that you are running a governor that makes no changes.

I am using conservative governor that successfully changed frequencies until 4.8. Governor configuration hasn't changed for years on my machine. Thresholds are changed dynamically based on AC status with this script:

$ cat /etc/pm/power.d/governor
#!/bin/sh

: ${GOVERNOR:=conservative}

: ${PWRS_UP_THRESHOLD:=95}
: ${PERF_UP_THRESHOLD:=90}

: ${PWRS_DOWN_THRESHOLD:=90}
: ${PERF_DOWN_THRESHOLD:=50}

powersave() {
    local cpufreq="/sys/devices/system/cpu/cpufreq/${GOVERNOR}"

    [ -w "${cpufreq}/up_threshold" -a -w "${cpufreq}/down_threshold" ] || return 1

    echo 99 > "${cpufreq}/up_threshold"
    echo 11 > "${cpufreq}/down_threshold"

    echo "$1" > "${cpufreq}/up_threshold"
    echo "$2" > "${cpufreq}/down_threshold"
}

case $1 in
    true)  powersave "${PWRS_UP_THRESHOLD}" "${PWRS_DOWN_THRESHOLD}" ;;
    false) powersave "${PERF_UP_THRESHOLD}" "${PERF_DOWN_THRESHOLD}" ;;
    *) exit 254 ;;
esac

exit 0
Comment 9 Len Brown 2016-10-24 23:48:07 UTC
please re-test 4.9-rc2
Comment 10 Coacher 2016-10-26 05:51:36 UTC
(In reply to Len Brown from comment #9)
> please re-test 4.9-rc2

Is there a specific change you'd like me to test?
Comment 11 Coacher 2016-10-28 17:25:23 UTC
I didn't manage to test 4.9-rc2, but I can confirm this problem is fixed in 4.8.5 due to changes that were introduced between 4.8.4 and 4.8.5.
Thank you very much.