From patchwork Mon Nov 5 06:45:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10667441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A66613A4 for ; Mon, 5 Nov 2018 06:45:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54C48287FD for ; Mon, 5 Nov 2018 06:45:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41B0D29511; Mon, 5 Nov 2018 06:45:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF307287FD for ; Mon, 5 Nov 2018 06:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729351AbeKEQDc (ORCPT ); Mon, 5 Nov 2018 11:03:32 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39816 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729121AbeKEQDc (ORCPT ); Mon, 5 Nov 2018 11:03:32 -0500 Received: by mail-pf1-f193.google.com with SMTP id n11-v6so3925567pfb.6 for ; Sun, 04 Nov 2018 22:45:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=oYRuhugKObJgjULAGE5kwvNvl0ck0Zbi5cldbw/qzyg=; b=dAdrV1bHrVbe4ftZmvk2XwZA5CU0G2CWjsDSrLcsCj/3+a+bKTsXWaVdmbKKGvTPQ2 JQN82t4rDZZpT+HtRBb57CUfhBnNKraYAWNqN0w41YXlMmE830CVORNRR5rrajxYZlMA h/bhNfyibUYNBon/XQ+4pIlvgohNfmlV7NWM4vtJAyujQ12iUceTYWD+UTp0mLu5emOn lrClHZrvr/xWkgSQRtzuO+fDBTLz7zHvIm2jCmngYTgUpwJXI2gdzs9ozgRcHVqrFXkU M+xoe5VOI65xJeWjo777ooEZY2Ng/FPyymG2FJ2eSA/aclzGZUwkU9pGiXivlKBIL/oT xZ1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oYRuhugKObJgjULAGE5kwvNvl0ck0Zbi5cldbw/qzyg=; b=Ff71T5AMauNFDoyu0NF27WbFPdR2lAbhNerJyPvDE6QpFD1BX/4Dd+WdJJCgRdmcdR Z7MIV3CyUTbG3Ypwh2Qy1YQF6Wfph5ngMaTcTF8k1oWzvo4a6JGHnX2dXRcBNC3DNmyG E42QcY9so3++Hsgzo3hxtC7ia7jdu3JBLPKi98nykf6cxgNdUugmBTHJPfCI5OYzU8TQ ktPLLl20AIsJaHw5yVWD/8TqrLK3IdNz+lWW58DrDBkm+L0uCcksmSjQiachmDkpfDDP eRJKOQjqqOlyZQAWCdGRhf07PNNBew8y6s5utIkDbphVRvrc2iTtDqcelhy8kH5yDRqL HFDw== X-Gm-Message-State: AGRZ1gIv3t/wQcfcKObFF7Dih8s8vWH3EezI79SLkGa4IS6z+tje775f /KCTlxhwOU4IrAp3v1YQBhY= X-Google-Smtp-Source: AJdET5d0FgZLOgUOBj+K0ICHgT4flqcCYppW61cl2TkV1g0qteV4mU0k+mtaNgrvCLGH7F/vpJPvdQ== X-Received: by 2002:a63:ef47:: with SMTP id c7mr19226026pgk.386.1541400323712; Sun, 04 Nov 2018 22:45:23 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id e131-v6sm17402650pfc.122.2018.11.04.22.45.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Nov 2018 22:45:22 -0800 (PST) From: Wei Yang To: pbonzini@redhat.com, rkrcmar@redhat.com Cc: x86@kernel.org, kvm@vger.kernel.org, Wei Yang Subject: [PATCH 1/2] KVM: use same boundary check for async_pf Date: Mon, 5 Nov 2018 14:45:02 +0800 Message-Id: <20181105064503.36285-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit af585b921e5d ("KVM: Halt vcpu if page it tries to access is swapped out") introduces async_pf. The gfn hash table size is defined as: gfn_t gfns[roundup_pow_of_two(ASYNC_PF_PER_VCPU)]; And iterations in arch/x86/kvm/x86.c are checked with: i < roundup_pow_of_two(ASYNC_PF_PER_VCPU) While the check in kvm_setup_async_pf() is: if (vcpu->async_pf.queued >= ASYNC_PF_PER_VCPU) Generally this works good, while the check is not exact. This patch adjust the check in kvm_setup_async_pf() to use the same boundary as others. Signed-off-by: Wei Yang --- virt/kvm/async_pf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c index 23c2519c5b32..4f4f6eac88a4 100644 --- a/virt/kvm/async_pf.c +++ b/virt/kvm/async_pf.c @@ -182,7 +182,7 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, { struct kvm_async_pf *work; - if (vcpu->async_pf.queued >= ASYNC_PF_PER_VCPU) + if (vcpu->async_pf.queued >= roundup_pow_of_two(ASYNC_PF_PER_VCPU)) return 0; /* setup delayed work */