[Devel] [PATCH RHEL7 COMMIT] ms/kvm: x86: hyperv: avoid livelock in oneshot SynIC timers

Konstantin Khorenko khorenko at virtuozzo.com
Mon Aug 7 12:33:20 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-514.26.1.vz7.35.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.26.1.vz7.33.22
------>
commit d86cb50b159e72f7575ac407d984252395cad053
Author: Roman Kagan <rkagan at virtuozzo.com>
Date:   Mon Aug 7 13:33:20 2017 +0400

    ms/kvm: x86: hyperv: avoid livelock in oneshot SynIC timers
    
    If the SynIC timer message delivery fails due to SINT message slot being
    busy, there's no point to attempt starting the timer again until we're
    notified of the slot being released by the guest (via EOM or EOI).
    
    Even worse, when a oneshot timer fails to deliver its message, its
    re-arming with an expiration time in the past leads to immediate retry
    of the delivery, and so on, without ever letting the guest vcpu to run
    and release the slot, which results in a livelock.
    
    To avoid that, only start the timer when there's no timer message
    pending delivery.  When there is, meaning the slot is busy, the
    processing will be restarted upon notification from the guest that the
    slot is released.
    
    Signed-off-by: Roman Kagan <rkagan at virtuozzo.com>
    Signed-off-by: Radim Krčmář <rkrcmar at redhat.com>
    (cherry picked from commit f1ff89ec4447c4e39d275a1ca3de43eed2a92745)
---
 arch/x86/kvm/hyperv.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index c8efdce..ab9501c 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -632,9 +632,10 @@ void kvm_hv_process_stimers(struct kvm_vcpu *vcpu)
 				}
 
 				if ((stimer->config & HV_STIMER_ENABLE) &&
-				    stimer->count)
-					stimer_start(stimer);
-				else
+				    stimer->count) {
+					if (!stimer->msg_pending)
+						stimer_start(stimer);
+				} else
 					stimer_cleanup(stimer);
 			}
 		}


More information about the Devel mailing list