linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf/x86/amd: Do not WARN on every IRQ
@ 2023-06-16 11:53 Breno Leitao
  2023-06-16 13:29 ` Peter Zijlstra
  0 siblings, 1 reply; 22+ messages in thread
From: Breno Leitao @ 2023-06-16 11:53 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Adrian Hunter, Thomas Gleixner, Borislav Petkov,
	Dave Hansen, x86, H. Peter Anvin, Sandipan Das
  Cc: leit, dcostantino, open list:PERFORMANCE EVENTS SUBSYSTEM,
	open list:PERFORMANCE EVENTS SUBSYSTEM

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]

WARN_ONCE if any reserved bit is set, and sanitize the value to what the
code is handling, so the overflow events continue to be handled for the
number of events that are known to be sane.

Signed-off-by: Breno Leitao <leitao@debian.org>
Fixes: 7685665c390d ("perf/x86/amd/core: Add PerfMonV2 overflow handling")

[1] Link: https://www.amd.com/system/files/TechDocs/24593.pdf
---
 arch/x86/events/amd/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index bccea57dee81..809ddb15c122 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -909,6 +909,10 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)
 		status &= ~GLOBAL_STATUS_LBRS_FROZEN;
 	}
 
+	amd_pmu_global_cntr_mask = (1ULL << x86_pmu.num_counters) - 1;
+	WARN_ON_ONCE(status & ~amd_pmu_global_cntr_mask);
+	status &= amd_pmu_global_cntr_mask;
+
 	for (idx = 0; idx < x86_pmu.num_counters; idx++) {
 		if (!test_bit(idx, cpuc->active_mask))
 			continue;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-09-14 13:52 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-16 11:53 [PATCH] perf/x86/amd: Do not WARN on every IRQ Breno Leitao
2023-06-16 13:29 ` Peter Zijlstra
2023-06-16 14:03   ` Breno Leitao
2023-06-16 14:43     ` Sandipan Das (AMD)
2023-06-16 15:32       ` Peter Zijlstra
2023-09-13 14:30         ` Jirka Hladky
2023-09-13 15:03           ` Breno Leitao
2023-09-13 15:23             ` Jirka Hladky
2023-09-13 16:18           ` Sandipan Das
2023-09-14  8:44             ` Jirka Hladky
     [not found]             ` <CAE4VaGAcWk0PYygNGcguRA2V2qK03entkv6BUsnxhS-ftdfywg@mail.gmail.com>
2023-09-14  8:49               ` Sandipan Das
2023-09-13 16:24   ` Breno Leitao
2023-09-14  8:45     ` Jirka Hladky
2023-09-14  8:55       ` Sandipan Das
2023-09-14  9:12         ` Peter Zijlstra
2023-09-14  9:14           ` Sandipan Das
2023-09-14  9:30           ` Breno Leitao
2023-09-14 11:18             ` Peter Zijlstra
2023-09-14 11:22               ` Sandipan Das
2023-09-14 11:27                 ` Peter Zijlstra
2023-09-14 12:21                 ` Breno Leitao
2023-09-14 13:50                   ` Jirka Hladky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).