]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: LAPIC: Fix lapic timer injection delay
authorWanpeng Li <wanpeng.li@hotmail.com>
Thu, 29 Jun 2017 13:28:09 +0000 (06:28 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 29 Jun 2017 16:21:13 +0000 (18:21 +0200)
commit503460c90fb09691bbfae0fc6e275b2da85d678e
tree7fcea60d187c8ba5ee8c099e224aaaf4e632a8a6
parentedb408943f29248133c1a6444c17c9a99fae5037
KVM: LAPIC: Fix lapic timer injection delay

If the TSC deadline timer is programmed really close to the deadline or
even in the past, the computation in vmx_set_hv_timer will program the
absolute target tsc value to vmcs preemption timer field w/ delta == 0,
then plays a vmentry and an upcoming vmx preemption timer fire vmexit
dance, the lapic timer injection is delayed due to this duration. Actually
the lapic timer which is emulated by hrtimer can handle this correctly.

This patch fixes it by firing the lapic timer and injecting a timer interrupt
immediately during the next vmentry if the TSC deadline timer is programmed
really close to the deadline or even in the past. This saves ~300 cycles on
the tsc_deadline_timer test of apic.flat.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/lapic.c
arch/x86/kvm/vmx.c