On Mon, 31 Aug 2020 at 20:48, Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> wrote: > > Wanpeng Li <kernellwp@xxxxxxxxx> writes: > > > From: Wanpeng Li <wanpengli@xxxxxxxxxxx> > > > > per-vCPU timer_advance_ns should be set to 0 if timer mode is not tscdeadline > > otherwise we waste cpu cycles in the function lapic_timer_int_injected(), > > lapic_timer_int_injected is just a test, kvm_wait_lapic_expire() > (__kvm_wait_lapic_expire()) maybe? Both the check in lapic_timer_int_injected(), the check in __kvm_wait_lapic_expire(), and these function calls, we can observe ~1.3% world switch time reduce w/ this patch by kvm-unit-tests/vmexit.flat vmcall testing on AMD server. In addition, I think we should set apic->lapic_timer.expired_tscdeadline to 0 when switching between tscdeadline mode and other modes on Intel in order that we will not waste cpu cycles to tune advance value in adjust_lapic_timer_advance() for one time. Wanpeng