]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
x86 / CPU: Always show current CPU frequency in /proc/cpuinfo
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 19 Jan 2018 15:41:38 +0000 (10:41 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 14 Mar 2018 10:40:48 +0000 (11:40 +0100)
commit3246f29e8076ba8d592e7b1645606e354b705c83
tree6b61eab057c622bde31cef71427ebf9850345d79
parent41d9b2fc2d0cfb34c8a845ae83a7c7aa31a3f260
x86 / CPU: Always show current CPU frequency in /proc/cpuinfo

BugLink: http://bugs.launchpad.net/bugs/1743269
After commit 890da9cf0983 (Revert "x86: do not use cpufreq_quick_get()
for /proc/cpuinfo "cpu MHz"") the "cpu MHz" number in /proc/cpuinfo
on x86 can be either the nominal CPU frequency (which is constant)
or the frequency most recently requested by a scaling governor in
cpufreq, depending on the cpufreq configuration.  That is somewhat
inconsistent and is different from what it was before 4.13, so in
order to restore the previous behavior, make it report the current
CPU frequency like the scaling_cur_freq sysfs file in cpufreq.

To that end, modify the /proc/cpuinfo implementation on x86 to use
aperfmperf_snapshot_khz() to snapshot the APERF and MPERF feedback
registers, if available, and use their values to compute the CPU
frequency to be reported as "cpu MHz".

However, do that carefully enough to avoid accumulating delays that
lead to unacceptable access times for /proc/cpuinfo on systems with
many CPUs.  Run aperfmperf_snapshot_khz() once on all CPUs
asynchronously at the /proc/cpuinfo open time, add a single delay
upfront (if necessary) at that point and simply compute the current
frequency while running show_cpuinfo() for each individual CPU.

Also, to avoid slowing down /proc/cpuinfo accesses too much, reduce
the default delay between consecutive APERF and MPERF reads to 10 ms,
which should be sufficient to get large enough numbers for the
frequency computation in all cases.

Fixes: 890da9cf0983 (Revert "x86: do not use cpufreq_quick_get() for /proc/cpuinfo "cpu MHz"")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@kernel.org>
(back ported from commit 7d5905dc14a87805a59f3c5bf70173aac2bb18f8)
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Acked-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/x86/kernel/cpu/Makefile
arch/x86/kernel/cpu/aperfmperf.c
arch/x86/kernel/cpu/cpu.h
arch/x86/kernel/cpu/proc.c
fs/proc/cpuinfo.c
include/linux/cpufreq.h