kvm: cap halt polling at exactly halt_poll_ns
PATCH 1/1 kvm: cap halt polling at exactly halt_poll_ns
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)
--- virt/kvm/kvm_main.c | 3 +++ 1 file changed, 3 insertions(+)
virt/kvm/kvm_main.c +3 -0
@@ -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); }
Signature · 1 line
2.7.0.rc3.207.g0ac5344
Quoted 21 lines · David Matlack
When growing halt-polling, there is no check that the poll time exceeds the limit. It's possible for
vcpu->halt_poll_nsgrow once pasthalt_poll_ns, and stay there until a halt which takes longer thanvcpu->halt_poll_ns. For example, booting a Linux guest with halt_poll_ns=11000:... kvm:kvm_halt_poll_ns: vcpu 0:
halt_poll_ns0 (shrink 10000) ... kvm:kvm_halt_poll_ns: vcpu 0:halt_poll_ns10000 (grow 0) ... kvm:kvm_halt_poll_ns: vcpu 0:halt_poll_ns20000 (grow 10000)Signed-off-by David Matlack <[email protected]>--- virt/kvm/kvm_main.c | 3 +++ 1 file changed, 3 insertions(+)virt/kvm/kvm_main.c +0
-0
virt/kvm/kvm_main.c static void grow_halt_poll_ns(struct kvm_vcpu *vcpu) · line 1960
Quoted 9 lines
virt/kvm/kvm_main.c +3
-0@@ -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