From: Sean Christopherson <seanjc@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Fernand Sieber" <sieberf@amazon.com>,
pbonzini@redhat.com, "Jan H. Schönherr" <jschoenh@amazon.de>,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
dwmw@amazon.co.uk, hborghor@amazon.de, nh-open-source@amazon.com,
abusse@amazon.de, nsaenz@amazon.com, stable@vger.kernel.org
Subject: Re: [PATCH] KVM: x86/pmu: Do not accidentally create BTS events
Date: Tue, 2 Dec 2025 08:03:26 -0800 [thread overview]
Message-ID: <aS8Nzomxsy5S4AQ-@google.com> (raw)
In-Reply-To: <20251202124423.GC2458571@noisy.programming.kicks-ass.net>
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.
next prev parent reply other threads:[~2025-12-02 16:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 14:23 [PATCH] KVM: x86/pmu: Do not accidentally create BTS events Fernand Sieber
2025-12-01 14:26 ` kernel test robot
2025-12-01 14:45 ` Woodhouse, David
2025-12-02 9:35 ` Peter Zijlstra
2025-12-02 9:59 ` Fernand Sieber
2025-12-02 10:03 ` Peter Zijlstra
2025-12-02 12:44 ` Peter Zijlstra
2025-12-02 16:03 ` Sean Christopherson [this message]
2025-12-10 10:11 ` Fernand Sieber
2025-12-10 11:16 ` Peter Zijlstra
2025-12-11 18:36 ` [PATCH v2] perf/x86/intel: Do not enable BTS for guests Fernand Sieber
2025-12-11 18:38 ` kernel test robot
2026-01-14 17:25 ` David Woodhouse
2026-01-21 13:57 ` Fernand Sieber
2026-01-21 15:31 ` Peter Zijlstra
2026-01-21 15:50 ` [tip: perf/urgent] " tip-bot2 for Fernand Sieber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aS8Nzomxsy5S4AQ-@google.com \
--to=seanjc@google.com \
--cc=abusse@amazon.de \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw@amazon.co.uk \
--cc=hborghor@amazon.de \
--cc=hpa@zytor.com \
--cc=jschoenh@amazon.de \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nh-open-source@amazon.com \
--cc=nsaenz@amazon.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=sieberf@amazon.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox