]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
x86 / CPU: Avoid unnecessary IPIs in arch_freq_get_on_cpu()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 19 Jan 2018 15:41:37 +0000 (10:41 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 14 Mar 2018 10:40:47 +0000 (11:40 +0100)
commit41d9b2fc2d0cfb34c8a845ae83a7c7aa31a3f260
tree67f6f31b4db3d7d4635ff4305d952a9eec52cd40
parent9338f80f616094b7a2caab2004286fe06a382b8d
x86 / CPU: Avoid unnecessary IPIs in arch_freq_get_on_cpu()

BugLink: http://bugs.launchpad.net/bugs/1743269
Even though aperfmperf_snapshot_khz() caches the samples.khz value to
return if called again in a sufficiently short time, its caller,
arch_freq_get_on_cpu(), still uses smp_call_function_single() to run it
which may allow user space to trigger an IPI storm by reading from the
scaling_cur_freq cpufreq sysfs file in a tight loop.

To avoid that, move the decision on whether or not to return the cached
samples.khz value to arch_freq_get_on_cpu().

This change was part of commit 941f5f0f6ef5 ("x86: CPU: Fix up "cpu MHz"
in /proc/cpuinfo"), but it was not the reason for the revert and it
remains applicable.

Fixes: 4815d3c56d1e (cpufreq: x86: Make scaling_cur_freq behave more as expected)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: WANG Chao <chao.wang@ucloud.cn>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit b29c6ef7bb1257853c1e31616d84f55e561cf631)
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/aperfmperf.c