diff mbox

[1/1] KVM: shrink halt polling even more for invalid wakeups

Message ID 1463474962-5941-2-git-send-email-borntraeger@de.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christian Borntraeger May 17, 2016, 8:49 a.m. UTC
commit 3491caf2755e ("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: Christian Borntraeger <borntraeger@de.ibm.com>
---
 virt/kvm/kvm_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Christian Borntraeger May 17, 2016, 1:54 p.m. UTC | #1
On 05/17/2016 10:49 AM, Christian Borntraeger wrote:
> commit 3491caf2755e ("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: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  virt/kvm/kvm_main.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index fbd7698..dec1ed2 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2055,12 +2055,13 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
>  out:
>  	block_ns = ktime_to_ns(cur) - ktime_to_ns(start);
> 
> -	if (halt_poll_ns) {
> +	if (!vcpu_valid_wakeup(vcpu))
> +		 shrink_halt_poll_ns(vcpu);
		^ hmpf. Small whitespace error. I can resend if wanted.

> +	else if (halt_poll_ns) {
>  		if (block_ns <= vcpu->halt_poll_ns)
>  			;
>  		/* we had a long block, shrink polling */
> -		else if (!vcpu_valid_wakeup(vcpu) ||
> -			(vcpu->halt_poll_ns && block_ns > halt_poll_ns))
> +		else if (vcpu->halt_poll_ns && block_ns > halt_poll_ns)
>  			shrink_halt_poll_ns(vcpu);
>  		/* we had a short halt and our poll time is too small */
>  		else if (vcpu->halt_poll_ns < halt_poll_ns &&
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini May 17, 2016, 4:43 p.m. UTC | #2
On 17/05/2016 15:54, Christian Borntraeger wrote:
>> > -	if (halt_poll_ns) {
>> > +	if (!vcpu_valid_wakeup(vcpu))
>> > +		 shrink_halt_poll_ns(vcpu);
> 		^ hmpf. Small whitespace error. I can resend if wanted.

No need.

Paolo

>> > 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Cornelia Huck May 17, 2016, 5 p.m. UTC | #3
On Tue, 17 May 2016 10:49:22 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> commit 3491caf2755e ("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: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  virt/kvm/kvm_main.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index fbd7698..dec1ed2 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2055,12 +2055,13 @@  void kvm_vcpu_block(struct kvm_vcpu *vcpu)
 out:
 	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)
 			;
 		/* we had a long block, shrink polling */
-		else if (!vcpu_valid_wakeup(vcpu) ||
-			(vcpu->halt_poll_ns && block_ns > halt_poll_ns))
+		else if (vcpu->halt_poll_ns && block_ns > halt_poll_ns)
 			shrink_halt_poll_ns(vcpu);
 		/* we had a short halt and our poll time is too small */
 		else if (vcpu->halt_poll_ns < halt_poll_ns &&