diff options
| -rw-r--r-- | arch/x86/kernel/cpu/aperfmperf.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/arch/x86/kernel/cpu/aperfmperf.c b/arch/x86/kernel/cpu/aperfmperf.c index 0ee83321a313..957813e0180d 100644 --- a/arch/x86/kernel/cpu/aperfmperf.c +++ b/arch/x86/kernel/cpu/aperfmperf.c | |||
| @@ -42,10 +42,6 @@ static void aperfmperf_snapshot_khz(void *dummy) | |||
| 42 | s64 time_delta = ktime_ms_delta(now, s->time); | 42 | s64 time_delta = ktime_ms_delta(now, s->time); |
| 43 | unsigned long flags; | 43 | unsigned long flags; |
| 44 | 44 | ||
| 45 | /* Don't bother re-computing within the cache threshold time. */ | ||
| 46 | if (time_delta < APERFMPERF_CACHE_THRESHOLD_MS) | ||
| 47 | return; | ||
| 48 | |||
| 49 | local_irq_save(flags); | 45 | local_irq_save(flags); |
| 50 | rdmsrl(MSR_IA32_APERF, aperf); | 46 | rdmsrl(MSR_IA32_APERF, aperf); |
| 51 | rdmsrl(MSR_IA32_MPERF, mperf); | 47 | rdmsrl(MSR_IA32_MPERF, mperf); |
| @@ -74,6 +70,7 @@ static void aperfmperf_snapshot_khz(void *dummy) | |||
| 74 | 70 | ||
| 75 | unsigned int arch_freq_get_on_cpu(int cpu) | 71 | unsigned int arch_freq_get_on_cpu(int cpu) |
| 76 | { | 72 | { |
| 73 | s64 time_delta; | ||
| 77 | unsigned int khz; | 74 | unsigned int khz; |
| 78 | 75 | ||
| 79 | if (!cpu_khz) | 76 | if (!cpu_khz) |
| @@ -82,6 +79,12 @@ unsigned int arch_freq_get_on_cpu(int cpu) | |||
| 82 | if (!static_cpu_has(X86_FEATURE_APERFMPERF)) | 79 | if (!static_cpu_has(X86_FEATURE_APERFMPERF)) |
| 83 | return 0; | 80 | return 0; |
| 84 | 81 | ||
| 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 | |||
| 85 | smp_call_function_single(cpu, aperfmperf_snapshot_khz, NULL, 1); | 88 | smp_call_function_single(cpu, aperfmperf_snapshot_khz, NULL, 1); |
| 86 | khz = per_cpu(samples.khz, cpu); | 89 | khz = per_cpu(samples.khz, cpu); |
| 87 | if (khz) | 90 | if (khz) |
