From patchwork Sun Sep 16 08:07:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10601677 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 8611B17EE for ; Sun, 16 Sep 2018 08:10:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7857E2A19B for ; Sun, 16 Sep 2018 08:10:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CC7B2A1C3; Sun, 16 Sep 2018 08:10:12 +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 131EE2A19B for ; Sun, 16 Sep 2018 08:10:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727058AbeIPN3b (ORCPT ); Sun, 16 Sep 2018 09:29:31 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45346 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbeIPN3a (ORCPT ); Sun, 16 Sep 2018 09:29:30 -0400 Received: by mail-pg1-f194.google.com with SMTP id x26-v6so6234085pge.12 for ; Sun, 16 Sep 2018 01:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LL3gzwDocuT5lgNBdYH8iwIKCd0aX/0RZD+Fay31paM=; b=S8DCdTh+AukfBxvgwKDidtXcwnHgzLEE3cCloMaMUfZE3d+U7+9RitU7Gfs4/ZGECF tvS6VgD9vXaN99mb/DWx9QjFREQiiInizcpbf9xMJtHQh9VWcE85O+AYJmmjqhdP44Ln njFYr7qtQ2dB+6U/2SYex7xTs50Nhn3B5FivOVtVP2NuVgAN0CT4tV54vCSKmv6DNvHL lv5Tvom1zUI4V4CB4dPljZ9IMsSYgVJWD5ddDf38huWzBhRm/y4z/dpiFIdqyWPFEWzz CNz9nqB5AUOO9IlHkngAX0eBili6z9z660gaCeJMVz3XTekvN1gDv/k1+sPcIarq0Jny a6kw== 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=LL3gzwDocuT5lgNBdYH8iwIKCd0aX/0RZD+Fay31paM=; b=i7qC5sOJmPfAPmsRdTeDha0OF9QYnbKHhMY5hHKhdYhhjUH+YruJbHnFK6whRPW+NM Xx5ij37rwexocoOChJp2aPsNAlQ0SQsZBHYEDEipy2SBzfvHXRuFLOcDmzomxvPLkNKl Lkk1W+MmuXzVDbF0L7jnmeV3Ve6WPoF1UhUkzD/x8FJvHQ70xn918LAH9aSfIxWKjtfh tHg6R6u5kxTI2rN8UpomEKEi/16BTCi50Q013cUfSx3U390UsYd48i8wx8ybsYMQgfZe Bh8SxefulQx+L6yqPGaedw1pCh0Vy6oZam2v/+SfWwSHLilJVWKaHDejJFpaEJ5jnK8c VMdg== X-Gm-Message-State: APzg51C0e95ZnXf1YLcEEWbw/78G4QSioMJlHohqEIsUKXoFOwlc08gQ q0l+r5BWUZW770kFI/n9qlw= X-Google-Smtp-Source: ANB0VdaEbSH3iMJchIsubD41AMAVX2JC/ovcOMxkYkvLfYsltYQ6CeSRWHAotiwC6DJPblVwqxPK8Q== X-Received: by 2002:a63:67c3:: with SMTP id b186-v6mr18622402pgc.5.1537085245093; Sun, 16 Sep 2018 01:07:25 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id k1-v6sm14295663pfi.62.2018.09.16.01.07.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Sep 2018 01:07:24 -0700 (PDT) From: Wei Yang To: pbonzini@redhat.com, rkrcmar@redhat.com Cc: x86@kernel.org, kvm@vger.kernel.org, Wei Yang Subject: [PATCH] KVM: x86: pvec always has more than 1 sp Date: Sun, 16 Sep 2018 16:07:16 +0800 Message-Id: <20180916080716.7270-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 Here is the code flow related to mmu_pages_first(): mmu_unsync_walk() mmu_pages_add() __mmu_unsync_walk() for_each_sp() mmu_pages_first() Every time when mmu_pages_first() is invoked, pvec is prepared by mmu_unsync_walk() which insert at least one sp in pvec. This patch removes the check on pvec->nr since this doesn't happen. Signed-off-by: Wei Yang --- arch/x86/kvm/mmu.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 899c029cff0d..0caaaa25e88b 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2267,9 +2267,6 @@ static int mmu_pages_first(struct kvm_mmu_pages *pvec, struct kvm_mmu_page *sp; int level; - if (pvec->nr == 0) - return 0; - WARN_ON(pvec->page[0].idx != INVALID_INDEX); sp = pvec->page[0].sp;