Re: [PATCH v4 1/3] time: add "NOW() good" indicator
Roger Pau Monné <[email protected]>
| Newsgroups | org.xenproject.lists.xen-devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jun 30, 2026 at 04:06:00PM +0200, Jan Beulich wrote: > printk_start_of_line() checks for a value of 0 right now. In order to be > able to have NOW() return at least monotonically increasing values, that > needs replacing by an explicit indicator. > > Signed-off-by: Jan Beulich <[email protected]> > --- > Arm and RISC-V may want to consider whether their initial get_cycles() > can't be moved yet earlier, such that the indicator also can be set > yet earlier. > --- > v4: Add barriers. > v3: New. > > --- a/xen/arch/arm/time.c > +++ b/xen/arch/arm/time.c > @@ -145,6 +145,8 @@ void __init preinit_xen_time(void) > panic("Timer: Cannot initialize platform timer\n"); > > boot_count = get_cycles(); > + smp_wmb(); > + NOW_good = true; > } > > static void __init init_dt_xen_time(void) > --- a/xen/arch/riscv/time.c > +++ b/xen/arch/riscv/time.c > @@ -87,6 +87,8 @@ void __init preinit_xen_time(void) > panic("%s: ACPI isn't supported\n", __func__); > > boot_clock_cycles = get_cycles(); > + smp_wmb(); > + NOW_good = true; > > /* set_xen_timer must have been set by sbi_init() already */ > ASSERT(set_xen_timer); > --- a/xen/arch/x86/time.c > +++ b/xen/arch/x86/time.c > @@ -2660,6 +2660,7 @@ void __init early_time_init(void) > > set_time_scale(&t->tsc_scale, tmp); > t->stamp.local_tsc = boot_tsc_stamp; > + NOW_good = true; Would you need a barrier here to ensure compiler doesn't re-order the writes? Maybe using ACCESS_ONCE(), or a smp_wmb() like it's used in other arches? Thanks, Roger.