[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/time: make early NOW() uses slightly more precise



commit 4526d67634664bac3a441b37caa22d9b2e7a34d8
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu May 7 13:25:17 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu May 7 16:10:52 2026 +0200

    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().
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/time.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 8209d37d32..c708c80be3 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -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);
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.