linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kvm: cap halt polling at exactly halt_poll_ns
@ 2016-03-09  0:19 David Matlack
  2016-03-09 10:55 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: David Matlack @ 2016-03-09  0:19 UTC (permalink / raw)
  To: kvm; +Cc: linux-kernel, pbonzini, wanpeng.li, David Matlack

When growing halt-polling, there is no check that the poll time exceeds
the limit. It's possible for vcpu->halt_poll_ns grow once past
halt_poll_ns, and stay there until a halt which takes longer than
vcpu->halt_poll_ns. For example, booting a Linux guest with
halt_poll_ns=11000:

 ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 0 (shrink 10000)
 ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 10000 (grow 0)
 ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 20000 (grow 10000)

Signed-off-by: David Matlack <dmatlack@google.com>
---
 virt/kvm/kvm_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a11cfd2..9102ae1 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1952,6 +1952,9 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
 	else
 		val *= halt_poll_ns_grow;
 
+	if (val > halt_poll_ns)
+		val = halt_poll_ns;
+
 	vcpu->halt_poll_ns = val;
 	trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, val, old);
 }
-- 
2.7.0.rc3.207.g0ac5344

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kvm: cap halt polling at exactly halt_poll_ns
  2016-03-09  0:19 [PATCH] kvm: cap halt polling at exactly halt_poll_ns David Matlack
@ 2016-03-09 10:55 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2016-03-09 10:55 UTC (permalink / raw)
  To: David Matlack, kvm; +Cc: linux-kernel, wanpeng.li



On 09/03/2016 01:19, David Matlack wrote:
> When growing halt-polling, there is no check that the poll time exceeds
> the limit. It's possible for vcpu->halt_poll_ns grow once past
> halt_poll_ns, and stay there until a halt which takes longer than
> vcpu->halt_poll_ns. For example, booting a Linux guest with
> halt_poll_ns=11000:
> 
>  ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 0 (shrink 10000)
>  ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 10000 (grow 0)
>  ... kvm:kvm_halt_poll_ns: vcpu 0: halt_poll_ns 20000 (grow 10000)
> 
> Signed-off-by: David Matlack <dmatlack@google.com>
> ---
>  virt/kvm/kvm_main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index a11cfd2..9102ae1 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1952,6 +1952,9 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
>  	else
>  		val *= halt_poll_ns_grow;
>  
> +	if (val > halt_poll_ns)
> +		val = halt_poll_ns;
> +
>  	vcpu->halt_poll_ns = val;
>  	trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, val, old);
>  }
> 

Applied to kvm/master, thanks.

Paolo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-09 10:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-09  0:19 [PATCH] kvm: cap halt polling at exactly halt_poll_ns David Matlack
2016-03-09 10:55 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).