Re: [PATCH] perf/x86/amd: Do not WARN on every IRQ

From: Breno Leitao
Date: Fri Jun 16 2023 - 10:05:23 EST


On Fri, Jun 16, 2023 at 03:29:54PM +0200, Peter Zijlstra wrote:
> On Fri, Jun 16, 2023 at 04:53:15AM -0700, Breno Leitao wrote:
> > On some systems, the Performance Counter Global Status Register is
> > coming with reserved bits set, which causes the system to be unusable
> > if a simple `perf top` runs. The system hits the WARN() thousands times
> > while perf runs.
> >
> > WARNING: CPU: 18 PID: 20608 at arch/x86/events/amd/core.c:944 amd_pmu_v2_handle_irq+0x1be/0x2b0
> >
> > This happens because the "Performance Counter Global Status Register"
> > (PerfCntGlobalStatus) MSR has bit 7 set. Bit 7 should be reserved according
> > to the documentation (Figure 13-12 from "AMD64 Architecture Programmer’s
> > Manual, Volume 2: System Programming, 24593"[1]
>
> Would it then not make more sense to mask out bit7 before:

It is more than bit 7. This is the register structure according to the document
above:

Bits Mnemonic Description Access type
63:60 Reserved RO
59 PMCF Performance Counter Freeze RO
58 LBRSF Last Branch Record Stack Freeze RO
57:6 Reserved RO
5:0 CNT_OF Counter overflow for PerfCnt[5:0] RO

In the code, bit GLOBAL_STATUS_LBRS_FROZEN is handled and cleared before
we reach my changes

That said, your approach is almost similar to what I did, and I will be happy
to change in order to make the code clearer.

> + status &= ~AMD_PMU_V2_GLOBAL_STATUS_RESERVED;
> if (!status)
> goto done;
>
> ?
>
> Aside from being reserved, why are these bits magically set all of a
> sudden?

That is probably a question to AMD.