KVM: polling: add architecture backend to disable polling
authorChristian Borntraeger <borntraeger@de.ibm.com>
Tue, 5 Mar 2019 10:30:01 +0000 (05:30 -0500)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Fri, 26 Apr 2019 07:08:17 +0000 (09:08 +0200)
There are cases where halt polling is unwanted. For example when running
KVM on an over committed LPAR we rather want to give back the CPU to
neighbour LPARs instead of polling. Let us provide a callback that
allows architectures to disable polling.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
include/linux/kvm_host.h
virt/kvm/Kconfig
virt/kvm/kvm_main.c

index 9d55c63db09b5dcb9ac997d802cb00ff356d4353..b3aff1a3f63378ad3070a8196334724dd467ed02 100644 (file)
@@ -1305,6 +1305,16 @@ static inline bool vcpu_valid_wakeup(struct kvm_vcpu *vcpu)
 }
 #endif /* CONFIG_HAVE_KVM_INVALID_WAKEUPS */
 
+#ifdef CONFIG_HAVE_KVM_NO_POLL
+/* Callback that tells if we must not poll */
+bool kvm_arch_no_poll(struct kvm_vcpu *vcpu);
+#else
+static inline bool kvm_arch_no_poll(struct kvm_vcpu *vcpu)
+{
+       return false;
+}
+#endif /* CONFIG_HAVE_KVM_NO_POLL */
+
 #ifdef CONFIG_HAVE_KVM_VCPU_ASYNC_IOCTL
 long kvm_arch_vcpu_async_ioctl(struct file *filp,
                               unsigned int ioctl, unsigned long arg);
index ea434ddc849925c6e2577a9ed6acea906ea8eafd..aad9284c043a029481072a8d802400902fd730fb 100644 (file)
@@ -57,3 +57,6 @@ config HAVE_KVM_VCPU_ASYNC_IOCTL
 
 config HAVE_KVM_VCPU_RUN_PID_CHANGE
        bool
+
+config HAVE_KVM_NO_POLL
+       bool
index 55fe8e20d8fd9b7367619a250dde9076a74bdc6e..23aec2f4ba7193acffd9969e2d6806a16a7d1cae 100644 (file)
@@ -2253,7 +2253,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
        u64 block_ns;
 
        start = cur = ktime_get();
-       if (vcpu->halt_poll_ns) {
+       if (vcpu->halt_poll_ns && !kvm_arch_no_poll(vcpu)) {
                ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns);
 
                ++vcpu->stat.halt_attempted_poll;