Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753179AbcCIKzc (ORCPT ); Wed, 9 Mar 2016 05:55:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42286 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752645AbcCIKzZ (ORCPT ); Wed, 9 Mar 2016 05:55:25 -0500 Subject: Re: [PATCH] kvm: cap halt polling at exactly halt_poll_ns To: David Matlack , kvm@vger.kernel.org References: <1457482784-82531-1-git-send-email-dmatlack@google.com> Cc: linux-kernel@vger.kernel.org, wanpeng.li@hotmail.com From: Paolo Bonzini Message-ID: <56E00119.9060702@redhat.com> Date: Wed, 9 Mar 2016 11:55:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1457482784-82531-1-git-send-email-dmatlack@google.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1128 Lines: 37 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 > --- > 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