From patchwork Wed Mar 9 00:19:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 8538581 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 69280C0554 for ; Wed, 9 Mar 2016 00:20:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8F3802015E for ; Wed, 9 Mar 2016 00:20:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B67E2201FE for ; Wed, 9 Mar 2016 00:20:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751227AbcCIAT4 (ORCPT ); Tue, 8 Mar 2016 19:19:56 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:33897 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750974AbcCIATy (ORCPT ); Tue, 8 Mar 2016 19:19:54 -0500 Received: by mail-pf0-f180.google.com with SMTP id 129so24803310pfw.1 for ; Tue, 08 Mar 2016 16:19:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=kZfp4x4DJkoyJyPFN4wOOyGTgamgXrd/FmK2K0SACZo=; b=XDXxmGLeIA3EbAwIbFZauFsA+ocXJT53zlDG87is0FPlZT0KHjHj+GTpKLLiYiPyb9 mST9hyrdQ7yZ/pqLp0tXFUqxywsajlUdVzzOG/1lcsuAMxTGnO70xEXnLkQ3/sJQlvFx zFDd05wu/U7KydPxLwgC0AHIW/Z2+q0MpXKaxCHwczKyX6XJeuYaRIG1Dm4t0JUu9XT5 8LNIlWle7EaSjoIeLInmcAss/sL6uGyaHXnuD0ZDHZJJnHMp2FsVtgNNQRtjChkVNbdb 9r+sSJzX57c53KRuWXDD/neFgvZjCJrT1LEOFn16k4vPM3g3sK+rB9i1I7MVwNz9kOA/ KF7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=kZfp4x4DJkoyJyPFN4wOOyGTgamgXrd/FmK2K0SACZo=; b=b+qSGA37POV5DoYd2v5gFYIqH9x0+ZUXJpEw78D6E12Oy1TDi+vb3gWvvPNHy1kblS NFWygrcvhvmNnsPAbCzOcj77vkC7c1hg8SXa0g+oGXnkPrpAtU8WTD9pxNsBHtgxoojo ApyDUVe4Yk8AsOj3rCHXLhG18TGZFYfhb7GoLFPURuCn0EvUIPPkgMut7FtWEUiuEHeC jl4CAC/fL+tctoamt9HW7wTANwXr7uM2gsbJoz7Z3m6YRqllaQsPqRm2yNItpbSrc5r9 N3aylhnNfIL1dCy6vtAGDzRYILeUwvf6Eb3C9odF2cjtoq4mDgOUc+laU7ZsMBr+3JUv UR4Q== X-Gm-Message-State: AD7BkJJJw4v7ZxBB0lhVy6ctgz9Ca9cwjIjnEEaEuaTqzUosw78jAGxm2jNTInUiN5MV1fbf X-Received: by 10.98.68.73 with SMTP id r70mr46605496pfa.136.1457482793402; Tue, 08 Mar 2016 16:19:53 -0800 (PST) Received: from dmatlack.sea.corp.google.com ([172.31.89.32]) by smtp.gmail.com with ESMTPSA id dg1sm7524736pad.18.2016.03.08.16.19.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Mar 2016 16:19:52 -0800 (PST) From: David Matlack To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, pbonzini@redhat.com, wanpeng.li@hotmail.com, David Matlack Subject: [PATCH] kvm: cap halt polling at exactly halt_poll_ns Date: Tue, 8 Mar 2016 16:19:44 -0800 Message-Id: <1457482784-82531-1-git-send-email-dmatlack@google.com> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); }