[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aS8Nzomxsy5S4AQ-@google.com>
Date: Tue, 2 Dec 2025 08:03:26 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Fernand Sieber <sieberf@...zon.com>, pbonzini@...hat.com,
"Jan H. Schönherr" <jschoenh@...zon.de>, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org, dwmw@...zon.co.uk,
hborghor@...zon.de, nh-open-source@...zon.com, abusse@...zon.de,
nsaenz@...zon.com, stable@...r.kernel.org
Subject: Re: [PATCH] KVM: x86/pmu: Do not accidentally create BTS events
On Tue, Dec 02, 2025, Peter Zijlstra wrote:
> Does something like so work? It is still terrible, but perhaps slightly
> less so.
>
> diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
> index 2b969386dcdd..493e6ba51e06 100644
> --- a/arch/x86/events/perf_event.h
> +++ b/arch/x86/events/perf_event.h
> @@ -1558,13 +1558,22 @@ static inline bool intel_pmu_has_bts_period(struct perf_event *event, u64 period
> struct hw_perf_event *hwc = &event->hw;
> unsigned int hw_event, bts_event;
>
> - if (event->attr.freq)
> + /*
> + * Only use BTS for fixed rate period==1 events.
> + */
> + if (event->attr.freq || period != 1)
> + return false;
> +
> + /*
> + * BTS doesn't virtualize.
> + */
> + if (event->attr.exclude_host)
Ya, this seems like the right fix. Pulling in the original bug report:
When BTS is enabled, it leads to general host performance degradation to both
VMs and host.
I assume the underlying problem is that intel_pmu_enable_bts() is called even
when the event isn't enabled in the host, and BTS doesn't discrimate once it's
enable and bogs down the host (but presumably not the guest, at least not directly,
since KVM should prevent setting BTS in vmcs.GUEST_IA32_DEBUGCTL). Enabling BTS
for exclude-host events simply can't work, even if the event came from host userspace.
Powered by blists - more mailing lists