Re: [patch 2/3] KVM: x86: add option to advance tscdeadline hrtimer expiration

Paolo Bonzini
2014-12-23T13:18:09Z

On 18/12/2014 13:24, Marcelo Tosatti wrote:
> True. I can change to a direct wait if that is preferred.

What about this:

guest_tsc = kvm_x86_ops->read_l1_tsc(vcpu, native_read_tsc());
trace_kvm_wait_lapic_expire(vcpu->vcpu_id, guest_tsc - tsc_deadline);

/* We know that __delay is delay_tsc, see kvm_timer_init. */
if (guest_tsc < tsc_deadline)
__delay(tsc_deadline - guest_tsc);

and a check in kvm_timer_init:

if (check_tsc_unstable() && lapic_timer_advance_ns) {
pr_info("kvm: unstable TSC, disabling lapic_timer_advance_ns\n");
lapic_timer_advance_ns = 0;
}

Paolo