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: 13162211 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 27297C64EC4 for ; Mon, 6 Mar 2023 19:02:43 +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=KitzW4d+c8lT0W/lM1r5mVH0QWTkdQoOhMv2JzBFqxg=; b=1JbWv1DWtaASRmdnEDDX9TahXg BAqRKA4N9o2CTAZCTbn0sKrxxm2UCWVu96V/oH47mCmEVpI43UNgTuke8GjomPDrWTMpcH3Lj+SUS Z/qaRO0tLGrsn9wFAY9dgV+eeCeyqkg3c64KbssdFbtCfiWfN5GeVLTMsiB1IV5JSmbkaZwo95DxR A/T+OyKeSUTn4E2uu9awTDVCZ9cGY5Zf1GPsO/M2zM4vyJy33+yWl+5eKYL89Y46WtUNGdGeSg5YM YnZuSvA29AhfLQEbTvm3vfekWap4r8IdcNd5H/NV7t+72UTfIiSWp2GfUKYxiCosEdF9S0zN+enXV DBwTx5lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG6T-00ERjb-O4; Mon, 06 Mar 2023 19:02:33 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG60-00ERUE-4N for linux-riscv@lists.infradead.org; Mon, 06 Mar 2023 19:02:10 +0000 Received: by mail-pj1-x104a.google.com with SMTP id pb4-20020a17090b3c0400b00237873bd59bso2877842pjb.2 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=L/iq8n3l+LQbYngNywL1YxSp/F7+53g+kPmXuDeFDzLyfMKcScqay4IBmQwSNDpUgC QRBZe5rPGv3OWPk4vbH8WzXmXpdNRCIDEHifVJ7KiTIGRYNo2SxNviAqGJEF4MuhSigU mfsSFFATMPyDAtyvI5ppu0egLdW8V0XoP+UWOjlpvjpMbCeqqEWeRKCI5/N/zTxyNAr0 dZeozchIEyMLovB4r+98IXIxA5IEgsNA90jpWzl2b9Jl1DX9oEH4/C2KLlt4nM8WhdBE ygDSFS074ANhfLBRHydpVxSyzllWEA7IsHVqH6TJkZbkrjoDJ8S2G+B8LPtz755OSxcx 0nMg== X-Gm-Message-State: AO0yUKXynsdfBf7rxkFvFNW+RYyCQ+wriQF2pNt3LUBAgN34s0HXyU8U EmonqGnzDhccf1uDST4oMAbzhwmR/EguQA== 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_379210_9C251A97 X-CRM114-Status: UNSURE ( 9.62 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13162210 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 6B526C6FD1F for ; Mon, 6 Mar 2023 19:02:30 +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=zhfR7VFheNHlVnQbdPiUO56ViYjr2N22bbj6ucP/Cgg=; b=Qyx3gd4h72448VXpKyT7s0FYg4 0q23hn/JJ3SaTfPrEXxD0/w9OSf7+WjspqDDYgARc/ue7PHu6EELlwdXUSziE2H/enrb0c32CDEKz s4j4WNfBviwTRSWt0AJaNg5XgM+FMsSHxVwDGKDDRrqLrLKQOZ3B4ecmWQbmlj1VWqdLWw3Gz05Pc IvRZ3b9xumDIO2K0OFFLk7lRM6phNNisBP5soU8wyKX1SSi5hofgOK51n1ENorTdMaJbEN5xJUP4i 5udjwsJlgcg1G9hW+iAAcDiVx7IUJN8jfj84bT+HXXMoOl245GY9ZotJNxvfGOI+AQQTFH3SB5YnZ vLJ4O5PQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG6G-00ERcm-Nk; Mon, 06 Mar 2023 19:02:20 +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-00ERTd-6S for linux-riscv@lists.infradead.org; Mon, 06 Mar 2023 19:02:07 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id a137-20020a25ca8f000000b0091b90b20cd9so11468973ybg.6 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=LSbk2XekrNNktLIgZnp1ycUuYsinQy0Em1Xwy7usKa4S9djMngHR4GLf1m+NV5klcW sPS+yV9N0TkLfxtrVgk8Sm1QH6Pt5GlJ3PU/h68OeOszWEHLu+GLb3AyZ9JmYfEOxfru kw40kp58WK8bspgBMXucyXXtwI1XNmUTygmuU2a/8s/kLTSSvfU03uqRFhX9BBQU6Y4q 1tqarb/OLZ1L9B31RnqrRJW1B8886f9lLNUkxcw1Dv1ZluABRF2gJ3hpA33hwi+l7R9c 4vu3/OWyarlTrpXtgizCp8q6rDf+PPjVRLYQD/uBlatLNM0a5GmThApH6jOEdW7l1uyf NrDw== X-Gm-Message-State: AO0yUKWuhSB/Vpsy34FG7GUku2sWCJlvhUaQ/M/EK82+44Z55TFPs7/W +CwLWDIsiARyBfP1SyhftgH8DvUO0iZ/gg== 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_375178_B8FF266C X-CRM114-Status: UNSURE ( 9.98 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13162212 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 B55A5C61DA4 for ; Mon, 6 Mar 2023 19:03:10 +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=bFbgrtyNfYlwTCl4XLyTGIbsKN/69OPZWMBiQEgwkJE=; b=mzKaH/Z6pI/gOd3/c1dmzPOo/G zsx+PMr3zj95PLdcV96MRKs4iRwka6d5DXobhLeQH10YzTY8AyddD4Bop390iCeElU2nKkiWRihVd o5gZi6awSlCtx09tmasgARhLrNpqrZ3kfF1CKeY3nQ5O06ULetRMVil5equGgVLp6/zxWq3u+eZy4 RkhjvnMDQ9692DZgZk5Pqn2NqK4HcOJSj/ACkCiStn8LObxMmDFBzZyzlUy1CSTsCx75OQts6oCXI rgElYE3DOp1zMVedn04z6fi3Sw47DqMfZ7USdhFFzqOFO7pYdYp1K9zYToEgUcPSSxJYeIMV3quPL o1BdncPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG6x-00ERzG-3R; Mon, 06 Mar 2023 19:03:03 +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-00ERWX-S0 for linux-riscv@lists.infradead.org; Mon, 06 Mar 2023 19:02:10 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 204-20020a2514d5000000b00a3637aea9e1so11588331ybu.17 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=rBestrZBvY9f/5bPvuSoLwOk6T9atdgFTrezFDFvs4uINo/31zyFD9IDqC1w4AvgTJ ga1+KhMWd0JGIuCKMKUyGMO9c/SKZOCbqa3nKZ60CGAfCU2pl4T5VuTqlHCug4lSf0XZ OEU+FkrDnxXf7f5H/FDVrNqxbmiknFwuz460hUlJWmLCY1Q01/f1esNfvOKjwsa6pmcg OVAb+yowWby9LEdlWTlF/sEZusCPGFwTZpGwlcXWeLczAlKmz8EMH5LgrNE+nwILA4f2 y048AYSdEkjBH6IH8syTxfIpmCyF5zNMcXgNFkXny37TlJHjuwcgMTfSGEnjsAmFSVxH ZYJg== X-Gm-Message-State: AO0yUKXEvLd3eNmQ2LhUGDN+4v6NwoAaYDB7xDG0Hl2KSaRgzdcUJrlD sLlDlxotj4TgQF7ONsoeiPZ8T6JbJlOxJg== 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_955264_37F40340 X-CRM114-Status: GOOD ( 10.10 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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: 13162213 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 BEE09C61DA4 for ; Mon, 6 Mar 2023 19:03:14 +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=5OKlMCeMRc5Mf5AqRc5CWoTVJYio4lRHBiK0BH31u4Y=; b=HNbrER4DZuWzw6tyB+XlFPJckA enkzbl8H3cbMSRD2dOqkq8DgQx8MXGFZdz0j5PeLK3upKiF98FyUGDdMhwO3jaZsWujclQ8RSgSfC GKg4i/9Hi9QM5JDLCt8cFzk6a0W2uTfwDJerab1Jm2eYySrkR1FbsdezlRHvCx9CSjipukrXFdrWr 5oxJXDHfYiIzRuPuOp/ZPmFanESIm2bGnioxz4iJ5ePFP1WWfeZU/r/KkgKeUnC2PYKGidJyfW3BR CYlGMU13u0yqdqO5kn29tf1Lw2umesJ5YaFWJHNN3sNlgM9uPeviYy2ilGZNdPlhqxeOpE3SkLKlQ Zqo6PwFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZG70-00ES2Q-OI; Mon, 06 Mar 2023 19:03:06 +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 1pZG6A-00ERad-6g for linux-riscv@bombadil.infradead.org; Mon, 06 Mar 2023 19:02:14 +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-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pZG66-00Glqt-2H for linux-riscv@lists.infradead.org; Mon, 06 Mar 2023 19:02:12 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id w192-20020a25dfc9000000b009fe14931caaso11492165ybg.7 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=8GEGB3xX1kH/aN0cBaUMQDP3Z8gpvs/UEf9VurrZV4ACfC/sVtewob9OSLXc3xARoK zkt9tVA6GFALSNam0FlRtSryUTzsgSO/6jNv2nLLlR8Xy4A6U1IscTjvKjB9KwWkR+JR lRn9SyD21ZhLEFMzAp1pXVjDch2w3BgJ9tGLGvibOi3XDA9BB5oDdjUKlek04xR3tnNJ fNyEmrNwAJdE2nxiQgBao7PyXqfH8rMWRnu+qf85k9y0CLACyg0JQt60UAzRJexlbQqH BNXvUE7XY8nLE67H56DHX1cbdQQsvSMhG3oTzET/Hd5NUJbcuZ8pyO/hCZAx7sN2hWc7 HOrw== X-Gm-Message-State: AO0yUKXKjDA8s8HAg1mhzX0no71n/35GeeW8y0dIMcnxNm4oZy2EaMh8 SOn+FE2pAqsMf5loHcZ1f/0+MG5S+hp6QQ== 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_779615_0E696CEA X-CRM114-Status: GOOD ( 10.99 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=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)