Commit 7fa08e71 authored by Nir Weiner's avatar Nir Weiner Committed by Paolo Bonzini

KVM: grow_halt_poll_ns() should never shrink vCPU halt_poll_ns

grow_halt_poll_ns() have a strange behavior in case
(halt_poll_ns_grow == 0) && (vcpu->halt_poll_ns != 0).

In this case, vcpu->halt_pol_ns will be set to zero.
That results in shrinking instead of growing.

Fix issue by changing grow_halt_poll_ns() to not modify
vcpu->halt_poll_ns in case halt_poll_ns_grow is zero
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: default avatarLiran Alon <liran.alon@oracle.com>
Signed-off-by: default avatarNir Weiner <nir.weiner@oracle.com>
Suggested-by: default avatarLiran Alon <liran.alon@oracle.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 8ab3c471
...@@ -3631,8 +3631,11 @@ static void kvmppc_wait_for_exec(struct kvmppc_vcore *vc, ...@@ -3631,8 +3631,11 @@ static void kvmppc_wait_for_exec(struct kvmppc_vcore *vc,
static void grow_halt_poll_ns(struct kvmppc_vcore *vc) static void grow_halt_poll_ns(struct kvmppc_vcore *vc)
{ {
if (!halt_poll_ns_grow)
return;
/* 10us base */ /* 10us base */
if (vc->halt_poll_ns == 0 && halt_poll_ns_grow) if (vc->halt_poll_ns == 0)
vc->halt_poll_ns = 10000; vc->halt_poll_ns = 10000;
else else
vc->halt_poll_ns *= halt_poll_ns_grow; vc->halt_poll_ns *= halt_poll_ns_grow;
......
...@@ -2188,8 +2188,11 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu) ...@@ -2188,8 +2188,11 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
old = val = vcpu->halt_poll_ns; old = val = vcpu->halt_poll_ns;
grow = READ_ONCE(halt_poll_ns_grow); grow = READ_ONCE(halt_poll_ns_grow);
if (!grow)
goto out;
/* 10us base */ /* 10us base */
if (val == 0 && grow) if (val == 0)
val = 10000; val = 10000;
else else
val *= grow; val *= grow;
...@@ -2198,6 +2201,7 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu) ...@@ -2198,6 +2201,7 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
val = halt_poll_ns; val = halt_poll_ns;
vcpu->halt_poll_ns = val; vcpu->halt_poll_ns = val;
out:
trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, val, old); trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, val, old);
} }
......
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