Commit 2086d320 authored by Christian Borntraeger's avatar Christian Borntraeger Committed by Paolo Bonzini

KVM: shrink halt polling even more for invalid wakeups

commit 3491caf2 ("KVM: halt_polling: provide a way to qualify
 wakeups during poll") added more aggressive shrinking of the
polling interval if the wakeup did not match some criteria. This
still allows to keep polling enabled if the polling time was
smaller that the current max poll time (block_ns <= vcpu->halt_poll_ns).
Performance measurement shows that even more aggressive shrinking
(shrink polling on any invalid wakeup) reduces absolute and relative
(to the workload) CPU usage even further.

Cc: David Matlack <dmatlack@google.com>
Cc: Wanpeng Li <kernellwp@gmail.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent c4a8de35
...@@ -2055,12 +2055,13 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) ...@@ -2055,12 +2055,13 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
out: out:
block_ns = ktime_to_ns(cur) - ktime_to_ns(start); block_ns = ktime_to_ns(cur) - ktime_to_ns(start);
if (halt_poll_ns) { if (!vcpu_valid_wakeup(vcpu))
shrink_halt_poll_ns(vcpu);
else if (halt_poll_ns) {
if (block_ns <= vcpu->halt_poll_ns) if (block_ns <= vcpu->halt_poll_ns)
; ;
/* we had a long block, shrink polling */ /* we had a long block, shrink polling */
else if (!vcpu_valid_wakeup(vcpu) || else if (vcpu->halt_poll_ns && block_ns > halt_poll_ns)
(vcpu->halt_poll_ns && block_ns > halt_poll_ns))
shrink_halt_poll_ns(vcpu); shrink_halt_poll_ns(vcpu);
/* we had a short halt and our poll time is too small */ /* we had a short halt and our poll time is too small */
else if (vcpu->halt_poll_ns < halt_poll_ns && else if (vcpu->halt_poll_ns < halt_poll_ns &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment