On Mon, May 20, 2019 at 03:03:10PM +0200, Paolo Bonzini wrote: > On 08/05/19 23:47, Sean Christopherson wrote: > > + > > + /* > > + * The first vCPU to get a stable advancement time "wins" and > > + * sets the advancement time that is used for *new* vCPUS that > > + * are created with auto-adjusting enabled. > > + */ > > + if (apic->lapic_timer.timer_advance_adjust_done) > > + (void)cmpxchg(&adjusted_timer_advance_ns, -1, > > + timer_advance_ns); > > This is relatively expensive, so it should only be done after setting > timer_advance_adjust_done to true. That's already the case, or am I missing something? This code is inside "if (!apic->lapic_timer.timer_advance_adjust_done)", and apic->lapic_timer.timer_advance_adjust_done is set to true at creation time if "adjusted_timer_advance_ns != -1", i.e. the cmpxchg() will only be reached on vCPUs that are created before adjusted_timer_advance_ns is set and will be reached at most once per vCPU.