[PATCH 2/9] x86,tsc: Feed refined TSC calibration into sched_clock

From: Peter Zijlstra
Date: Fri Apr 21 2017 - 13:38:55 EST


For the (older) CPUs that still need the refined TSC calibration, also
update the sched_clock rate.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
arch/x86/kernel/tsc.c | 5 +++++
1 file changed, 5 insertions(+)

--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1267,6 +1267,7 @@ static void tsc_refine_calibration_work(
static int hpet;
u64 tsc_stop, ref_stop, delta;
unsigned long freq;
+ int cpu;

/* Don't bother refining TSC on unstable systems */
if (check_tsc_unstable())
@@ -1317,6 +1318,10 @@ static void tsc_refine_calibration_work(
/* Inform the TSC deadline clockevent devices about the recalibration */
lapic_update_tsc_freq();

+ /* Update the sched_clock() rate to match the clocksource one */
+ for_each_possible_cpu(cpu)
+ set_cyc2ns_scale(tsc_khz, cpu);
+
out:
if (boot_cpu_has(X86_FEATURE_ART))
art_related_clocksource = &clocksource_tsc;