Blob Blame History Raw
From: Christian Borntraeger <borntraeger@de.ibm.com>
Date: Tue, 5 Mar 2019 05:30:01 -0500
Subject: KVM: polling: add architecture backend to disable polling
Patch-mainline: v5.2-rc1
Git-commit: cdd6ad3ac63d2fa320baefcf92a02a918375c30f
References: bsc#1119222

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>
Acked-by: Liang Yan <lyan@suse.com>
---
 include/linux/kvm_host.h |   10 ++++++++++
 virt/kvm/Kconfig         |    3 +++
 virt/kvm/kvm_main.c      |    2 +-
 3 files changed, 14 insertions(+), 1 deletion(-)

--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1283,4 +1283,14 @@ static inline long kvm_arch_vcpu_async_i
 }
 #endif /* CONFIG_HAVE_KVM_VCPU_ASYNC_IOCTL */
 
+#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 */
+
 #endif
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -53,3 +53,6 @@ config HAVE_KVM_IRQ_BYPASS
 
 config HAVE_KVM_VCPU_ASYNC_IOCTL
        bool
+
+config HAVE_KVM_NO_POLL
+       bool
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2216,7 +2216,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcp
 	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;