[RHEL7,COMMIT] ms/KVM: x86: really disarm lapic timer when clearing TMICT

Submitted by Konstantin Khorenko on July 25, 2018, 3:47 p.m.


Message ID 201807251547.w6PFl9iB019351@finist_ce7.work
State New
Series "ms/KVM: x86: really disarm lapic timer when clearing TMICT"
Headers show

Commit Message

Konstantin Khorenko July 25, 2018, 3:47 p.m.
The commit is pushed to "branch-rh7-3.10.0-862.9.1.vz7.63.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.9.1.vz7.63.2
commit 5f1bd493e2d0093c567739251556023a845cd8da
Author: Radim Krčmář <rkrcmar@redhat.com>
Date:   Wed Jul 25 18:47:09 2018 +0300

    ms/KVM: x86: really disarm lapic timer when clearing TMICT
    preemption timer only looks at tscdeadline and could inject already
    disarmed timer.
    Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
    Reviewed-by: Wanpeng Li <wanpeng.li@hotmail.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit 5d74a6999368ad1991491b1913bb80faf1925e67)
    Signed-off-by: Viktor Prutyanov <viktor.prutyanov@virtuozzo.com>
    Signed-off-by: Viktor Prutyanov <viktor.prutyanov@virtuozzo.com>
    Patchset description:
    Fix guest context switch performance degradation.
    Following patches were adopted from mainline kernel to fix guest Windows
    context switch performance degradation.
    VMX preemption timer support was added in kernel-3.10.0-862.3.2.el7. In this
    case, timer incorrectly triggers despite of its disabling and causes extra
    VMexit on every context switch. These patches add correct handling of disabled
    Radim Krčmář (3):
      KVM: x86: handle 0 write to TSC_DEADLINE MSR
      KVM: x86: really disarm lapic timer when clearing TMICT
      KVM: x86: thoroughly disarm LAPIC timer around TSC deadline switch
    Wanpeng Li (3):
      KVM: LAPIC: Fix lapic timer mode transition
      KVM: LAPIC: Introduce limit_periodic_timer_frequency
      KVM: LAPIC: Keep timer running when switching between one-shot and
        periodic mode
 arch/x86/kvm/lapic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 4fb6d073a8ce..c03a1658b578 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1466,8 +1466,10 @@  static bool set_target_expiration(struct kvm_lapic *apic)
 	apic->lapic_timer.period = (u64)kvm_lapic_get_reg(apic, APIC_TMICT)
 		* APIC_BUS_CYCLE_NS * apic->divide_count;
-	if (!apic->lapic_timer.period)
+	if (!apic->lapic_timer.period) {
+		apic->lapic_timer.tscdeadline = 0;
 		return false;
+	}