Skip to content

Commit 15d3ec8

Browse files
borntraegerchenxiangzuo
authored andcommitted
KVM: polling: add architecture backend to disable polling
fix #28092200 commit cdd6ad3 upstream 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> Signed-off-by: chenxiangzuo <cxz18821786681@linux.alibaba.com> Reviewed-by: Caspar Zhang <caspar@linux.alibaba.com>
1 parent c053cc1 commit 15d3ec8

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

include/linux/kvm_host.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,16 @@ static inline bool vcpu_valid_wakeup(struct kvm_vcpu *vcpu)
12841284
}
12851285
#endif /* CONFIG_HAVE_KVM_INVALID_WAKEUPS */
12861286

1287+
#ifdef CONFIG_HAVE_KVM_NO_POLL
1288+
/* Callback that tells if we must not poll */
1289+
bool kvm_arch_no_poll(struct kvm_vcpu *vcpu);
1290+
#else
1291+
static inline bool kvm_arch_no_poll(struct kvm_vcpu *vcpu)
1292+
{
1293+
return false;
1294+
}
1295+
#endif /* CONFIG_HAVE_KVM_NO_POLL */
1296+
12871297
#ifdef CONFIG_HAVE_KVM_VCPU_ASYNC_IOCTL
12881298
long kvm_arch_vcpu_async_ioctl(struct file *filp,
12891299
unsigned int ioctl, unsigned long arg);

virt/kvm/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ config HAVE_KVM_VCPU_ASYNC_IOCTL
5757

5858
config HAVE_KVM_VCPU_RUN_PID_CHANGE
5959
bool
60+
61+
config HAVE_KVM_NO_POLL
62+
bool

virt/kvm/kvm_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
22142214
u64 block_ns;
22152215

22162216
start = cur = ktime_get();
2217-
if (vcpu->halt_poll_ns) {
2217+
if (vcpu->halt_poll_ns && !kvm_arch_no_poll(vcpu)) {
22182218
ktime_t stop = ktime_add_ns(ktime_get(), vcpu->halt_poll_ns);
22192219

22202220
++vcpu->stat.halt_attempted_poll;

0 commit comments

Comments
 (0)