linux-stable/arch/x86/kernel/cpu
Rafael J. Wysocki 4815d3c56d cpufreq: x86: Make scaling_cur_freq behave more as expected
After commit f8475cef90 "x86: use common aperfmperf_khz_on_cpu() to
calculate KHz using APERF/MPERF" the scaling_cur_freq policy attribute
in sysfs only behaves as expected on x86 with APERF/MPERF registers
available when it is read from at least twice in a row.  The value
returned by the first read may not be meaningful, because the
computations in there use cached values from the previous iteration
of aperfmperf_snapshot_khz() which may be stale.

To prevent that from happening, modify arch_freq_get_on_cpu() to
call aperfmperf_snapshot_khz() twice, with a short delay between
these calls, if the previous invocation of aperfmperf_snapshot_khz()
was too far back in the past (specifically, more that 1s ago).

Also, as pointed out by Doug Smythies, aperf_delta is limited now
and the multiplication of it by cpu_khz won't overflow, so simplify
the s->khz computations too.

Fixes: f8475cef90 "x86: use common aperfmperf_khz_on_cpu() to calculate KHz using APERF/MPERF"
Reported-by: Doug Smythies <dsmythies@telus.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-07-30 14:26:51 +02:00
..
mcheck x86/mce: Always save severity in machine_check_poll() 2017-06-26 15:58:56 +02:00
microcode x86/microcode: Make a couple of symbols static 2017-06-26 15:57:37 +02:00
mtrr x86/mtrr: Remove get_online_cpus() from mtrr_save_state() 2017-05-26 10:10:38 +02:00
.gitignore
amd.c x86/cpu: Use indirect call to measure performance in init_amd_k6() 2017-07-16 11:05:04 +02:00
aperfmperf.c cpufreq: x86: Make scaling_cur_freq behave more as expected 2017-07-30 14:26:51 +02:00
bugs.c x86: use set_memory.h header 2017-05-08 17:15:13 -07:00
centaur.c Merge branch 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-05-01 20:51:12 -07:00
common.c x86/cpu: remove hypervisor specific set_cpu_features 2017-05-02 11:14:30 +02:00
cpu.h x86/cpu: Restore MSR_IA32_ENERGY_PERF_BIAS after resume 2015-07-21 07:51:38 +02:00
cyrix.c x86/cpu/cyrix: Add alternative Device ID of Geode GX1 SoC 2017-06-05 08:34:20 +02:00
hypervisor.c x86/cpu: remove hypervisor specific set_cpu_features 2017-05-02 11:14:30 +02:00
intel.c x86/arch_prctl: Add ARCH_[GET|SET]_CPUID 2017-03-20 16:10:34 +01:00
intel_cacheinfo.c sched/headers: Prepare to remove <linux/cred.h> inclusion from <linux/sched.h> 2017-03-02 08:42:31 +01:00
intel_rdt.c x86/intel_rdt: Fix padding when resource is enabled via mount 2017-04-20 15:57:59 +02:00
intel_rdt_rdtgroup.c x86/intel_rdt: Fix memory leak on mount failure 2017-06-30 21:20:00 +02:00
intel_rdt_schemata.c x86/intel_rdt: Return error for incorrect resource names in schemata 2017-04-20 15:57:59 +02:00
Makefile x86: use common aperfmperf_khz_on_cpu() to calculate KHz using APERF/MPERF 2017-06-27 01:47:32 +02:00
match.c x86/kernel: Audit and remove any unnecessary uses of module.h 2016-07-14 15:06:41 +02:00
mkcapflags.sh x86/cpufeature: Carve out X86_FEATURE_* 2016-01-30 11:22:17 +01:00
mshyperv.c x86/hyperv: Read TSC frequency from a synthetic MSR 2017-06-22 15:35:12 +02:00
perfctr-watchdog.c x86/kernel: Audit and remove any unnecessary uses of module.h 2016-07-14 15:06:41 +02:00
powerflags.c x86/cpu: Add advanced power management bits 2016-03-29 11:12:11 +02:00
proc.c x86: do not use cpufreq_quick_get() for /proc/cpuinfo "cpu MHz" 2017-06-24 01:45:47 +02:00
rdrand.c x86, asm: Use CC_SET()/CC_OUT() and static_cpu_has() in archrandom.h 2016-06-08 12:41:20 -07:00
scattered.c x86/intel_rdt/mba: Memory bandwith allocation feature detect 2017-04-14 16:10:07 +02:00
topology.c x86/cpu: Convert printk(KERN_<LEVEL> ...) to pr_<level>(...) 2016-02-03 10:30:03 +01:00
transmeta.c Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-03-07 14:42:34 -08:00
umc.c
vmware.c vmware: set cpu capabilities during platform initialization 2017-05-02 11:14:24 +02:00