From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80FADC43219 for ; Mon, 11 Oct 2021 09:45:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A99860F92 for ; Mon, 11 Oct 2021 09:45:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235653AbhJKJrC (ORCPT ); Mon, 11 Oct 2021 05:47:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:41916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235626AbhJKJrB (ORCPT ); Mon, 11 Oct 2021 05:47:01 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F3FEA60F43; Mon, 11 Oct 2021 09:45:00 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mZrrf-00FyZ3-2U; Mon, 11 Oct 2021 10:44:59 +0100 Date: Mon, 11 Oct 2021 10:44:58 +0100 Message-ID: <87tuhnq4it.wl-maz@kernel.org> From: Marc Zyngier To: Sean Christopherson Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Will Deacon , Mark Rutland , Guo Ren , Nick Hu , Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Boris Ostrovsky , Juergen Gross , Alexander Shishkin , Jiri Olsa , Namhyung Kim , James Morse , Alexandru Elisei , Suzuki K Poulose , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Stefano Stabellini , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, Artem Kashkanov , Like Xu , Zhu Lingshan Subject: Re: [PATCH v3 15/16] KVM: arm64: Drop perf.c and fold its tiny bits of code into arm.c / pmu.c In-Reply-To: <20210922000533.713300-16-seanjc@google.com> References: <20210922000533.713300-1-seanjc@google.com> <20210922000533.713300-16-seanjc@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: seanjc@google.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, will@kernel.org, mark.rutland@arm.com, guoren@kernel.org, nickhu@andestech.com, green.hu@gmail.com, deanbo422@gmail.com, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, pbonzini@redhat.com, boris.ostrovsky@oracle.com, jgross@suse.com, alexander.shishkin@linux.intel.com, jolsa@redhat.com, namhyung@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, sstabellini@kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, artem.kashkanov@intel.com, like.xu.linux@gmail.com, lingshan.zhu@intel.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org On Wed, 22 Sep 2021 01:05:32 +0100, Sean Christopherson wrote: > > Call KVM's (un)register perf callbacks helpers directly from arm.c, and > move the PMU bits into pmu.c and rename the related helper accordingly. > > Signed-off-by: Sean Christopherson > --- > arch/arm64/include/asm/kvm_host.h | 3 --- > arch/arm64/kvm/Makefile | 2 +- > arch/arm64/kvm/arm.c | 6 ++++-- > arch/arm64/kvm/perf.c | 27 --------------------------- > arch/arm64/kvm/pmu.c | 8 ++++++++ > include/kvm/arm_pmu.h | 1 + > 6 files changed, 14 insertions(+), 33 deletions(-) > delete mode 100644 arch/arm64/kvm/perf.c > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 828b6eaa2c56..f141ac65f4f1 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -670,9 +670,6 @@ unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len); > int kvm_handle_mmio_return(struct kvm_vcpu *vcpu); > int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa); > > -void kvm_perf_init(void); > -void kvm_perf_teardown(void); > - > #ifdef CONFIG_GUEST_PERF_EVENTS > static inline bool kvm_arch_pmi_in_guest(struct kvm_vcpu *vcpu) > { > diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile > index 989bb5dad2c8..0bcc378b7961 100644 > --- a/arch/arm64/kvm/Makefile > +++ b/arch/arm64/kvm/Makefile > @@ -12,7 +12,7 @@ obj-$(CONFIG_KVM) += hyp/ > > kvm-y := $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o \ > $(KVM)/vfio.o $(KVM)/irqchip.o $(KVM)/binary_stats.o \ > - arm.o mmu.o mmio.o psci.o perf.o hypercalls.o pvtime.o \ > + arm.o mmu.o mmio.o psci.o hypercalls.o pvtime.o \ > inject_fault.o va_layout.o handle_exit.o \ > guest.o debug.o reset.o sys_regs.o \ > vgic-sys-reg-v3.o fpsimd.o pmu.o \ > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > index 2b542fdc237e..48f89d80f464 100644 > --- a/arch/arm64/kvm/arm.c > +++ b/arch/arm64/kvm/arm.c > @@ -1744,7 +1744,9 @@ static int init_subsystems(void) > if (err) > goto out; > > - kvm_perf_init(); > + kvm_pmu_init(); > + kvm_register_perf_callbacks(NULL); > + > kvm_sys_reg_table_init(); > > out: > @@ -2160,7 +2162,7 @@ int kvm_arch_init(void *opaque) > /* NOP: Compiling as a module not supported */ > void kvm_arch_exit(void) > { > - kvm_perf_teardown(); > + kvm_unregister_perf_callbacks(); > } > > static int __init early_kvm_mode_cfg(char *arg) > diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c > deleted file mode 100644 > index 0b902e0d5b5d..000000000000 > --- a/arch/arm64/kvm/perf.c > +++ /dev/null > @@ -1,27 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0-only > -/* > - * Based on the x86 implementation. > - * > - * Copyright (C) 2012 ARM Ltd. > - * Author: Marc Zyngier > - */ > - > -#include > -#include > - > -#include > - > -DEFINE_STATIC_KEY_FALSE(kvm_arm_pmu_available); > - > -void kvm_perf_init(void) > -{ > - if (kvm_pmu_probe_pmuver() != 0xf && !is_protected_kvm_enabled()) > - static_branch_enable(&kvm_arm_pmu_available); > - > - kvm_register_perf_callbacks(NULL); > -} > - > -void kvm_perf_teardown(void) > -{ > - kvm_unregister_perf_callbacks(); > -} > diff --git a/arch/arm64/kvm/pmu.c b/arch/arm64/kvm/pmu.c > index 03a6c1f4a09a..d98b57a17043 100644 > --- a/arch/arm64/kvm/pmu.c > +++ b/arch/arm64/kvm/pmu.c > @@ -7,6 +7,14 @@ > #include > #include > > +DEFINE_STATIC_KEY_FALSE(kvm_arm_pmu_available); > + > +void kvm_pmu_init(void) > +{ > + if (kvm_pmu_probe_pmuver() != 0xf && !is_protected_kvm_enabled()) > + static_branch_enable(&kvm_arm_pmu_available); > +} > + > /* > * Given the perf event attributes and system type, determine > * if we are going to need to switch counters at guest entry/exit. > diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h > index 864b9997efb2..42270676498d 100644 > --- a/include/kvm/arm_pmu.h > +++ b/include/kvm/arm_pmu.h > @@ -14,6 +14,7 @@ > #define ARMV8_PMU_MAX_COUNTER_PAIRS ((ARMV8_PMU_MAX_COUNTERS + 1) >> 1) > > DECLARE_STATIC_KEY_FALSE(kvm_arm_pmu_available); > +void kvm_pmu_init(void); > > static __always_inline bool kvm_arm_support_pmu_v3(void) > { Note that this patch is now conflicting with e840f42a4992 ("KVM: arm64: Fix PMU probe ordering"), which was merged in -rc4. Moving the static key definition to arch/arm64/kvm/pmu-emul.c and getting rid of kvm_pmu_init() altogether should be enough to resolve it. With that, Reviewed-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible.