From patchwork Mon Mar 6 19:01:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13162217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63433C64EC4 for ; Mon, 6 Mar 2023 19:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0EjM0fyvqz0zVIPbtCeCJPISnxWo8zfbrznvk3sowCc=; b=jgNdwYbGIHeBmHAfUOaNfhGUy7 b7sTlsO0jjkwDlLXEE68R0eSrrqIo/hOhKiCwRSAZqd6ulvE93nqIx2/UC0HQw7U8/QhGq4oxB1OQ YXhQU0dfijeSMbAfWNMz1qeWjeFgpuLL0UiUUTq5rLqmRxmGhrKzmJmqht7olo4D5driyB+JOCn62 V4GrZqAognotikBNOgvQFrfRmd7I9iBXd1DUT+HxxHce3fj5f1eLUNNXw/JDYpLqRt9yVq0Fw6hdF 16M9gaz73X/+j9E8FCpkC5Ifwmaa4LY90pI6ckogDpSxN3/IVmmLaUV2rpYwgLfqqRmYO1+MfwHVA xvVtPSyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG6h-00ERqq-ED; Mon, 06 Mar 2023 19:02:47 +0000 Received: from mail-pj1-x1049.google.com ([2607:f8b0:4864:20::1049]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG60-00ERUC-50 for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2023 19:02:10 +0000 Received: by mail-pj1-x1049.google.com with SMTP id in9-20020a17090b438900b00237161acdfcso2878525pjb.1 for ; Mon, 06 Mar 2023 11:02:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678129321; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=aVeYFUAaozUOnFog0adFgmU2JgVVSGajkgl902L/1Rk=; b=ayF7i9DvZYu0FDkTEvY+lEZ1TzR7tFwo1A5yCyweiwEzFA0569mKnfCWbwfT1RuYoi aaoj0OLX7WH5Im9zuLmCg3rZNvdhl90C4a1BKpyW4x/Rubg7L9dVdsaZmtTnUT5cfTnk Nc1lmZ6fPheWE0NkKvZ9+Lp9C29mSi0spLczKUwC8b0qgfoe41IPITIS2c14lITxvnPM zhrb7ld7vwVaQdcKugb86XtsYk3weAUHE303Fxtk7OcLXuHXe96DFmN1WUOTaubuCtuP QQRVnUdGWrto44NaTGO0O7pKktt0pIZOJ+IqWSgMFAUkK80pJi/ziF6HAXcS1lPVrp2I luDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678129321; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aVeYFUAaozUOnFog0adFgmU2JgVVSGajkgl902L/1Rk=; b=TA/BMmoNKNGySVN25sEkYcr6z0tnPev1pwtOTAfFShK5S2W1o3cJi84BXV2Qa2KYLc PaxY0ssNqT5fKUC9C7saVAs4Ed8Kr82Ft9VJGSES0qBVdrCIoGmxxHI0jpN9oM/qvG/9 +Qwk8YhRNZcaLZJ79b0gz0wnfgsGVIzTxTc49Rh7nV6QhKHewg0QgnJy9Zo0l7JZxtuC okfFYc91w6o+tLMGAX4z1OaokfGoPqRkX8DvF/n7Tx6R3ymSFfhawELwugId5A/9thhd 4oiLNjgYMY3tAGlr7acAs4TJWYBNmJz2okqsFr9HiaFuCFLg2JIlyF4uWV4A8WONsTLY wSZg== X-Gm-Message-State: AO0yUKUVgq9oebUklV3q4GVQvyyiSaBjAYhuB44vp9RXu/KTrxQEfpJZ zdrZyORmnslYHrqVuvpwwsdKopeS7s77qQ== X-Google-Smtp-Source: AK7set8bkhEjkaxKFJOK+csmU8XUtWiWxWElSO+3ptgGRXr0eXqqwcSExjspxYfl4cT7fbWwfKjZyhdLvknmjw== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a17:903:278d:b0:19c:1869:3558 with SMTP id jw13-20020a170903278d00b0019c18693558mr4672667plb.5.1678129321404; Mon, 06 Mar 2023 11:02:01 -0800 (PST) Date: Mon, 6 Mar 2023 11:01:53 -0800 In-Reply-To: <20230306190156.434452-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230306190156.434452-1-dmatlack@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306190156.434452-2-dmatlack@google.com> Subject: [PATCH v2 1/4] KVM: Refactor stats descriptor generation macros From: David Matlack To: Paolo Bonzini Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Sean Christopherson , Michael Ellerman , Eric Farman , " =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= " , David Matlack , Sathvika Vasireddy , Nicholas Piggin , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230306_110204_334775_CC0C473D X-CRM114-Status: GOOD ( 11.14 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Refactor the various KVM stats macros to reduce the amount of duplicate macro code. This change also improves readability by spelling out "CUMULATIVE", "INSTANT", and "PEAK" instead of the previous short-hands which were less clear ("COUNTER", "ICOUNTER", and "PCOUNTER"). No functional change intended. Suggested-by: Sean Christopherson Signed-off-by: David Matlack Acked-by: Anup Patel --- arch/arm64/kvm/guest.c | 14 +-- arch/mips/kvm/mips.c | 54 +++++------ arch/powerpc/kvm/book3s.c | 62 ++++++------ arch/powerpc/kvm/booke.c | 48 ++++----- arch/riscv/kvm/vcpu.c | 16 +-- arch/s390/kvm/kvm-s390.c | 198 +++++++++++++++++++------------------- arch/x86/kvm/x86.c | 94 +++++++++--------- include/linux/kvm_host.h | 95 ++++++------------ 8 files changed, 272 insertions(+), 309 deletions(-) diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 07444fa22888..890ed444c237 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -44,13 +44,13 @@ const struct kvm_stats_header kvm_vm_stats_header = { const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { KVM_GENERIC_VCPU_STATS(), - STATS_DESC_COUNTER(VCPU, hvc_exit_stat), - STATS_DESC_COUNTER(VCPU, wfe_exit_stat), - STATS_DESC_COUNTER(VCPU, wfi_exit_stat), - STATS_DESC_COUNTER(VCPU, mmio_exit_user), - STATS_DESC_COUNTER(VCPU, mmio_exit_kernel), - STATS_DESC_COUNTER(VCPU, signal_exits), - STATS_DESC_COUNTER(VCPU, exits) + KVM_STAT(VCPU, CUMULATIVE, NONE, hvc_exit_stat), + KVM_STAT(VCPU, CUMULATIVE, NONE, wfe_exit_stat), + KVM_STAT(VCPU, CUMULATIVE, NONE, wfi_exit_stat), + KVM_STAT(VCPU, CUMULATIVE, NONE, mmio_exit_user), + KVM_STAT(VCPU, CUMULATIVE, NONE, mmio_exit_kernel), + KVM_STAT(VCPU, CUMULATIVE, NONE, signal_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, exits) }; const struct kvm_stats_header kvm_vcpu_stats_header = { diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c index 36c8991b5d39..b7b2fa400bcf 100644 --- a/arch/mips/kvm/mips.c +++ b/arch/mips/kvm/mips.c @@ -53,34 +53,34 @@ const struct kvm_stats_header kvm_vm_stats_header = { const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { KVM_GENERIC_VCPU_STATS(), - STATS_DESC_COUNTER(VCPU, wait_exits), - STATS_DESC_COUNTER(VCPU, cache_exits), - STATS_DESC_COUNTER(VCPU, signal_exits), - STATS_DESC_COUNTER(VCPU, int_exits), - STATS_DESC_COUNTER(VCPU, cop_unusable_exits), - STATS_DESC_COUNTER(VCPU, tlbmod_exits), - STATS_DESC_COUNTER(VCPU, tlbmiss_ld_exits), - STATS_DESC_COUNTER(VCPU, tlbmiss_st_exits), - STATS_DESC_COUNTER(VCPU, addrerr_st_exits), - STATS_DESC_COUNTER(VCPU, addrerr_ld_exits), - STATS_DESC_COUNTER(VCPU, syscall_exits), - STATS_DESC_COUNTER(VCPU, resvd_inst_exits), - STATS_DESC_COUNTER(VCPU, break_inst_exits), - STATS_DESC_COUNTER(VCPU, trap_inst_exits), - STATS_DESC_COUNTER(VCPU, msa_fpe_exits), - STATS_DESC_COUNTER(VCPU, fpe_exits), - STATS_DESC_COUNTER(VCPU, msa_disabled_exits), - STATS_DESC_COUNTER(VCPU, flush_dcache_exits), - STATS_DESC_COUNTER(VCPU, vz_gpsi_exits), - STATS_DESC_COUNTER(VCPU, vz_gsfc_exits), - STATS_DESC_COUNTER(VCPU, vz_hc_exits), - STATS_DESC_COUNTER(VCPU, vz_grr_exits), - STATS_DESC_COUNTER(VCPU, vz_gva_exits), - STATS_DESC_COUNTER(VCPU, vz_ghfc_exits), - STATS_DESC_COUNTER(VCPU, vz_gpa_exits), - STATS_DESC_COUNTER(VCPU, vz_resvd_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, wait_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, cache_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, signal_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, int_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, cop_unusable_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, tlbmod_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, tlbmiss_ld_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, tlbmiss_st_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, addrerr_st_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, addrerr_ld_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, syscall_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, resvd_inst_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, break_inst_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, trap_inst_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, msa_fpe_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, fpe_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, msa_disabled_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, flush_dcache_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, vz_gpsi_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, vz_gsfc_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, vz_hc_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, vz_grr_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, vz_gva_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, vz_ghfc_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, vz_gpa_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, vz_resvd_exits), #ifdef CONFIG_CPU_LOONGSON64 - STATS_DESC_COUNTER(VCPU, vz_cpucfg_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, vz_cpucfg_exits), #endif }; diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 57f4e7896d67..8a7a932961d5 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c @@ -40,8 +40,8 @@ const struct _kvm_stats_desc kvm_vm_stats_desc[] = { KVM_GENERIC_VM_STATS(), - STATS_DESC_ICOUNTER(VM, num_2M_pages), - STATS_DESC_ICOUNTER(VM, num_1G_pages) + KVM_STAT(VM, INSTANT, NONE, num_2M_pages), + KVM_STAT(VM, INSTANT, NONE, num_1G_pages) }; const struct kvm_stats_header kvm_vm_stats_header = { @@ -55,35 +55,35 @@ const struct kvm_stats_header kvm_vm_stats_header = { const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { KVM_GENERIC_VCPU_STATS(), - STATS_DESC_COUNTER(VCPU, sum_exits), - STATS_DESC_COUNTER(VCPU, mmio_exits), - STATS_DESC_COUNTER(VCPU, signal_exits), - STATS_DESC_COUNTER(VCPU, light_exits), - STATS_DESC_COUNTER(VCPU, itlb_real_miss_exits), - STATS_DESC_COUNTER(VCPU, itlb_virt_miss_exits), - STATS_DESC_COUNTER(VCPU, dtlb_real_miss_exits), - STATS_DESC_COUNTER(VCPU, dtlb_virt_miss_exits), - STATS_DESC_COUNTER(VCPU, syscall_exits), - STATS_DESC_COUNTER(VCPU, isi_exits), - STATS_DESC_COUNTER(VCPU, dsi_exits), - STATS_DESC_COUNTER(VCPU, emulated_inst_exits), - STATS_DESC_COUNTER(VCPU, dec_exits), - STATS_DESC_COUNTER(VCPU, ext_intr_exits), - STATS_DESC_COUNTER(VCPU, halt_successful_wait), - STATS_DESC_COUNTER(VCPU, dbell_exits), - STATS_DESC_COUNTER(VCPU, gdbell_exits), - STATS_DESC_COUNTER(VCPU, ld), - STATS_DESC_COUNTER(VCPU, st), - STATS_DESC_COUNTER(VCPU, pf_storage), - STATS_DESC_COUNTER(VCPU, pf_instruc), - STATS_DESC_COUNTER(VCPU, sp_storage), - STATS_DESC_COUNTER(VCPU, sp_instruc), - STATS_DESC_COUNTER(VCPU, queue_intr), - STATS_DESC_COUNTER(VCPU, ld_slow), - STATS_DESC_COUNTER(VCPU, st_slow), - STATS_DESC_COUNTER(VCPU, pthru_all), - STATS_DESC_COUNTER(VCPU, pthru_host), - STATS_DESC_COUNTER(VCPU, pthru_bad_aff) + KVM_STAT(VM, CUMULATIVE, NONE, sum_exits), + KVM_STAT(VM, CUMULATIVE, NONE, mmio_exits), + KVM_STAT(VM, CUMULATIVE, NONE, signal_exits), + KVM_STAT(VM, CUMULATIVE, NONE, light_exits), + KVM_STAT(VM, CUMULATIVE, NONE, itlb_real_miss_exits), + KVM_STAT(VM, CUMULATIVE, NONE, itlb_virt_miss_exits), + KVM_STAT(VM, CUMULATIVE, NONE, dtlb_real_miss_exits), + KVM_STAT(VM, CUMULATIVE, NONE, dtlb_virt_miss_exits), + KVM_STAT(VM, CUMULATIVE, NONE, syscall_exits), + KVM_STAT(VM, CUMULATIVE, NONE, isi_exits), + KVM_STAT(VM, CUMULATIVE, NONE, dsi_exits), + KVM_STAT(VM, CUMULATIVE, NONE, emulated_inst_exits), + KVM_STAT(VM, CUMULATIVE, NONE, dec_exits), + KVM_STAT(VM, CUMULATIVE, NONE, ext_intr_exits), + KVM_STAT(VM, CUMULATIVE, NONE, halt_successful_wait), + KVM_STAT(VM, CUMULATIVE, NONE, dbell_exits), + KVM_STAT(VM, CUMULATIVE, NONE, gdbell_exits), + KVM_STAT(VM, CUMULATIVE, NONE, ld), + KVM_STAT(VM, CUMULATIVE, NONE, st), + KVM_STAT(VM, CUMULATIVE, NONE, pf_storage), + KVM_STAT(VM, CUMULATIVE, NONE, pf_instruc), + KVM_STAT(VM, CUMULATIVE, NONE, sp_storage), + KVM_STAT(VM, CUMULATIVE, NONE, sp_instruc), + KVM_STAT(VM, CUMULATIVE, NONE, queue_intr), + KVM_STAT(VM, CUMULATIVE, NONE, ld_slow), + KVM_STAT(VM, CUMULATIVE, NONE, st_slow), + KVM_STAT(VM, CUMULATIVE, NONE, pthru_all), + KVM_STAT(VM, CUMULATIVE, NONE, pthru_host), + KVM_STAT(VM, CUMULATIVE, NONE, pthru_bad_aff) }; const struct kvm_stats_header kvm_vcpu_stats_header = { diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 01adffb24667..898bdd583289 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -38,8 +38,8 @@ unsigned long kvmppc_booke_handlers; const struct _kvm_stats_desc kvm_vm_stats_desc[] = { KVM_GENERIC_VM_STATS(), - STATS_DESC_ICOUNTER(VM, num_2M_pages), - STATS_DESC_ICOUNTER(VM, num_1G_pages) + KVM_STAT(VM, INSTANT, NONE, num_2M_pages), + KVM_STAT(VM, INSTANT, NONE, num_1G_pages) }; const struct kvm_stats_header kvm_vm_stats_header = { @@ -53,28 +53,28 @@ const struct kvm_stats_header kvm_vm_stats_header = { const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { KVM_GENERIC_VCPU_STATS(), - STATS_DESC_COUNTER(VCPU, sum_exits), - STATS_DESC_COUNTER(VCPU, mmio_exits), - STATS_DESC_COUNTER(VCPU, signal_exits), - STATS_DESC_COUNTER(VCPU, light_exits), - STATS_DESC_COUNTER(VCPU, itlb_real_miss_exits), - STATS_DESC_COUNTER(VCPU, itlb_virt_miss_exits), - STATS_DESC_COUNTER(VCPU, dtlb_real_miss_exits), - STATS_DESC_COUNTER(VCPU, dtlb_virt_miss_exits), - STATS_DESC_COUNTER(VCPU, syscall_exits), - STATS_DESC_COUNTER(VCPU, isi_exits), - STATS_DESC_COUNTER(VCPU, dsi_exits), - STATS_DESC_COUNTER(VCPU, emulated_inst_exits), - STATS_DESC_COUNTER(VCPU, dec_exits), - STATS_DESC_COUNTER(VCPU, ext_intr_exits), - STATS_DESC_COUNTER(VCPU, halt_successful_wait), - STATS_DESC_COUNTER(VCPU, dbell_exits), - STATS_DESC_COUNTER(VCPU, gdbell_exits), - STATS_DESC_COUNTER(VCPU, ld), - STATS_DESC_COUNTER(VCPU, st), - STATS_DESC_COUNTER(VCPU, pthru_all), - STATS_DESC_COUNTER(VCPU, pthru_host), - STATS_DESC_COUNTER(VCPU, pthru_bad_aff) + KVM_STAT(VCPU, CUMULATIVE, NONE, sum_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, mmio_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, signal_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, light_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, itlb_real_miss_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, itlb_virt_miss_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, dtlb_real_miss_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, dtlb_virt_miss_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, syscall_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, isi_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, dsi_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, emulated_inst_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, dec_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, ext_intr_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, halt_successful_wait), + KVM_STAT(VCPU, CUMULATIVE, NONE, dbell_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, gdbell_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, ld), + KVM_STAT(VCPU, CUMULATIVE, NONE, st), + KVM_STAT(VCPU, CUMULATIVE, NONE, pthru_all), + KVM_STAT(VCPU, CUMULATIVE, NONE, pthru_host), + KVM_STAT(VCPU, CUMULATIVE, NONE, pthru_bad_aff) }; const struct kvm_stats_header kvm_vcpu_stats_header = { diff --git a/arch/riscv/kvm/vcpu.c b/arch/riscv/kvm/vcpu.c index 7d010b0be54e..57f57f6f5baf 100644 --- a/arch/riscv/kvm/vcpu.c +++ b/arch/riscv/kvm/vcpu.c @@ -25,14 +25,14 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { KVM_GENERIC_VCPU_STATS(), - STATS_DESC_COUNTER(VCPU, ecall_exit_stat), - STATS_DESC_COUNTER(VCPU, wfi_exit_stat), - STATS_DESC_COUNTER(VCPU, mmio_exit_user), - STATS_DESC_COUNTER(VCPU, mmio_exit_kernel), - STATS_DESC_COUNTER(VCPU, csr_exit_user), - STATS_DESC_COUNTER(VCPU, csr_exit_kernel), - STATS_DESC_COUNTER(VCPU, signal_exits), - STATS_DESC_COUNTER(VCPU, exits) + KVM_STAT(VCPU, CUMULATIVE, NONE, ecall_exit_stat), + KVM_STAT(VCPU, CUMULATIVE, NONE, wfi_exit_stat), + KVM_STAT(VCPU, CUMULATIVE, NONE, mmio_exit_user), + KVM_STAT(VCPU, CUMULATIVE, NONE, mmio_exit_kernel), + KVM_STAT(VCPU, CUMULATIVE, NONE, csr_exit_user), + KVM_STAT(VCPU, CUMULATIVE, NONE, csr_exit_kernel), + KVM_STAT(VCPU, CUMULATIVE, NONE, signal_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, exits) }; const struct kvm_stats_header kvm_vcpu_stats_header = { diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 39b36562c043..dfb3bc4d4b46 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c @@ -61,12 +61,12 @@ const struct _kvm_stats_desc kvm_vm_stats_desc[] = { KVM_GENERIC_VM_STATS(), - STATS_DESC_COUNTER(VM, inject_io), - STATS_DESC_COUNTER(VM, inject_float_mchk), - STATS_DESC_COUNTER(VM, inject_pfault_done), - STATS_DESC_COUNTER(VM, inject_service_signal), - STATS_DESC_COUNTER(VM, inject_virtio), - STATS_DESC_COUNTER(VM, aen_forward) + KVM_STAT(VM, CUMULATIVE, NONE, inject_io), + KVM_STAT(VM, CUMULATIVE, NONE, inject_float_mchk), + KVM_STAT(VM, CUMULATIVE, NONE, inject_pfault_done), + KVM_STAT(VM, CUMULATIVE, NONE, inject_service_signal), + KVM_STAT(VM, CUMULATIVE, NONE, inject_virtio), + KVM_STAT(VM, CUMULATIVE, NONE, aen_forward) }; const struct kvm_stats_header kvm_vm_stats_header = { @@ -80,99 +80,99 @@ const struct kvm_stats_header kvm_vm_stats_header = { const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { KVM_GENERIC_VCPU_STATS(), - STATS_DESC_COUNTER(VCPU, exit_userspace), - STATS_DESC_COUNTER(VCPU, exit_null), - STATS_DESC_COUNTER(VCPU, exit_external_request), - STATS_DESC_COUNTER(VCPU, exit_io_request), - STATS_DESC_COUNTER(VCPU, exit_external_interrupt), - STATS_DESC_COUNTER(VCPU, exit_stop_request), - STATS_DESC_COUNTER(VCPU, exit_validity), - STATS_DESC_COUNTER(VCPU, exit_instruction), - STATS_DESC_COUNTER(VCPU, exit_pei), - STATS_DESC_COUNTER(VCPU, halt_no_poll_steal), - STATS_DESC_COUNTER(VCPU, instruction_lctl), - STATS_DESC_COUNTER(VCPU, instruction_lctlg), - STATS_DESC_COUNTER(VCPU, instruction_stctl), - STATS_DESC_COUNTER(VCPU, instruction_stctg), - STATS_DESC_COUNTER(VCPU, exit_program_interruption), - STATS_DESC_COUNTER(VCPU, exit_instr_and_program), - STATS_DESC_COUNTER(VCPU, exit_operation_exception), - STATS_DESC_COUNTER(VCPU, deliver_ckc), - STATS_DESC_COUNTER(VCPU, deliver_cputm), - STATS_DESC_COUNTER(VCPU, deliver_external_call), - STATS_DESC_COUNTER(VCPU, deliver_emergency_signal), - STATS_DESC_COUNTER(VCPU, deliver_service_signal), - STATS_DESC_COUNTER(VCPU, deliver_virtio), - STATS_DESC_COUNTER(VCPU, deliver_stop_signal), - STATS_DESC_COUNTER(VCPU, deliver_prefix_signal), - STATS_DESC_COUNTER(VCPU, deliver_restart_signal), - STATS_DESC_COUNTER(VCPU, deliver_program), - STATS_DESC_COUNTER(VCPU, deliver_io), - STATS_DESC_COUNTER(VCPU, deliver_machine_check), - STATS_DESC_COUNTER(VCPU, exit_wait_state), - STATS_DESC_COUNTER(VCPU, inject_ckc), - STATS_DESC_COUNTER(VCPU, inject_cputm), - STATS_DESC_COUNTER(VCPU, inject_external_call), - STATS_DESC_COUNTER(VCPU, inject_emergency_signal), - STATS_DESC_COUNTER(VCPU, inject_mchk), - STATS_DESC_COUNTER(VCPU, inject_pfault_init), - STATS_DESC_COUNTER(VCPU, inject_program), - STATS_DESC_COUNTER(VCPU, inject_restart), - STATS_DESC_COUNTER(VCPU, inject_set_prefix), - STATS_DESC_COUNTER(VCPU, inject_stop_signal), - STATS_DESC_COUNTER(VCPU, instruction_epsw), - STATS_DESC_COUNTER(VCPU, instruction_gs), - STATS_DESC_COUNTER(VCPU, instruction_io_other), - STATS_DESC_COUNTER(VCPU, instruction_lpsw), - STATS_DESC_COUNTER(VCPU, instruction_lpswe), - STATS_DESC_COUNTER(VCPU, instruction_pfmf), - STATS_DESC_COUNTER(VCPU, instruction_ptff), - STATS_DESC_COUNTER(VCPU, instruction_sck), - STATS_DESC_COUNTER(VCPU, instruction_sckpf), - STATS_DESC_COUNTER(VCPU, instruction_stidp), - STATS_DESC_COUNTER(VCPU, instruction_spx), - STATS_DESC_COUNTER(VCPU, instruction_stpx), - STATS_DESC_COUNTER(VCPU, instruction_stap), - STATS_DESC_COUNTER(VCPU, instruction_iske), - STATS_DESC_COUNTER(VCPU, instruction_ri), - STATS_DESC_COUNTER(VCPU, instruction_rrbe), - STATS_DESC_COUNTER(VCPU, instruction_sske), - STATS_DESC_COUNTER(VCPU, instruction_ipte_interlock), - STATS_DESC_COUNTER(VCPU, instruction_stsi), - STATS_DESC_COUNTER(VCPU, instruction_stfl), - STATS_DESC_COUNTER(VCPU, instruction_tb), - STATS_DESC_COUNTER(VCPU, instruction_tpi), - STATS_DESC_COUNTER(VCPU, instruction_tprot), - STATS_DESC_COUNTER(VCPU, instruction_tsch), - STATS_DESC_COUNTER(VCPU, instruction_sie), - STATS_DESC_COUNTER(VCPU, instruction_essa), - STATS_DESC_COUNTER(VCPU, instruction_sthyi), - STATS_DESC_COUNTER(VCPU, instruction_sigp_sense), - STATS_DESC_COUNTER(VCPU, instruction_sigp_sense_running), - STATS_DESC_COUNTER(VCPU, instruction_sigp_external_call), - STATS_DESC_COUNTER(VCPU, instruction_sigp_emergency), - STATS_DESC_COUNTER(VCPU, instruction_sigp_cond_emergency), - STATS_DESC_COUNTER(VCPU, instruction_sigp_start), - STATS_DESC_COUNTER(VCPU, instruction_sigp_stop), - STATS_DESC_COUNTER(VCPU, instruction_sigp_stop_store_status), - STATS_DESC_COUNTER(VCPU, instruction_sigp_store_status), - STATS_DESC_COUNTER(VCPU, instruction_sigp_store_adtl_status), - STATS_DESC_COUNTER(VCPU, instruction_sigp_arch), - STATS_DESC_COUNTER(VCPU, instruction_sigp_prefix), - STATS_DESC_COUNTER(VCPU, instruction_sigp_restart), - STATS_DESC_COUNTER(VCPU, instruction_sigp_init_cpu_reset), - STATS_DESC_COUNTER(VCPU, instruction_sigp_cpu_reset), - STATS_DESC_COUNTER(VCPU, instruction_sigp_unknown), - STATS_DESC_COUNTER(VCPU, instruction_diagnose_10), - STATS_DESC_COUNTER(VCPU, instruction_diagnose_44), - STATS_DESC_COUNTER(VCPU, instruction_diagnose_9c), - STATS_DESC_COUNTER(VCPU, diag_9c_ignored), - STATS_DESC_COUNTER(VCPU, diag_9c_forward), - STATS_DESC_COUNTER(VCPU, instruction_diagnose_258), - STATS_DESC_COUNTER(VCPU, instruction_diagnose_308), - STATS_DESC_COUNTER(VCPU, instruction_diagnose_500), - STATS_DESC_COUNTER(VCPU, instruction_diagnose_other), - STATS_DESC_COUNTER(VCPU, pfault_sync) + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_userspace), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_null), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_external_request), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_io_request), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_external_interrupt), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_stop_request), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_validity), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_instruction), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_pei), + KVM_STAT(VCPU, CUMULATIVE, NONE, halt_no_poll_steal), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_lctl), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_lctlg), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_stctl), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_stctg), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_program_interruption), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_instr_and_program), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_operation_exception), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_ckc), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_cputm), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_external_call), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_emergency_signal), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_service_signal), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_virtio), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_stop_signal), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_prefix_signal), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_restart_signal), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_program), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_io), + KVM_STAT(VCPU, CUMULATIVE, NONE, deliver_machine_check), + KVM_STAT(VCPU, CUMULATIVE, NONE, exit_wait_state), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_ckc), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_cputm), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_external_call), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_emergency_signal), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_mchk), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_pfault_init), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_program), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_restart), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_set_prefix), + KVM_STAT(VCPU, CUMULATIVE, NONE, inject_stop_signal), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_epsw), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_gs), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_io_other), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_lpsw), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_lpswe), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_pfmf), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_ptff), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sck), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sckpf), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_stidp), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_spx), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_stpx), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_stap), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_iske), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_ri), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_rrbe), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sske), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_ipte_interlock), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_stsi), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_stfl), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_tb), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_tpi), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_tprot), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_tsch), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sie), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_essa), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sthyi), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_sense), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_sense_running), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_external_call), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_emergency), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_cond_emergency), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_start), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_stop), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_stop_store_status), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_store_status), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_store_adtl_status), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_arch), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_prefix), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_restart), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_init_cpu_reset), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_cpu_reset), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_sigp_unknown), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_diagnose_10), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_diagnose_44), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_diagnose_9c), + KVM_STAT(VCPU, CUMULATIVE, NONE, diag_9c_ignored), + KVM_STAT(VCPU, CUMULATIVE, NONE, diag_9c_forward), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_diagnose_258), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_diagnose_308), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_diagnose_500), + KVM_STAT(VCPU, CUMULATIVE, NONE, instruction_diagnose_other), + KVM_STAT(VCPU, CUMULATIVE, NONE, pfault_sync) }; const struct kvm_stats_header kvm_vcpu_stats_header = { diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f706621c35b8..072f5ba83170 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -233,19 +233,19 @@ EXPORT_SYMBOL_GPL(host_xss); const struct _kvm_stats_desc kvm_vm_stats_desc[] = { KVM_GENERIC_VM_STATS(), - STATS_DESC_COUNTER(VM, mmu_shadow_zapped), - STATS_DESC_COUNTER(VM, mmu_pte_write), - STATS_DESC_COUNTER(VM, mmu_pde_zapped), - STATS_DESC_COUNTER(VM, mmu_flooded), - STATS_DESC_COUNTER(VM, mmu_recycled), - STATS_DESC_COUNTER(VM, mmu_cache_miss), - STATS_DESC_ICOUNTER(VM, mmu_unsync), - STATS_DESC_ICOUNTER(VM, pages_4k), - STATS_DESC_ICOUNTER(VM, pages_2m), - STATS_DESC_ICOUNTER(VM, pages_1g), - STATS_DESC_ICOUNTER(VM, nx_lpage_splits), - STATS_DESC_PCOUNTER(VM, max_mmu_rmap_size), - STATS_DESC_PCOUNTER(VM, max_mmu_page_hash_collisions) + KVM_STAT(VM, CUMULATIVE, NONE, mmu_shadow_zapped), + KVM_STAT(VM, CUMULATIVE, NONE, mmu_pte_write), + KVM_STAT(VM, CUMULATIVE, NONE, mmu_pde_zapped), + KVM_STAT(VM, CUMULATIVE, NONE, mmu_flooded), + KVM_STAT(VM, CUMULATIVE, NONE, mmu_recycled), + KVM_STAT(VM, CUMULATIVE, NONE, mmu_cache_miss), + KVM_STAT(VM, INSTANT, NONE, mmu_unsync), + KVM_STAT(VM, INSTANT, NONE, pages_4k), + KVM_STAT(VM, INSTANT, NONE, pages_2m), + KVM_STAT(VM, INSTANT, NONE, pages_1g), + KVM_STAT(VM, INSTANT, NONE, nx_lpage_splits), + KVM_STAT(VM, PEAK, NONE, max_mmu_rmap_size), + KVM_STAT(VM, PEAK, NONE, max_mmu_page_hash_collisions) }; const struct kvm_stats_header kvm_vm_stats_header = { @@ -259,40 +259,40 @@ const struct kvm_stats_header kvm_vm_stats_header = { const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = { KVM_GENERIC_VCPU_STATS(), - STATS_DESC_COUNTER(VCPU, pf_taken), - STATS_DESC_COUNTER(VCPU, pf_fixed), - STATS_DESC_COUNTER(VCPU, pf_emulate), - STATS_DESC_COUNTER(VCPU, pf_spurious), - STATS_DESC_COUNTER(VCPU, pf_fast), - STATS_DESC_COUNTER(VCPU, pf_mmio_spte_created), - STATS_DESC_COUNTER(VCPU, pf_guest), - STATS_DESC_COUNTER(VCPU, tlb_flush), - STATS_DESC_COUNTER(VCPU, invlpg), - STATS_DESC_COUNTER(VCPU, exits), - STATS_DESC_COUNTER(VCPU, io_exits), - STATS_DESC_COUNTER(VCPU, mmio_exits), - STATS_DESC_COUNTER(VCPU, signal_exits), - STATS_DESC_COUNTER(VCPU, irq_window_exits), - STATS_DESC_COUNTER(VCPU, nmi_window_exits), - STATS_DESC_COUNTER(VCPU, l1d_flush), - STATS_DESC_COUNTER(VCPU, halt_exits), - STATS_DESC_COUNTER(VCPU, request_irq_exits), - STATS_DESC_COUNTER(VCPU, irq_exits), - STATS_DESC_COUNTER(VCPU, host_state_reload), - STATS_DESC_COUNTER(VCPU, fpu_reload), - STATS_DESC_COUNTER(VCPU, insn_emulation), - STATS_DESC_COUNTER(VCPU, insn_emulation_fail), - STATS_DESC_COUNTER(VCPU, hypercalls), - STATS_DESC_COUNTER(VCPU, irq_injections), - STATS_DESC_COUNTER(VCPU, nmi_injections), - STATS_DESC_COUNTER(VCPU, req_event), - STATS_DESC_COUNTER(VCPU, nested_run), - STATS_DESC_COUNTER(VCPU, directed_yield_attempted), - STATS_DESC_COUNTER(VCPU, directed_yield_successful), - STATS_DESC_COUNTER(VCPU, preemption_reported), - STATS_DESC_COUNTER(VCPU, preemption_other), - STATS_DESC_IBOOLEAN(VCPU, guest_mode), - STATS_DESC_COUNTER(VCPU, notify_window_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, pf_taken), + KVM_STAT(VCPU, CUMULATIVE, NONE, pf_fixed), + KVM_STAT(VCPU, CUMULATIVE, NONE, pf_emulate), + KVM_STAT(VCPU, CUMULATIVE, NONE, pf_spurious), + KVM_STAT(VCPU, CUMULATIVE, NONE, pf_fast), + KVM_STAT(VCPU, CUMULATIVE, NONE, pf_mmio_spte_created), + KVM_STAT(VCPU, CUMULATIVE, NONE, pf_guest), + KVM_STAT(VCPU, CUMULATIVE, NONE, tlb_flush), + KVM_STAT(VCPU, CUMULATIVE, NONE, invlpg), + KVM_STAT(VCPU, CUMULATIVE, NONE, exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, io_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, mmio_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, signal_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, irq_window_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, nmi_window_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, l1d_flush), + KVM_STAT(VCPU, CUMULATIVE, NONE, halt_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, request_irq_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, irq_exits), + KVM_STAT(VCPU, CUMULATIVE, NONE, host_state_reload), + KVM_STAT(VCPU, CUMULATIVE, NONE, fpu_reload), + KVM_STAT(VCPU, CUMULATIVE, NONE, insn_emulation), + KVM_STAT(VCPU, CUMULATIVE, NONE, insn_emulation_fail), + KVM_STAT(VCPU, CUMULATIVE, NONE, hypercalls), + KVM_STAT(VCPU, CUMULATIVE, NONE, irq_injections), + KVM_STAT(VCPU, CUMULATIVE, NONE, nmi_injections), + KVM_STAT(VCPU, CUMULATIVE, NONE, req_event), + KVM_STAT(VCPU, CUMULATIVE, NONE, nested_run), + KVM_STAT(VCPU, CUMULATIVE, NONE, directed_yield_attempted), + KVM_STAT(VCPU, CUMULATIVE, NONE, directed_yield_successful), + KVM_STAT(VCPU, CUMULATIVE, NONE, preemption_reported), + KVM_STAT(VCPU, CUMULATIVE, NONE, preemption_other), + KVM_STAT(VCPU, INSTANT, BOOLEAN, guest_mode), + KVM_STAT(VCPU, CUMULATIVE, NONE, notify_window_exits), }; const struct kvm_stats_header kvm_vcpu_stats_header = { diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 8ada23756b0e..02b1151c2753 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1785,80 +1785,43 @@ struct _kvm_stats_desc { }, \ .name = #stat, \ } + /* SCOPE: VM, VM_GENERIC, VCPU, VCPU_GENERIC */ #define STATS_DESC(SCOPE, stat, type, unit, base, exp, sz, bsz) \ SCOPE##_STATS_DESC(stat, type, unit, base, exp, sz, bsz) -#define STATS_DESC_CUMULATIVE(SCOPE, name, unit, base, exponent) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_CUMULATIVE, \ - unit, base, exponent, 1, 0) -#define STATS_DESC_INSTANT(SCOPE, name, unit, base, exponent) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_INSTANT, \ - unit, base, exponent, 1, 0) -#define STATS_DESC_PEAK(SCOPE, name, unit, base, exponent) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_PEAK, \ - unit, base, exponent, 1, 0) -#define STATS_DESC_LINEAR_HIST(SCOPE, name, unit, base, exponent, sz, bsz) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_LINEAR_HIST, \ - unit, base, exponent, sz, bsz) -#define STATS_DESC_LOG_HIST(SCOPE, name, unit, base, exponent, sz) \ - STATS_DESC(SCOPE, name, KVM_STATS_TYPE_LOG_HIST, \ - unit, base, exponent, sz, 0) - -/* Cumulative counter, read/write */ -#define STATS_DESC_COUNTER(SCOPE, name) \ - STATS_DESC_CUMULATIVE(SCOPE, name, KVM_STATS_UNIT_NONE, \ - KVM_STATS_BASE_POW10, 0) -/* Instantaneous counter, read only */ -#define STATS_DESC_ICOUNTER(SCOPE, name) \ - STATS_DESC_INSTANT(SCOPE, name, KVM_STATS_UNIT_NONE, \ - KVM_STATS_BASE_POW10, 0) -/* Peak counter, read/write */ -#define STATS_DESC_PCOUNTER(SCOPE, name) \ - STATS_DESC_PEAK(SCOPE, name, KVM_STATS_UNIT_NONE, \ - KVM_STATS_BASE_POW10, 0) - -/* Instantaneous boolean value, read only */ -#define STATS_DESC_IBOOLEAN(SCOPE, name) \ - STATS_DESC_INSTANT(SCOPE, name, KVM_STATS_UNIT_BOOLEAN, \ - KVM_STATS_BASE_POW10, 0) -/* Peak (sticky) boolean value, read/write */ -#define STATS_DESC_PBOOLEAN(SCOPE, name) \ - STATS_DESC_PEAK(SCOPE, name, KVM_STATS_UNIT_BOOLEAN, \ - KVM_STATS_BASE_POW10, 0) - -/* Cumulative time in nanosecond */ -#define STATS_DESC_TIME_NSEC(SCOPE, name) \ - STATS_DESC_CUMULATIVE(SCOPE, name, KVM_STATS_UNIT_SECONDS, \ - KVM_STATS_BASE_POW10, -9) -/* Linear histogram for time in nanosecond */ -#define STATS_DESC_LINHIST_TIME_NSEC(SCOPE, name, sz, bsz) \ - STATS_DESC_LINEAR_HIST(SCOPE, name, KVM_STATS_UNIT_SECONDS, \ - KVM_STATS_BASE_POW10, -9, sz, bsz) -/* Logarithmic histogram for time in nanosecond */ -#define STATS_DESC_LOGHIST_TIME_NSEC(SCOPE, name, sz) \ - STATS_DESC_LOG_HIST(SCOPE, name, KVM_STATS_UNIT_SECONDS, \ - KVM_STATS_BASE_POW10, -9, sz) +#define KVM_STAT(SCOPE, TYPE, UNIT, _stat) \ + STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_##TYPE, \ + KVM_STATS_UNIT_##UNIT, KVM_STATS_BASE_POW10, 0, 1, 0) + +#define KVM_STAT_NSEC(SCOPE, _stat) \ + STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_CUMULATIVE, \ + KVM_STATS_UNIT_SECONDS, KVM_STATS_BASE_POW10, -9, 1, 0) + +#define KVM_HIST_NSEC(SCOPE, TYPE, _stat, _size, _bucket_size) \ + STATS_DESC(VCPU_GENERIC, _stat, KVM_STATS_TYPE_##TYPE##_HIST, \ + KVM_STATS_UNIT_SECONDS, KVM_STATS_BASE_POW10, -9, \ + _size, _bucket_size) #define KVM_GENERIC_VM_STATS() \ - STATS_DESC_COUNTER(VM_GENERIC, remote_tlb_flush), \ - STATS_DESC_COUNTER(VM_GENERIC, remote_tlb_flush_requests) + KVM_STAT(VM_GENERIC, CUMULATIVE, NONE, remote_tlb_flush), \ + KVM_STAT(VM_GENERIC, CUMULATIVE, NONE, remote_tlb_flush_requests) + +#define KVM_HALT_POLL_HIST(_stat) \ + KVM_HIST_NSEC(VCPU_GENERIC, LOG, _stat, HALT_POLL_HIST_COUNT, 0) #define KVM_GENERIC_VCPU_STATS() \ - STATS_DESC_COUNTER(VCPU_GENERIC, halt_successful_poll), \ - STATS_DESC_COUNTER(VCPU_GENERIC, halt_attempted_poll), \ - STATS_DESC_COUNTER(VCPU_GENERIC, halt_poll_invalid), \ - STATS_DESC_COUNTER(VCPU_GENERIC, halt_wakeup), \ - STATS_DESC_TIME_NSEC(VCPU_GENERIC, halt_poll_success_ns), \ - STATS_DESC_TIME_NSEC(VCPU_GENERIC, halt_poll_fail_ns), \ - STATS_DESC_TIME_NSEC(VCPU_GENERIC, halt_wait_ns), \ - STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_poll_success_hist, \ - HALT_POLL_HIST_COUNT), \ - STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_poll_fail_hist, \ - HALT_POLL_HIST_COUNT), \ - STATS_DESC_LOGHIST_TIME_NSEC(VCPU_GENERIC, halt_wait_hist, \ - HALT_POLL_HIST_COUNT), \ - STATS_DESC_IBOOLEAN(VCPU_GENERIC, blocking) + KVM_STAT(VCPU_GENERIC, CUMULATIVE, NONE, halt_successful_poll), \ + KVM_STAT(VCPU_GENERIC, CUMULATIVE, NONE, halt_attempted_poll), \ + KVM_STAT(VCPU_GENERIC, CUMULATIVE, NONE, halt_poll_invalid), \ + KVM_STAT(VCPU_GENERIC, CUMULATIVE, NONE, halt_wakeup), \ + KVM_STAT_NSEC(VCPU_GENERIC, halt_poll_success_ns), \ + KVM_STAT_NSEC(VCPU_GENERIC, halt_poll_fail_ns), \ + KVM_STAT_NSEC(VCPU_GENERIC, halt_wait_ns), \ + KVM_HALT_POLL_HIST(halt_poll_success_hist), \ + KVM_HALT_POLL_HIST(halt_poll_fail_hist), \ + KVM_HALT_POLL_HIST(halt_wait_hist), \ + KVM_STAT(VCPU_GENERIC, INSTANT, BOOLEAN, blocking) extern struct dentry *kvm_debugfs_dir; From patchwork Mon Mar 6 19:01:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13162215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F524C64EC4 for ; Mon, 6 Mar 2023 19:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=xkKvf3j5B/bWTnVO5WFUoVpfSwwc7WXETq4+zgvU4Z4=; b=ehk87AMutixSBBN3ADpvYV9fGB H0F4qdbsfWTNeZfEXH2Ddqz3ORl+SYcpmGQPFE4lHRznolT8Y+i4SJUBYB98TIJSixmg9jomJkOlc vddWce5Ul9JlivxjWOrc8Y6xhjTiOuBb/rexvvZtXBcE9yw2YdVNvMZ9+qpdTGjbbl1DYVfwJwl0G oCzknUktXsDmqE8OjJ0pwmAJWZmVyZxs/jHioImblftNJwVznztR3pQD3mtNOXqr3grY0ylRAg571 dlyTAK8RmnL4z1JjOmwEyAnSPi2AB9Su6f8J5usLkIwSMzc1Z5mrdIJ3CCQ0BQxntugBX5np7HcT1 ih9XWvVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG6K-00ERdp-2X; Mon, 06 Mar 2023 19:02:24 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG60-00ERUh-D7 for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2023 19:02:08 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id o3-20020a257303000000b00a131264017aso11591723ybc.20 for ; Mon, 06 Mar 2023 11:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678129323; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=YtNaR+Rua5pfZ3i1GgJ4+hfSm+WXWk7IiLK4Wtb8+uM=; b=A42BX/LP2I7Yrldf83rjJjVVWP9EY7MIToR2w3fKfHNuwlJilnDlJG9Ga110/MBKfg bANY0GGZpHkSiBa5gtT3zYMm3kqQ6eoCd9XQbU1Nw97OaGmCCVTg5gCJq6SSBEjZs5D2 WXuRcS2VBsFJxrimrp+JQlNpq+OFmS1Ohh71sBzmcc1MXrTW549F5OJ3aZCaRVfQfJrL Xl5df+WIcc/z0GU55ilZ3Am2ARcrEJpAjke5BrZTBJ9d+m4fByyPMgXYOtOtNovF1gQu M0K+F9OgIzJN5j3FpXghI6sTRl0hwMpb0KkZDbWtWBZRE7ORKqG1rS1sA7NOJROAsX6B zrWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678129323; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YtNaR+Rua5pfZ3i1GgJ4+hfSm+WXWk7IiLK4Wtb8+uM=; b=3yTsHa3UEYf0PKHgyRnWI/FgPI77z2u+wyC/Lf7UFr2FqmEoWs4LAwLywolhBj+oqE ZZBWYIi/ayNIZ0J3BiEVbwOVLeNvVswHTIh3jm4D1IIrqwyQyi7ilQ/pqfN4QuFL8/fZ Yl1z57rQh20LJFM3eef3WR3vcgljWfKI/b/0pcT5RstSlIQACCGq4GWqNzfKZSx0nWGQ YwXPCU9YWpyaPEG4Sl6FYV4L42s0Op0DZvqFE7krLOb9+MQJ6Yt+fqh4HZN8XpmfFFWf 12I52oo7+gtSgM+OAof7GlsJ5+1hudxHGuIaPqebHwwVcGhZZDOGt2x85JB3l02oWK7O ORww== X-Gm-Message-State: AO0yUKVgPgeqzLPryirlnlh4U2FHntN9oU8Ia+hY8dnbI+rqjd5FpmWo qZhRcnuh0AcKmw8PupJsxEZTGQVqw2A6zw== X-Google-Smtp-Source: AK7set90Igml/rc2W0Ya1hk1eHjjJqlvHrIGVSaZmJTzp6vbZseA2XP1DWQDVsfl/YAYC2c0ne8CFj1tJ7LMiQ== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a81:ad0d:0:b0:52e:b635:5496 with SMTP id l13-20020a81ad0d000000b0052eb6355496mr7126400ywh.2.1678129323101; Mon, 06 Mar 2023 11:02:03 -0800 (PST) Date: Mon, 6 Mar 2023 11:01:54 -0800 In-Reply-To: <20230306190156.434452-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230306190156.434452-1-dmatlack@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306190156.434452-3-dmatlack@google.com> Subject: [PATCH v2 2/4] KVM: Refactor designated initializer macros for struct _kvm_stats_desc From: David Matlack To: Paolo Bonzini Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Sean Christopherson , Michael Ellerman , Eric Farman , " =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= " , David Matlack , Sathvika Vasireddy , Nicholas Piggin , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230306_110204_584775_54F780B3 X-CRM114-Status: GOOD ( 11.50 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Refactor the macros that generate struct _kvm_stats_desc designated initializers to cut down on duplication. No functional change intended. Signed-off-by: David Matlack --- include/linux/kvm_host.h | 75 +++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 40 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 02b1151c2753..6673ae757c4e 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1744,47 +1744,42 @@ struct _kvm_stats_desc { char name[KVM_STATS_NAME_SIZE]; }; -#define STATS_DESC_COMMON(type, unit, base, exp, sz, bsz) \ - .flags = type | unit | base | \ - BUILD_BUG_ON_ZERO(type & ~KVM_STATS_TYPE_MASK) | \ - BUILD_BUG_ON_ZERO(unit & ~KVM_STATS_UNIT_MASK) | \ - BUILD_BUG_ON_ZERO(base & ~KVM_STATS_BASE_MASK), \ - .exponent = exp, \ - .size = sz, \ - .bucket_size = bsz - -#define VM_GENERIC_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ +/* Generates a designated initializer list for a struct _kvm_stats_desc. */ +#define _KVM_STATS_DESC(_struct, _field, _name, _type, _unit, _base, \ + _exponent, _size, _bucket_size) \ +{ \ { \ - { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vm_stat, generic.stat) \ - }, \ - .name = #stat, \ - } -#define VCPU_GENERIC_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ - { \ - { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vcpu_stat, generic.stat) \ - }, \ - .name = #stat, \ - } -#define VM_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ - { \ - { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vm_stat, stat) \ - }, \ - .name = #stat, \ - } -#define VCPU_STATS_DESC(stat, type, unit, base, exp, sz, bsz) \ - { \ - { \ - STATS_DESC_COMMON(type, unit, base, exp, sz, bsz), \ - .offset = offsetof(struct kvm_vcpu_stat, stat) \ - }, \ - .name = #stat, \ - } + .flags = _type | _unit | _base | \ + BUILD_BUG_ON_ZERO(_type & ~KVM_STATS_TYPE_MASK) | \ + BUILD_BUG_ON_ZERO(_unit & ~KVM_STATS_UNIT_MASK) | \ + BUILD_BUG_ON_ZERO(_base & ~KVM_STATS_BASE_MASK), \ + .exponent = _exponent, \ + .size = _size, \ + .bucket_size = _bucket_size, \ + .offset = offsetof(_struct, _field), \ + }, \ + .name = _name, \ +} + +#define VM_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vm_stat, generic._stat, #_stat, _type, \ + _unit, _base, _exponent, _size, _bucket_size) + +#define VCPU_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vcpu_stat, generic._stat, #_stat, _type, \ + _unit, _base, _exponent, _size, _bucket_size) + +#define VM_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vm_stat, _stat, #_stat, _type, _unit, \ + _base, _exponent, _size, _bucket_size) + +#define VCPU_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ + _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vcpu_stat, _stat, #_stat, _type, _unit, \ + _base, _exponent, _size, _bucket_size) /* SCOPE: VM, VM_GENERIC, VCPU, VCPU_GENERIC */ #define STATS_DESC(SCOPE, stat, type, unit, base, exp, sz, bsz) \ From patchwork Mon Mar 6 19:01:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13162216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7C42C61DA4 for ; Mon, 6 Mar 2023 19:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=usTjmY8dy+Zkehyc2I7+7Xuijo9ZO1s7VeTAKculIpc=; b=2ZIc1SdN6b/Z3NSgz8gzKNupNP t+Ok9ej/U+YeB/Vl0XYOfVqiPoU5QKT6vc6cMwgwW4JZyYX2vjTQoZi/QeKyzO+jJnNks5+uz7dkv QcRih45ECosDsnLQTzUSoeu4Q8Zo9FegZKreosvhoqHVj3bHVRtszDrmNKuJLDkb2GGXwAI3dGUW+ F4CW2GJ/8NzuUw03+EmnzFVYtC7tfoS+L3XMNtjF4PpuTe2y5J4A/WCJV3tETe2Nvwaaj2/TGn5T+ ghk84ms7Wy9Zt0AWKOcsPDveJhd+o/WWgjtcj7HLXRhz2Z2ASGoxA2ak90egzm7REOgCz7QhvPb// 12VEdWNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG6V-00ERkY-TF; Mon, 06 Mar 2023 19:02:36 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG61-00ERWU-RD for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2023 19:02:10 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id w5-20020a253005000000b00aedd4305ff2so10903414ybw.13 for ; Mon, 06 Mar 2023 11:02:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678129324; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=XCoFR/ZEz+o/3af75F9xOrPS2psj7bAuPaV+hSWOgQo=; b=UtpACFkTBCbOuRJEDO4GIV5VZyNtvBXfzND3oU3x+MTJtqKf4RC+aJ4iEUgKvk/Gbv QwvfJnU9JToxEfS+WRcwSwlVT4IlfuPHxbDlaSiueIsWANa2Ta9bs7g2Xb/SoaztXvbW AcZzwTzgMy8MObXk877NToyNHzCNVG6tPs8bD3L2lDLtP1vJbpQNVe/QUw4MOneGcben A12+mWFZoMCKAD0Z64Pf8fB/rO0lgxgHvfoLNCDEimxkEwLixX3fA9CtbPgaW1lHLH/k mZfeAEacPOyAvkjV/89Ze4YmYA+t2BabNvI12wvTJZnOvTvidyImSKerp51EgZ1O07yo W1MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678129324; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XCoFR/ZEz+o/3af75F9xOrPS2psj7bAuPaV+hSWOgQo=; b=swh+msB9CI+vvHu0rWhxm0Zfw7Qp6FOSwMy4HNo5ssRC/AKnos3yHlZbaLsqOrMqIo cij3L1UyVWzcku+PpO1h3pWjy05Yj4eeCwBm1nQU5P0NUHvwnOhaxDWTs4OqIOArXxgM QoTwovYxrKsGxZQZojXV+MxLTtvIA7Rzy457FEKqeWiXpj+rJg2VtokdqbSIK+E0iv1j Sj/bTQqUCa2Nk0x9sE32yQcDPy5AslWvk3nhuKWpX60z5pSnxibkScz4/oLMFBVTp1CY wsGzF1xKRqnp1s2RCQJawMeVd1fr2vdV4I1brxF3lX1ePa7itzRgavtiLT+SobN8ATTL ltCg== X-Gm-Message-State: AO0yUKWRLYmtwPukdj1D1aDX+yCOkSuB+VcIVdqEdOXhGr1Dm9uSao00 IuWQoO0aE7FTuSMl6M4GTdN9R1PVaZdvgQ== X-Google-Smtp-Source: AK7set//cZ5G8Yg9tzyC35+cBUfG5YD+QOMFZSqm+c6ivqgffhDJvoZQbaLGDxeXrS7rdZX3Y2pHJ1bn0bJjqg== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a81:ac4b:0:b0:533:9ffb:cb12 with SMTP id z11-20020a81ac4b000000b005339ffbcb12mr7643877ywj.10.1678129324575; Mon, 06 Mar 2023 11:02:04 -0800 (PST) Date: Mon, 6 Mar 2023 11:01:55 -0800 In-Reply-To: <20230306190156.434452-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230306190156.434452-1-dmatlack@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306190156.434452-4-dmatlack@google.com> Subject: [PATCH v2 3/4] KVM: Allow custom names for KVM_STAT() From: David Matlack To: Paolo Bonzini Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Sean Christopherson , Michael Ellerman , Eric Farman , " =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= " , David Matlack , Sathvika Vasireddy , Nicholas Piggin , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, Jing Zhang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230306_110205_947577_814E79ED X-CRM114-Status: GOOD ( 11.62 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow custom names to be specified for stats built on KVM_STAT() via a new inner macro __KVM_STAT(). e.g. KVM_STAT(VM, CUMULATIVE, NONE, foo), __KVM_STAT(VM, CUMULATIVE, NONE, bar, "custom_name"), ... Custom name support enables decoupling the userspace-visible stat names from their internal representation in C. This can allow future commits to refactor the various stats structs without impacting userspace tools that read KVM stats. This also allows stats to be stored in data structures such as arrays, without needing unions to access specific stats. For example, the union for pages_{4k,2m,1g} is no longer necessary. At Google, we have several other out-of-tree stats that would benefit from this support. No functional change intended. Link: https://lore.kernel.org/all/20211019000459.3163029-1-jingzhangos@google.com/ Suggested-by: Jing Zhang Signed-off-by: David Matlack --- include/linux/kvm_host.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 6673ae757c4e..fa026e8997b2 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1761,40 +1761,43 @@ struct _kvm_stats_desc { .name = _name, \ } -#define VM_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ - _bucket_size) \ - _KVM_STATS_DESC(struct kvm_vm_stat, generic._stat, #_stat, _type, \ +#define VM_GENERIC_STATS_DESC(_stat, _name, _type, _unit, _base, _exponent, \ + _size, _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vm_stat, generic._stat, _name, _type, \ _unit, _base, _exponent, _size, _bucket_size) -#define VCPU_GENERIC_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ - _bucket_size) \ - _KVM_STATS_DESC(struct kvm_vcpu_stat, generic._stat, #_stat, _type, \ +#define VCPU_GENERIC_STATS_DESC(_stat, _name, _type, _unit, _base, _exponent, \ + _size, _bucket_size) \ + _KVM_STATS_DESC(struct kvm_vcpu_stat, generic._stat, _name, _type, \ _unit, _base, _exponent, _size, _bucket_size) -#define VM_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ +#define VM_STATS_DESC(_stat, _name, _type, _unit, _base, _exponent, _size, \ _bucket_size) \ - _KVM_STATS_DESC(struct kvm_vm_stat, _stat, #_stat, _type, _unit, \ + _KVM_STATS_DESC(struct kvm_vm_stat, _stat, _name, _type, _unit, \ _base, _exponent, _size, _bucket_size) -#define VCPU_STATS_DESC(_stat, _type, _unit, _base, _exponent, _size, \ +#define VCPU_STATS_DESC(_stat, _name, _type, _unit, _base, _exponent, _size, \ _bucket_size) \ - _KVM_STATS_DESC(struct kvm_vcpu_stat, _stat, #_stat, _type, _unit, \ + _KVM_STATS_DESC(struct kvm_vcpu_stat, _stat, _name, _type, _unit, \ _base, _exponent, _size, _bucket_size) /* SCOPE: VM, VM_GENERIC, VCPU, VCPU_GENERIC */ -#define STATS_DESC(SCOPE, stat, type, unit, base, exp, sz, bsz) \ - SCOPE##_STATS_DESC(stat, type, unit, base, exp, sz, bsz) +#define STATS_DESC(SCOPE, stat, name, type, unit, base, exp, sz, bsz) \ + SCOPE##_STATS_DESC(stat, name, type, unit, base, exp, sz, bsz) -#define KVM_STAT(SCOPE, TYPE, UNIT, _stat) \ - STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_##TYPE, \ +#define __KVM_STAT(SCOPE, TYPE, UNIT, _stat, _name) \ + STATS_DESC(SCOPE, _stat, _name, KVM_STATS_TYPE_##TYPE, \ KVM_STATS_UNIT_##UNIT, KVM_STATS_BASE_POW10, 0, 1, 0) +#define KVM_STAT(SCOPE, TYPE, UNIT, _stat) \ + __KVM_STAT(SCOPE, TYPE, UNIT, _stat, #_stat) + #define KVM_STAT_NSEC(SCOPE, _stat) \ - STATS_DESC(SCOPE, _stat, KVM_STATS_TYPE_CUMULATIVE, \ + STATS_DESC(SCOPE, _stat, #_stat, KVM_STATS_TYPE_CUMULATIVE, \ KVM_STATS_UNIT_SECONDS, KVM_STATS_BASE_POW10, -9, 1, 0) #define KVM_HIST_NSEC(SCOPE, TYPE, _stat, _size, _bucket_size) \ - STATS_DESC(VCPU_GENERIC, _stat, KVM_STATS_TYPE_##TYPE##_HIST, \ + STATS_DESC(VCPU_GENERIC, _stat, #_stat, KVM_STATS_TYPE_##TYPE##_HIST, \ KVM_STATS_UNIT_SECONDS, KVM_STATS_BASE_POW10, -9, \ _size, _bucket_size) From patchwork Mon Mar 6 19:01:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 13162218 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7268C61DA4 for ; Mon, 6 Mar 2023 19:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6NCqNHYq/h8HEP5MJcgiRVyovjdWZgXwKkAUEjRmbNA=; b=C5jbBz6lU5KK+04LhDjuVeXKiZ qzRS5PUp6bAMsD9LSJvk2lmxYKqS0/sldvTfNdfzKrM4O//rrlYYmFvi00ykhllzMZavh+nmMkMyn +VBC5nL9N+duZHspomUT5jWgn4f9piDZcOqyatd3aZOz6CiK+OD2nWHHo3fh0iHa4/AdWZlZ+IWk3 9JkjrY8oQ5p2EdFR6tgiozInJ1+X9luhBieZT5/C6E2KoRXNWhKdaYvB1iUcMcMcro71kZwn+uqIK XT8YOtS+t+YsD+GVXstOx4laQeX1jasJwVxCZZ8CwxXNW5kHkdxjJQTeSORo2GwBv1TmbEIy9X6ik 4aLtL4kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG76-00ES66-81; Mon, 06 Mar 2023 19:03:12 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG6C-00ERbK-0P for linux-arm-kernel@bombadil.infradead.org; Mon, 06 Mar 2023 19:02:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: Message-ID:References:Mime-Version:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Hy1Buh0DyhAQ1dsWc1I6Y0GrKiZLM4ytS70wq/2qiU0=; b=hK58AzGQBxAbfsw6G4kanEQDA1 0sqztLvxyUScj8jQ9sYAv1vP3QZZ8sPyivpu7o0IkZ2O6e5B185w35QNtZ9S9SwV6BtRWZiAEyal/ MkCRfCgnLYGfOw9m7Qbma3vba0pUSaI+iEnYCp4ZmBJARTPLlVCiBLEUHYWBgjRhaO56NNmf0BHk7 +grTpCKEu8pADEh2zO5QLOPvRfDQmSLxYvWYp+HuMkfuUNo1N+de0kaKwCXmSQhrQ3sxQV9ov/rVa o6r4kIwMVQSr9WRLZh2lQUf41ZQ7BBjRdguElI3qR/B35gDFDPSEzXHFLmzrr0r87wNlo7ZZb4QPP 3zNEDgcg==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pZG66-00Glqv-1y for linux-arm-kernel@lists.infradead.org; Mon, 06 Mar 2023 19:02:14 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-536cb268ab8so112433727b3.17 for ; Mon, 06 Mar 2023 11:02:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678129326; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Hy1Buh0DyhAQ1dsWc1I6Y0GrKiZLM4ytS70wq/2qiU0=; b=Letr5LRp7bS0YmkVINmE83RF8//+0ihwPomgSJZC4+dkD9sFUFEL35AQoxcfPpIbXW Y1mVJA34aQ9Fn9+jBPkAovdeUPbAGsum3MVzw575zB3u4rfwK4ZVePdw3VSiVo2j9C9v 3XnoKl7fEhlmtkQ5DdG9/UhFj+tyVjNmSih/iYAuSQ6xwOtYmbjOYgHRAkzFRXa92dze ZQvrRjBbIKvFglVzBDH4EAw30eROHuzuIjsYKsJXNnWsAQHIog+eYwButoAe0B9OxSD2 pOTz7b2aOyFjFOUOaTEw5+7DJRfnksutj0fbq9nxtjgFb7SGFFpwHZTOmxj6KpssL5px NozA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678129326; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hy1Buh0DyhAQ1dsWc1I6Y0GrKiZLM4ytS70wq/2qiU0=; b=REQ0H8mLiP1tEVJJAJ0iEq1uQexTLdiPe8f8QSfYUVf2BVpgGV7EX66EfuTPWH9qpH WUu0JsuT6IOLxWhw4Cne7+/NKfSmZEH6xVxMfGQcVqfcb4d+BpS8dKkvg7MiHwfvr66G s9xojrkMG83kQ1YyV8Mcy3SzbQtR04UypUqUobHfqtRdDkBvpqjlYDeftzYYUJS3DOEQ LAi4VdqX1ynk4exvMyX5CKdiaME3cwVlu4L6+jSJc+eshEsvcQpMVYvJTuCL0V/grRA4 JAzbCTRmfDvLh15Lg8jMdaZArMdC/4ayG/9O6T+jRs1vwqhJG1t/BPLc1TYT1iB07MyC yjuw== X-Gm-Message-State: AO0yUKWs8X5qri4GOZFjUJ7UqSjT0taFhOLb/NO8SAGttRrlHo4mcDGr J6+DLw0E1M2CL7B050DFad4f/uhFzQBVtw== X-Google-Smtp-Source: AK7set9e2oV5ajrE5TnGPzkyECRcuaio2KGOJRsM0L6WhO9k90cawVld9W/AAFXa4Ih5X3b9O+P88E69HqyVhg== X-Received: from dmatlack-n2d-128.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:1309]) (user=dmatlack job=sendgmr) by 2002:a81:b667:0:b0:534:d71f:14e6 with SMTP id h39-20020a81b667000000b00534d71f14e6mr7365447ywk.9.1678129326079; Mon, 06 Mar 2023 11:02:06 -0800 (PST) Date: Mon, 6 Mar 2023 11:01:56 -0800 In-Reply-To: <20230306190156.434452-1-dmatlack@google.com> Mime-Version: 1.0 References: <20230306190156.434452-1-dmatlack@google.com> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog Message-ID: <20230306190156.434452-5-dmatlack@google.com> Subject: [PATCH v2 4/4] KVM: x86: Drop union for pages_{4k,2m,1g} stats From: David Matlack To: Paolo Bonzini Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Huacai Chen , Aleksandar Markovic , Anup Patel , Atish Patra , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Sean Christopherson , Michael Ellerman , Eric Farman , " =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= " , David Matlack , Sathvika Vasireddy , Nicholas Piggin , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230306_190210_782232_5FC52922 X-CRM114-Status: GOOD ( 12.51 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Drop the union for the pages_{4k,2m,1g} stats. The union is no longer necessary now that KVM supports choosing a custom name for stats. Eliminating the union also would allow future commits to more easily move pages[] into common code, e.g. if KVM ever gains support for a common page table code. An alternative would be to drop pages[] and have kvm_update_page_stats() update pages_{4k,2m,1g} directly. But that's not a good direction to go in since other architectures use other page sizes. No functional change intended. Link: https://lore.kernel.org/kvm/20221208193857.4090582-1-dmatlack@google.com/ Signed-off-by: David Matlack --- arch/x86/include/asm/kvm_host.h | 9 +-------- arch/x86/kvm/x86.c | 6 +++--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 808c292ad3f4..a59e41355ef4 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1473,14 +1473,7 @@ struct kvm_vm_stat { u64 mmu_recycled; u64 mmu_cache_miss; u64 mmu_unsync; - union { - struct { - atomic64_t pages_4k; - atomic64_t pages_2m; - atomic64_t pages_1g; - }; - atomic64_t pages[KVM_NR_PAGE_SIZES]; - }; + atomic64_t pages[KVM_NR_PAGE_SIZES]; u64 nx_lpage_splits; u64 max_mmu_page_hash_collisions; u64 max_mmu_rmap_size; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 072f5ba83170..101ad6b7e7b6 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -240,9 +240,9 @@ const struct _kvm_stats_desc kvm_vm_stats_desc[] = { KVM_STAT(VM, CUMULATIVE, NONE, mmu_recycled), KVM_STAT(VM, CUMULATIVE, NONE, mmu_cache_miss), KVM_STAT(VM, INSTANT, NONE, mmu_unsync), - KVM_STAT(VM, INSTANT, NONE, pages_4k), - KVM_STAT(VM, INSTANT, NONE, pages_2m), - KVM_STAT(VM, INSTANT, NONE, pages_1g), + __KVM_STAT(VM, INSTANT, NONE, pages[PG_LEVEL_4K - 1], "pages_4k"), + __KVM_STAT(VM, INSTANT, NONE, pages[PG_LEVEL_2M - 1], "pages_2m"), + __KVM_STAT(VM, INSTANT, NONE, pages[PG_LEVEL_1G - 1], "pages_1g"), KVM_STAT(VM, INSTANT, NONE, nx_lpage_splits), KVM_STAT(VM, PEAK, NONE, max_mmu_rmap_size), KVM_STAT(VM, PEAK, NONE, max_mmu_page_hash_collisions)