From patchwork Thu Sep 18 16:38:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Liang Chen X-Patchwork-Id: 4932741 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B85EB9F32F for ; Thu, 18 Sep 2014 16:40:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E90B201BC for ; Thu, 18 Sep 2014 16:40:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 328D4201B4 for ; Thu, 18 Sep 2014 16:40:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932341AbaIRQkK (ORCPT ); Thu, 18 Sep 2014 12:40:10 -0400 Received: from mail-qc0-f182.google.com ([209.85.216.182]:48521 "EHLO mail-qc0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932092AbaIRQkH (ORCPT ); Thu, 18 Sep 2014 12:40:07 -0400 Received: by mail-qc0-f182.google.com with SMTP id i8so1010352qcq.27 for ; Thu, 18 Sep 2014 09:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=Es5Yq9mMs5C3m6zJWmnygLcnJM7tZYkmsCEsZGCTFag=; b=tMYgAMH/18P1QPvL7aAMS/qzCMtJ2PFxT6tNDL8PSI9No4EHWtjD2Ny1ty+xIYKIr/ 5zgDG4ShTdFQUkYEOUxlZmd/z+o1Si6dkDnUpqDxnnq0KYMqoZm5fhdoB0zcRXAvF+Yt NYpi4PytSr4CURih+Vp1OIpIosIZ8rnN476qJ/IhDoF5iXIwk2fXsLoBQVAlgBFXIQ20 2zwwJiaZsxBGhpIOfyB4B2KT9lyMbgINFR7df4wWK4wxCsvOHtQfkfc8rXyNf6+9Gtk0 P9a0nzLArAKquMeVyGZJhM/5miQjYxCdhXabi3NzyvRP+faHrNnQrhUYDZArsw0YP86I 2HmA== X-Received: by 10.140.88.134 with SMTP id t6mr673392qgd.12.1411058406991; Thu, 18 Sep 2014 09:40:06 -0700 (PDT) Received: from localhost.localdomain (c-174-57-166-71.hsd1.nj.comcast.net. [174.57.166.71]) by mx.google.com with ESMTPSA id r7sm17015143qai.15.2014.09.18.09.40.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Sep 2014 09:40:06 -0700 (PDT) From: Liang Chen To: pbonzini@redhat.com Cc: rkrcmar@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Liang Chen Subject: [PATCH v3 1/2] KVM: x86: count actual tlb flushes Date: Thu, 18 Sep 2014 12:38:36 -0400 Message-Id: <1411058317-23646-2-git-send-email-liangchen.linux@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411058317-23646-1-git-send-email-liangchen.linux@gmail.com> References: <1411058317-23646-1-git-send-email-liangchen.linux@gmail.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 From: Radim Kr?má? - we count KVM_REQ_TLB_FLUSH requests, not actual flushes (KVM can have multiple requests for one flush) - flushes from kvm_flush_remote_tlbs aren't counted - it's easy to make a direct request by mistake Solve these by postponing the counting to kvm_check_request(). Signed-off-by: Radim Kr?má? Signed-off-by: Liang Chen --- arch/x86/kvm/mmu.c | 1 - arch/x86/kvm/x86.c | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 9314678..b41fd97 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3452,7 +3452,6 @@ static void nonpaging_init_context(struct kvm_vcpu *vcpu, void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu) { - ++vcpu->stat.tlb_flush; kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); } EXPORT_SYMBOL_GPL(kvm_mmu_flush_tlb); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8f1e22d..9eb5458 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6017,8 +6017,10 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) } if (kvm_check_request(KVM_REQ_MMU_SYNC, vcpu)) kvm_mmu_sync_roots(vcpu); - if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu)) + if (kvm_check_request(KVM_REQ_TLB_FLUSH, vcpu)) { + ++vcpu->stat.tlb_flush; kvm_x86_ops->tlb_flush(vcpu); + } if (kvm_check_request(KVM_REQ_REPORT_TPR_ACCESS, vcpu)) { vcpu->run->exit_reason = KVM_EXIT_TPR_ACCESS; r = 0;