From patchwork Tue Apr 20 13:08:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoan Picchi X-Patchwork-Id: 12214219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DBC1C433B4 for ; Tue, 20 Apr 2021 13:11:06 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A79AA613C5 for ; Tue, 20 Apr 2021 13:11:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A79AA613C5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7oQ8r2z3u1n5VIIHnpiPt41GmInSbIBS539tGuZAp9k=; b=Xn18Dqba22KGWxB8SL87qE4Lhv IC4PI5lgrLzB3I3CaygYe0bM6q6tXWcZuS94qTk0d2Dcev2WXvavqPybwW/qnp8gt4ZjELza7Wa/m gKNxpvRUy3NkSMWxHeTcf8+HfUtsfjrg9p/IkTLdhoYHXuYanamTESCrJvODlLy43wczF6jxyeSqL z+2i0xEkO1NVbrcFhU0pp3PhKXjlSYWMVpjT/qJ02LpG402uQ7pVBApiEEb0QUCws5Sk23s0Ct5I+ ikz7aNi3c1vexCts/CO/GZwLpsouQryGr1Vn4ntskNAP9FjCdBjSTR4s4vgPn/t1JObZQsgVFfVXQ MgowaMqA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7e-00CA6k-8F; Tue, 20 Apr 2021 13:08:59 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7V-00CA5r-1X for linux-arm-kernel@desiato.infradead.org; Tue, 20 Apr 2021 13:08:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=30shxpscWJOWGJoSTNW74s02xRnaQE/4HEt3D6qTjuU=; b=TykhvfVGni73qAhFbf+intDpWG b6JcLWno6Z13mg05vRN09jBwTpB2tpWJ+PRsCsi48TFnOoHqAHqui3cFTp96h8Z3GxMwaQhEmJgdi uKjMab1+Ur+0Fl5xzAxr2+uwvIBc28JIWVrDpke4xrCLYe9pJz8G/z3rr7k9CgLR2cr3vAS5p3yZl BtMyg0L6/ej2XFjaycdlW16J7WgiSrXvaAebVY9oDIAQzVQpRQLUgy6Bz9tmy1liKbdy2HToinXFl jLisnCz1QUi/OvdhnkmVY6BfajvUcIXpqalttlNY8/FYGJQXLtBWb8/U5gRVE3nQNqb5c2dfMxgXo taXn84mg==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7S-00C7tZ-Cl for linux-arm-kernel@lists.infradead.org; Tue, 20 Apr 2021 13:08:47 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B23DE1478; Tue, 20 Apr 2021 06:08:45 -0700 (PDT) Received: from yoan-MS-7758.Home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 55ED03F792; Tue, 20 Apr 2021 06:08:44 -0700 (PDT) From: Yoan Picchi To: maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: catalin.marinas@arm.com, will@kernel.org, Yoan Picchi Subject: [PATCH v2 1/3] KVM: arm64: Add a stage2 page fault counter for kvm_stat Date: Tue, 20 Apr 2021 14:08:23 +0100 Message-Id: <20210420130825.15585-2-yoan.picchi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210420130825.15585-1-yoan.picchi@arm.com> References: <20210420130825.15585-1-yoan.picchi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210420_060846_502522_3D0E3B4B X-CRM114-Status: GOOD ( 12.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This counter is meant to detect stage 2 page fault exits. This is meant to measure how much those page fault influence the performance (by comparing this number of exits to some other exit causes). For now this counter is generic, but some more granularity is planned in the next commits so that one know how much of the page fault are for memory allocation, or for mmio for instance. The idea being that one using this counter can get a better idea of what is trigerring those exits to try to fix it. Signed-off-by: Yoan Picchi --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/guest.c | 1 + arch/arm64/kvm/mmu.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 3d10e6527..02891ce94 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -561,6 +561,7 @@ struct kvm_vcpu_stat { u64 wfi_exit_stat; u64 mmio_exit_user; u64 mmio_exit_kernel; + u64 stage2_abort_exit; u64 exits; }; diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 9bbd30e62..82a4b6275 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -38,6 +38,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { VCPU_STAT("wfi_exit_stat", wfi_exit_stat), VCPU_STAT("mmio_exit_user", mmio_exit_user), VCPU_STAT("mmio_exit_kernel", mmio_exit_kernel), + VCPU_STAT("stage2_abort_exit", stage2_abort_exit), VCPU_STAT("exits", exits), VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 77cb2d28f..c3527ccf6 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -966,6 +966,7 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu) fault_ipa = kvm_vcpu_get_fault_ipa(vcpu); is_iabt = kvm_vcpu_trap_is_iabt(vcpu); + /* Synchronous External Abort? */ if (kvm_vcpu_abt_issea(vcpu)) { /* @@ -980,6 +981,7 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu) trace_kvm_guest_fault(*vcpu_pc(vcpu), kvm_vcpu_get_esr(vcpu), kvm_vcpu_get_hfar(vcpu), fault_ipa); + vcpu->stat.stage2_abort_exit++; /* Check the stage-2 fault is trans. fault or write fault */ if (fault_status != FSC_FAULT && fault_status != FSC_PERM && From patchwork Tue Apr 20 13:08:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoan Picchi X-Patchwork-Id: 12214221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 191ACC433ED for ; Tue, 20 Apr 2021 13:11:14 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6ABAD61073 for ; Tue, 20 Apr 2021 13:11:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6ABAD61073 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ev/OAJRgsEkJdTfGjVCvpNZJ7zb9WYlIGkiUStrWhBQ=; b=bKEaJzbgP4CjMJ8Z89n38Y6cAJ 0P82ZK68p8a8DLfGmBHq4uLNB1MN1ZhKxKARAVNRuMcw9tFMStFWf7O4F7KhdKmBiNO0xMaTw+ypa P1WM4xTf+qW6sshPjJt4nnvbjnxDq4WDp7fDpICsKhZc5RfzL4bdMI2+GEpPmH7redGg5bNW67H7Q UQa9HjGjarXcQDEWpv9vlVizxC4fI9t2MMVeZSxxY342C8IXaideNZsXmdvEQwv8nE9d3I1G5SKsX O+169x3bPiD4zt1s6S3FU+Cdi0YAeetP925Zi6oWVGdA3aYZpd3Ylf/9PatFxo/fwpTzC1Pm6jSHf HHnEwp+g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7o-00CA7l-6Z; Tue, 20 Apr 2021 13:09:08 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7X-00CA6C-RU for linux-arm-kernel@desiato.infradead.org; Tue, 20 Apr 2021 13:08:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2s4VnhvgLZ1+L63yjFEMoX7gkuCcGBX7mFUjVL8jyF0=; b=QbV/hWDvnp6YdBMZ8XEJD8LJ0Z L+fUdsOtna0R2LJkxeOjjxpEyZ7zaZdHqv98y12Vw0H2XPEdSA6AkeXESdVyqoJD6oZFWOPuHAe6d Hj75WKUGWLHJihlpeqghTyLPkCCvmLbPtZM/B57hQzF+nE5LMBj2KQd5U/gmsXvMbvfo1lAZYC/Ga VyQNfEjsWIkXbDvvzjJsgcVQagV1kVu4Qz1Py8be9txZV3jZjXBOQRrs/Oi/UMnOQ9d/fek8zqLwW enFaOQX51Vi6XX7v8E4Cvi/lHJuDnWXIVqaycv2ZmM2HmSmtXpPvrZeyQRaAusU1PRpeUCCbaksTC DtI5kkjA==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7V-00C7ts-2r for linux-arm-kernel@lists.infradead.org; Tue, 20 Apr 2021 13:08:50 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 50B6514BF; Tue, 20 Apr 2021 06:08:47 -0700 (PDT) Received: from yoan-MS-7758.Home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EA5FB3F792; Tue, 20 Apr 2021 06:08:45 -0700 (PDT) From: Yoan Picchi To: maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: catalin.marinas@arm.com, will@kernel.org, Yoan Picchi Subject: [PATCH v2 2/3] KVM: arm64: Add two page mapping counters for kvm_stat Date: Tue, 20 Apr 2021 14:08:24 +0100 Message-Id: <20210420130825.15585-3-yoan.picchi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210420130825.15585-1-yoan.picchi@arm.com> References: <20210420130825.15585-1-yoan.picchi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210420_060849_241413_9694FD7B X-CRM114-Status: GOOD ( 21.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch adds regular_page_mapped and huge_page_mapped. regular_page_mapped is increased when a page of the smallest granularity is mapped. This is usually a 4k, 16k or 64k page. huge_page_mapped is increased when a huge page of any size other than the smallest granularity is mapped. Those counters only count pages allocated for the data and doesn't count the pages/blocks allocated to the page tables as I don't see where those might be needed to be recorded I can see two usecases for those counters : We can detect memory pressure in the host when the guest gets regular pages instead of huge ones. May help detecting an abnormal memory usage like some recurring allocs past the kernel and a few program starts. With the previous patch about stage2_abort_exit, it have the added benefit of specifying the second main cause of stage 2 page fault (the other being mmio access) To test this patch I did start a guest VM and monitor the page allocation. By default it only allocate huge pages. Then I tried to disable the huge pages with : echo never > /sys/kernel/mm/transparent_hugepage/enabled Starting the VM, it no longer allocate any huge page, but only regular pages. I can't log into the guess because it doesn't recognize my keyboard. To circumvent that I added some command to the init script that need some memory : cat /dev/zero | head -c 1000m | tail This take 1GiB of memory before finishing. From memory, it allocate 525 or so huge table which is around what I would expect with 2MB pages. I did check the relation between stage 2 exits, mmio exits and allocation. The mmio + allocation account for almost all the stage 2 exit as expected. There was only about 20 exits that was neither a mmio or an alloc during the kernel boot. I did not look what they are, but it can be a memory permission relaxation, or resizing a page. My main concern here is about the case where we replace a page/block by another/resize a block. I don't fully understand the mechanism yet and so don't know if it should be counted as an allocation or not. For now I don't account it. Signed-off-by: Yoan Picchi --- arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/kvm/guest.c | 2 ++ arch/arm64/kvm/hyp/pgtable.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 02891ce94..8f9d27571 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -547,6 +547,8 @@ static inline bool __vcpu_write_sys_reg_to_cpu(u64 val, int reg) struct kvm_vm_stat { ulong remote_tlb_flush; + ulong regular_page_mapped; + ulong huge_page_mapped; }; struct kvm_vcpu_stat { diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 82a4b6275..41316b30e 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -42,6 +42,8 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { VCPU_STAT("exits", exits), VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), + VM_STAT("regular_page_mapped", regular_page_mapped), + VM_STAT("huge_page_mapped", huge_page_mapped), { NULL } }; diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 4d177ce1d..2aba2b636 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -498,6 +498,11 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, smp_store_release(ptep, new); get_page(page); data->phys += granule; + if (level == KVM_PGTABLE_MAX_LEVELS - 1) + data->mmu->kvm->stat.regular_page_mapped++; + else + data->mmu->kvm->stat.huge_page_mapped++; + return 0; } From patchwork Tue Apr 20 13:08:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoan Picchi X-Patchwork-Id: 12214223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0192DC433ED for ; Tue, 20 Apr 2021 13:11:21 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9902D613C3 for ; Tue, 20 Apr 2021 13:11:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9902D613C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SZU66LEOdEsvgul0cueQkVuuGPxbNzLxIlARmKsQebQ=; b=SRIpZi8yxnF/TRQKDtvdJZLj+z f8TihID/PnrbWvTJ3KoZpGX7w9Z5/EnMT1r6fcuB56bWTz80l+L7T6f7XTgMffJAgpM6ylA3wkJHi ycdYdLCG4uZD+0wc2IrRPBv1BS0yrPM9QCR5OAsl+8ahK18e84ScvM53nmbZcVWnngEdrAkLbVkNL U1/XuBJMLg49b334y/0XOu0qZjestPtmkRuzyrtUAb3BRl0g0hMsU4emgAI7hzkiq58Xq7staXTx1 g2bVFbQDe5Q0X5Cl1LfHs46kGOFkKlWq/w9fJWMaVSnv3ORWpWMO6tOTtM5wVlhImS2huiGebF7tQ wBCmQX+g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7y-00CA9E-VB; Tue, 20 Apr 2021 13:09:20 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7X-00CA6D-Tp for linux-arm-kernel@desiato.infradead.org; Tue, 20 Apr 2021 13:08:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=u7nMWlv+dATKDPgw+aQki3/MtwVlTjNUpynYVidt2z4=; b=brWxH9W4+yp/h298f5q4GROk3W GjX48q6II3lCuZ1z+UqsQGhPd13dEi2FQMvOj7Nu+ZnxNCZSD4f7ImFybXaBuW6EIOJoVAkSt4mjZ 4e7fW0uIxSZJTyJbN++TytQnHleM2dnWpGKwDZZ/xuV5SZxbzRUteKrhq6KPxOCl5sp8qk+Kkwiv8 kqsfsrgEoPn5MS62l/XgaJjY2fHrAvBT4keqGNxDbjE+y7uMPtJNzQg86F8VwSgca9l1gwn/3z9PJ HZuY0Jh0Z25BEnkLqz/RT3ekCRtgSphpMXYXDAmr4JDqlP85U5rlWIwC1MrH/fRPyRbbNVVLoDyyV S+hcbBNw==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYq7V-00C7ty-Eb for linux-arm-kernel@lists.infradead.org; Tue, 20 Apr 2021 13:08:50 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E3C221478; Tue, 20 Apr 2021 06:08:48 -0700 (PDT) Received: from yoan-MS-7758.Home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8A57F3F792; Tue, 20 Apr 2021 06:08:47 -0700 (PDT) From: Yoan Picchi To: maz@kernel.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: catalin.marinas@arm.com, will@kernel.org, Yoan Picchi Subject: [PATCH v2 3/3] KVM: arm64: Add irq_exit counter for kvm_stat Date: Tue, 20 Apr 2021 14:08:25 +0100 Message-Id: <20210420130825.15585-4-yoan.picchi@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210420130825.15585-1-yoan.picchi@arm.com> References: <20210420130825.15585-1-yoan.picchi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210420_060849_552686_A359C0FD X-CRM114-Status: UNSURE ( 9.83 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This counter is meant to detect when the guest vm exits due to an interrupt. Those interrupts might be unrelated to the guest VM (say, some network packet arrived, and such) but they still trigger an exit which is recorded by the "exit" counter. The main purpose of this counter is to give some more granularity to this base exit counter so that one can have a rough idea of where those exits comes from and so, if those general exits happen because of the host or of the guest. Signed-off-by: Yoan Picchi --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/guest.c | 1 + arch/arm64/kvm/handle_exit.c | 1 + 3 files changed, 3 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 8f9d27571..185e707fb 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -565,6 +565,7 @@ struct kvm_vcpu_stat { u64 mmio_exit_kernel; u64 stage2_abort_exit; u64 exits; + u64 irq_exits; }; int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init); diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 41316b30e..eb4c24b7a 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -42,6 +42,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { VCPU_STAT("exits", exits), VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), + VCPU_STAT("irq_exits", irq_exits), VM_STAT("regular_page_mapped", regular_page_mapped), VM_STAT("huge_page_mapped", huge_page_mapped), { NULL } diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index cebe39f3b..7e5dbc5ff 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -244,6 +244,7 @@ int handle_exit(struct kvm_vcpu *vcpu, int exception_index) switch (exception_index) { case ARM_EXCEPTION_IRQ: + vcpu->stat.irq_exits++; return 1; case ARM_EXCEPTION_EL1_SERROR: return 1;