Skip to content

Commit ea0ee33

Browse files
committed
Revert "x86: CPU: Fix up "cpu MHz" in /proc/cpuinfo"
This reverts commit 941f5f0. Sadly, it turns out that we really can't just do the cross-CPU IPI to all CPU's to get their proper frequencies, because it's much too expensive on systems with lots of cores. So we'll have to revert this for now, and revisit it using a smarter model (probably doing one system-wide IPI at open time, and doing all the frequency calculations in parallel). Reported-by: WANG Chao <chao.wang@ucloud.cn> Reported-by: Ingo Molnar <mingo@kernel.org> Cc: Rafael J Wysocki <rafael.j.wysocki@intel.com> Cc: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3e81277 commit ea0ee33

3 files changed

Lines changed: 6 additions & 11 deletions

File tree

arch/x86/kernel/cpu/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ obj-y += common.o
2222
obj-y += rdrand.o
2323
obj-y += match.o
2424
obj-y += bugs.o
25-
obj-y += aperfmperf.o
25+
obj-$(CONFIG_CPU_FREQ) += aperfmperf.o
2626

2727
obj-$(CONFIG_PROC_FS) += proc.o
2828
obj-$(CONFIG_X86_FEATURE_NAMES) += capflags.o powerflags.o

arch/x86/kernel/cpu/aperfmperf.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ static void aperfmperf_snapshot_khz(void *dummy)
4242
s64 time_delta = ktime_ms_delta(now, s->time);
4343
unsigned long flags;
4444

45+
/* Don't bother re-computing within the cache threshold time. */
46+
if (time_delta < APERFMPERF_CACHE_THRESHOLD_MS)
47+
return;
48+
4549
local_irq_save(flags);
4650
rdmsrl(MSR_IA32_APERF, aperf);
4751
rdmsrl(MSR_IA32_MPERF, mperf);
@@ -70,7 +74,6 @@ static void aperfmperf_snapshot_khz(void *dummy)
7074

7175
unsigned int arch_freq_get_on_cpu(int cpu)
7276
{
73-
s64 time_delta;
7477
unsigned int khz;
7578

7679
if (!cpu_khz)
@@ -79,12 +82,6 @@ unsigned int arch_freq_get_on_cpu(int cpu)
7982
if (!static_cpu_has(X86_FEATURE_APERFMPERF))
8083
return 0;
8184

82-
/* Don't bother re-computing within the cache threshold time. */
83-
time_delta = ktime_ms_delta(ktime_get(), per_cpu(samples.time, cpu));
84-
khz = per_cpu(samples.khz, cpu);
85-
if (khz && time_delta < APERFMPERF_CACHE_THRESHOLD_MS)
86-
return khz;
87-
8885
smp_call_function_single(cpu, aperfmperf_snapshot_khz, NULL, 1);
8986
khz = per_cpu(samples.khz, cpu);
9087
if (khz)

arch/x86/kernel/cpu/proc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
7878
seq_printf(m, "microcode\t: 0x%x\n", c->microcode);
7979

8080
if (cpu_has(c, X86_FEATURE_TSC)) {
81-
unsigned int freq = arch_freq_get_on_cpu(cpu);
81+
unsigned int freq = cpufreq_quick_get(cpu);
8282

83-
if (!freq)
84-
freq = cpufreq_quick_get(cpu);
8583
if (!freq)
8684
freq = cpu_khz;
8785
seq_printf(m, "cpu MHz\t\t: %u.%03u\n",

0 commit comments

Comments
 (0)