aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Borntraeger <borntraeger@de.ibm.com>2019-03-05 05:30:01 -0500
committerChristian Borntraeger <borntraeger@de.ibm.com>2019-04-26 03:08:17 -0400
commitcdd6ad3ac63d2fa320baefcf92a02a918375c30f (patch)
tree0f4c98d67883cf3dfa08cd2731d3a9497ea4ccf7
parent8ec2fa52eac53bff7ef1cedbc4ad8af650ec937c (diff)
KVM: polling: add architecture backend to disable polling
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>
-rw-r--r--include/linux/kvm_host.h10
-rw-r--r--virt/kvm/Kconfig3
-rw-r--r--virt/kvm/kvm_main.c2
3 files changed, 14 insertions, 1 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 9d55c63db09b..b3aff1a3f633 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -1305,6 +1305,16 @@ static inline bool vcpu_valid_wakeup(struct kvm_vcpu *vcpu)
1305} 1305}
1306#endif /* CONFIG_HAVE_KVM_INVALID_WAKEUPS */ 1306#endif /* CONFIG_HAVE_KVM_INVALID_WAKEUPS */
1307 1307
1308#ifdef CONFIG_HAVE_KVM_NO_POLL
1309/* Callback that tells if we must not poll */
1310bool kvm_arch_no_poll(struct kvm_vcpu *vcpu);
1311#else
1312static inline bool kvm_arch_no_poll(struct kvm_vcpu *vcpu)
1313{
1314 return false;
1315}
1316#endif /* CONFIG_HAVE_KVM_NO_POLL */
1317
1308#ifdef CONFIG_HAVE_KVM_VCPU_ASYNC_IOCTL 1318#ifdef CONFIG_HAVE_KVM_VCPU_ASYNC_IOCTL
1309long kvm_arch_vcpu_async_ioctl(struct file *filp, 1319long kvm_arch_vcpu_async_ioctl(struct file *filp,
1310 unsigned int ioctl, unsigned long arg); 1320 unsigned int ioctl, unsigned long arg);
diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig
index ea434ddc8499..aad9284c043a 100644
--- a/virt/kvm/Kconfig
+++ b/virt/kvm/Kconfig
@@ -57,3 +57,6 @@ config HAVE_KVM_VCPU_ASYNC_IOCTL
57 57
58config HAVE_KVM_VCPU_RUN_PID_CHANGE 58config HAVE_KVM_VCPU_RUN_PID_CHANGE
59 bool 59 bool
60
61config HAVE_KVM_NO_POLL
62 bool
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 55fe8e20d8fd..23aec2f4ba71 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2253,7 +2253,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
2253 u64 block_ns; 2253 u64 block_ns;
2254 2254
2255 start = cur = ktime_get(); 2255 start = cur = ktime_get();
2256 if (vcpu->halt_poll_ns) { 2256 if (vcpu->halt_poll_ns && !kvm_arch_no_poll(vcpu)) {
2257 ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns); 2257 ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns);
2258 2258
2259 ++vcpu->stat.halt_attempted_poll; 2259 ++vcpu->stat.halt_attempted_poll;