From patchwork Fri Feb 15 04:10:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 10814145 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 B316013A4 for ; Fri, 15 Feb 2019 04:10:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92B142EC78 for ; Fri, 15 Feb 2019 04:10:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84D7F2EC80; Fri, 15 Feb 2019 04:10:27 +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 241002EC78 for ; Fri, 15 Feb 2019 04:10:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730684AbfBOEK0 (ORCPT ); Thu, 14 Feb 2019 23:10:26 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:37712 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729594AbfBOEKZ (ORCPT ); Thu, 14 Feb 2019 23:10:25 -0500 Received: by mail-pg1-f196.google.com with SMTP id q206so4170255pgq.4; Thu, 14 Feb 2019 20:10:25 -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=WmGbMniKCgUsrxyyJwK4gUwIV2Lp6eqak7RPGGw1vkc=; b=LB/0vDPW3mIBUwAuxXZ/CgFpn9R/Xt/v2bJDRW/2ALuxTPzn6qrSpx16ijBGYX1Bct aUxQ8G1MO0Efs3QjuwSM59VzL8TMbQuhOgJoCQp6TXFbw21yFQ1E7Xx40jEtRI/mZkZh jfb2+G+ft6KhZM1Rk+VrTNv+78g+40Z0KGrB4unCWDb9feNmucjy/6mrjZ366QT4VJ2Y rfm3kwZQ2BhoL7Th+aqqpwL3sBgA603GJuICUCe4VGRoYoJ0BrWR9Bb58RsTHb67CgNv PRShTGaZwFKHcCmRnK76MVtH/ZkexIM3cD+agiWb7Fo0EX1AWuP1Z0xVABKtpzBMNbjh cARQ== 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=WmGbMniKCgUsrxyyJwK4gUwIV2Lp6eqak7RPGGw1vkc=; b=IK41aegbcx3dkRvmn7Xjjhy21oKdtIi0+NcjagjF5OPVZ0lV4WxD2LRjK7l39SWhED 3uqL1d5vRPm6TkVV2+i9Et5EEuugiNjLUx4HlQdyvb3RcZ7kZe5mKth9roz3mzRidxPE kXbbabC3qZWgz0GCi4IQkCpQUO0IH1m9LSfXDhD4XL9u4f67kI4ZJyAWx6biVFnbyezj 0vO2TD3SqiF/RAXWuXgbBX8NcMfCGYWOJyYLQVyWY1HEggysJzQPCgZVtm00yZcs57Yy 5hAbqYMrLy5m7bp+eZLRDnf/x7LZ/R8+aOFJmR1s0hLqnsRuR7YDFfKQ2aTZrz6qbxWi 5vTw== X-Gm-Message-State: AHQUAuaACX6xXLwpZMAgQrewx0OgxUl1ohFIgDcGonEgpTYisNMPA9FP UnCoteYr9hx4gNH72b1T41d6lXd0 X-Google-Smtp-Source: AHgI3IabauFapV4yiDX0/GrikfoNH7r7KVHLYrRaspd6HMXryW+mGjdIxweOCDlkLp03Vl+UZ7d4Zw== X-Received: by 2002:aa7:85cc:: with SMTP id z12mr7843671pfn.196.1550203824493; Thu, 14 Feb 2019 20:10:24 -0800 (PST) Received: from surajjs2.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t65sm8413310pfi.117.2019.02.14.20.10.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 20:10:23 -0800 (PST) From: Suraj Jitindar Singh To: kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, paulus@ozlabs.org, Suraj Jitindar Singh Subject: [PATCH] KVM: PPC: Book3S: Add KVM stat num_[2M/1G]_pages Date: Fri, 15 Feb 2019 15:10:04 +1100 Message-Id: <20190215041004.10575-1-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds an entry to the kvm_stats_debugfs directory which provides the number of large (2M or 1G) pages which have been used to setup the guest mappings. Signed-off-by: Suraj Jitindar Singh --- arch/powerpc/include/asm/kvm_host.h | 2 ++ arch/powerpc/kvm/book3s.c | 3 +++ arch/powerpc/kvm/book3s_64_mmu_radix.c | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h index 0f98f00da2ea..cbb090010312 100644 --- a/arch/powerpc/include/asm/kvm_host.h +++ b/arch/powerpc/include/asm/kvm_host.h @@ -99,6 +99,8 @@ struct kvm_nested_guest; struct kvm_vm_stat { ulong remote_tlb_flush; + ulong num_2M_pages; + ulong num_1G_pages; }; struct kvm_vcpu_stat { diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index bd1a677dd9e4..3cc5215bdb2e 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -39,6 +39,7 @@ #include "book3s.h" #include "trace.h" +#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU /* #define EXIT_DEBUG */ @@ -71,6 +72,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { { "pthru_all", VCPU_STAT(pthru_all) }, { "pthru_host", VCPU_STAT(pthru_host) }, { "pthru_bad_aff", VCPU_STAT(pthru_bad_aff) }, + { "num_2M_pages", VM_STAT(num_2M_pages) }, + { "num_1G_pages", VM_STAT(num_1G_pages) }, { NULL } }; diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c index 1b821c6efdef..f55ef071883f 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c @@ -403,8 +403,13 @@ void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, unsigned long gpa, if (!memslot) return; } - if (shift) + if (shift) { /* 1GB or 2MB page */ page_size = 1ul << shift; + if (shift == PMD_SHIFT) + kvm->stat.num_2M_pages--; + else if (shift == PUD_SHIFT) + kvm->stat.num_1G_pages--; + } gpa &= ~(page_size - 1); hpa = old & PTE_RPN_MASK; @@ -878,6 +883,14 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu, put_page(page); } + /* Increment number of large pages if we (successfully) inserted one */ + if (!ret) { + if (level == 1) + kvm->stat.num_2M_pages++; + else if (level == 2) + kvm->stat.num_1G_pages++; + } + return ret; }