Skip to contentSkip to conversation

x86/time: make early NOW() uses slightly more precise

PATCH In review Jan Beulich 2 participants 2 messages May 6

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/time: make early NOW() uses slightly more precise

For early NOW() uses to yield sufficiently precise results (scaling incurs some error, which grows with the delta being scaled), init_percpu_time() wants to have run as early as possible. With 93340297802b ("x86/time:
calibrate TSC against platform timer") having moved the invocation of init_platform_timer() from init_xen_time() to early_time_init(), this other call could be moved as well.

Moving, however, has the unwanted effect of then growing the gap until time calibration runs for the 1st time. Therefore keep the present invocation, and add another from early_time_init().

xen/arch/x86/time.c +7 -0
@@ -2597,6 +2597,11 @@ int __init init_xen_time(void)
     /* Finish platform timer initialization. */
     try_platform_timer_tail();
 
+    /*
+     * While early_time_init() called this already, call it again here to
+     * reduce the gap until local_time_calibration() gets to run for the
+     * first time.
+     */
     init_percpu_time();
 
     init_timer(&calibration_timer, time_calibration, NULL, 0);
@@ -2642,6 +2647,8 @@ void __init early_time_init(void)
     set_time_scale(&t->tsc_scale, tmp);
     t->stamp.local_tsc = boot_tsc_stamp;
 
+    init_percpu_time();
+
     cpu_khz = DIV_ROUND(tmp, 1000);
     printk("Detected %lu.%03lu MHz processor.\n", 
            cpu_khz / 1000, cpu_khz % 1000);
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jan Beulich

For early NOW() uses to yield sufficiently precise results (scaling incurs some error, which grows with the delta being scaled), init_percpu_time() wants to have run as early as possible. With 93340297802b ("x86/time:
calibrate TSC against platform timer") having moved the invocation of init_platform_timer() from init_xen_time() to early_time_init(), this other call could be moved as well.

Moving, however, has the unwanted effect of then growing the gap until time calibration runs for the 1st time. Therefore keep the present invocation, and add another from early_time_init().

Yeah, keeping the second init_xen_time() will make sure the BSP doesn't diverge too much from the platform timer during boot. WE migth as well skip it and wait for the first rendezvous, but this is likely more accurate at the cost of doing the extra init_xen_time() in the BSP.

Quoted 1 line

Thanks, Roger.