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 X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F0FCC433FE for ; Mon, 20 Sep 2021 10:25:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D10ED6109E for ; Mon, 20 Sep 2021 10:25:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D10ED6109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w2hU02w/SiOqz7eiq0BhaRDiYb/twgOCRpSKscw9KhI=; b=fn2Al/Q6jzPpiH u3v0gKKhG8agKN49lJsqJLj74pxuAot5WZjQc15kCwZHGsuHClewbF+etwF77V6XdixIRJd2s1hgb Fr90ty8YJpo6KQZJrZaeM61U/LPCivMSldKzGWS7GmypOyIIw20xAw0YKDDB7xTqLieEbuCp2rYGs BH3/PYpP5aHVIrr0oX4rQSQkEEr+MhKVpMitZ9xgN0eB4Qsd2sGS+L0YtEwuavxm87/vjXhCSW0cZ somTKlC3zqD3Vz4T4qrYH/sr6/iM2qSHDYZoZ9Z6SmaCqLhQjIx2oZzCBtSh7q1pcJuh8ZObrZlfo aiymofKWyRU3OoibIHaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSGSx-001HD6-UT; Mon, 20 Sep 2021 10:24:04 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSGSt-001HC9-8Q for linux-arm-kernel@lists.infradead.org; Mon, 20 Sep 2021 10:24:00 +0000 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 EBBAC60FED; Mon, 20 Sep 2021 10:23:58 +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 1mSGSq-00Bjnp-Un; Mon, 20 Sep 2021 11:23:57 +0100 Date: Mon, 20 Sep 2021 11:23:56 +0100 Message-ID: <87y27rv937.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: "Russell King (Oracle)" , linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, James Morse , Alexandru Elisei , Suzuki K Poulose Subject: Re: REGRESSION: Upgrading host kernel from 5.11 to 5.13 breaks QEMU guests - perf/fw_devlink/kvm In-Reply-To: <20210920095656.GA11961@willie-the-truck> References: <877dfcwutt.wl-maz@kernel.org> <20210920095656.GA11961@willie-the-truck> 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") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: will@kernel.org, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210920_032359_402253_F9F4144E X-CRM114-Status: GOOD ( 36.57 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 20 Sep 2021 10:56:57 +0100, Will Deacon wrote: > > On Sun, Sep 19, 2021 at 02:36:46PM +0100, Marc Zyngier wrote: > > From 9c26e3e6bbcbc3a583b3974e7a9017029d31fe29 Mon Sep 17 00:00:00 2001 > > From: Marc Zyngier > > Date: Sun, 19 Sep 2021 14:09:49 +0100 > > Subject: [PATCH] KVM: arm64: Fix PMU probe ordering > > > > Russell reported that since 5.13, KVM's probing of the PMU has > > started to fail on his HW. As it turns out, there is an implicit > > ordering dependency between the architectural PMU probing code and > > and KVM's own probing. If, due to probe ordering reasons, KVM probes > > before the PMU driver, it will fail to detect the PMU and prevent it > > from being advertised to guests as well as the VMM. > > > > Obviously, this is one probing too many, and we should be able to > > deal with any ordering. > > > > Add a callback from the PMU code into KVM to advertise the registration > > of a host CPU PMU, allowing for any probing order. > > > > Fixes: 5421db1be3b1 ("KVM: arm64: Divorce the perf code from oprofile helpers") > > Reported-by: "Russell King (Oracle)" > > Signed-off-by: Marc Zyngier > > Link: https://lore.kernel.org/r/YUYRKVflRtUytzy5@shell.armlinux.org.uk > > Cc: stable@vger.kernel.org > > --- > > arch/arm64/kvm/perf.c | 3 --- > > arch/arm64/kvm/pmu-emul.c | 12 +++++++++++- > > drivers/perf/arm_pmu.c | 2 ++ > > include/kvm/arm_pmu.h | 3 --- > > include/linux/perf/arm_pmu.h | 6 ++++++ > > 5 files changed, 19 insertions(+), 7 deletions(-) > > > > diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c > > index f9bb3b14130e..c84fe24b2ea1 100644 > > --- a/arch/arm64/kvm/perf.c > > +++ b/arch/arm64/kvm/perf.c > > @@ -50,9 +50,6 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = { > > > > int kvm_perf_init(void) > > { > > - if (kvm_pmu_probe_pmuver() != ID_AA64DFR0_PMUVER_IMP_DEF && !is_protected_kvm_enabled()) > > - static_branch_enable(&kvm_arm_pmu_available); > > - > > return perf_register_guest_info_callbacks(&kvm_guest_cbs); > > } > > > > diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c > > index f5065f23b413..588100c52f34 100644 > > --- a/arch/arm64/kvm/pmu-emul.c > > +++ b/arch/arm64/kvm/pmu-emul.c > > @@ -740,7 +740,17 @@ void kvm_pmu_set_counter_event_type(struct kvm_vcpu *vcpu, u64 data, > > kvm_pmu_create_perf_event(vcpu, select_idx); > > } > > > > -int kvm_pmu_probe_pmuver(void) > > +void kvm_host_pmu_init(struct arm_pmu *pmu) > > +{ > > + if (pmu->pmuver != 0 && > > + pmu->pmuver != ID_AA64DFR0_PMUVER_IMP_DEF && > > + !is_protected_kvm_enabled()) { > > + static_branch_enable(&kvm_arm_pmu_available); > > + kvm_info("PMU detected and enabled\n"); > > + } > > +} > > + > > +static int kvm_pmu_probe_pmuver(void) > > { > > struct perf_event_attr attr = { }; > > struct perf_event *event; > > diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c > > index 3cbc3baf087f..295cc7952d0e 100644 > > --- a/drivers/perf/arm_pmu.c > > +++ b/drivers/perf/arm_pmu.c > > @@ -952,6 +952,8 @@ int armpmu_register(struct arm_pmu *pmu) > > pmu->name, pmu->num_events, > > has_nmi ? ", using NMIs" : ""); > > > > + kvm_host_pmu_init(pmu); > > Just a nit, but I think this will get called for each PMU we probe > on a big.LITTLE system which is probably harmless, but possible not > what you want? Yeah, it is a bit ugly, but harmless. In the future, it would be useful to track which PMU is used on which CPUs, and this will give us a decent hook. I'll tone the print down though. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel