* [PATCH] x86/time: make early NOW() uses slightly more precise
@ 2026-05-06 9:33 Jan Beulich
2026-05-06 10:19 ` Roger Pau Monné
0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2026-05-06 9:33 UTC (permalink / raw)
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper, Roger Pau Monné, Teddy Astie
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@suse.com>
--- 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);
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] x86/time: make early NOW() uses slightly more precise
2026-05-06 9:33 [PATCH] x86/time: make early NOW() uses slightly more precise Jan Beulich
@ 2026-05-06 10:19 ` Roger Pau Monné
0 siblings, 0 replies; 2+ messages in thread
From: Roger Pau Monné @ 2026-05-06 10:19 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel@lists.xenproject.org, Andrew Cooper, Teddy Astie
On Wed, May 06, 2026 at 11:33:55AM +0200, Jan Beulich wrote:
> 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.
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Thanks, Roger.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-06 10:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06 9:33 [PATCH] x86/time: make early NOW() uses slightly more precise Jan Beulich
2026-05-06 10:19 ` Roger Pau Monné
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.