Skip to contentSkip to conversation

x86/nmi: Rate limit unknown NMI messages

PATCH Applied Namhyung Kim 4 participants 4 messages Dec 9, 2023 – Jan 25, 2024 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/nmi: Rate limit unknown NMI messages

On some AMD machines, unknown NMI messages were printed on the console continuously when using perf command with IBS. It was reported that it can slow down the kernel. Let's ratelimit the unknown NMI messages.

Cc Ravi Bangoria <[email protected]>
Cc Guilherme Amadio <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 arch/x86/kernel/nmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/nmi.c +3 -3
index 17e955ab69fe..d23867901186 100644
@@ -303,13 +303,13 @@ unknown_nmi_error(unsigned char reason, struct pt_regs *regs)
 
 	__this_cpu_add(nmi_stats.unknown, 1);
 
-	pr_emerg("Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
-		 reason, smp_processor_id());
+	pr_emerg_ratelimited("Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
+			     reason, smp_processor_id());
 
 	if (unknown_nmi_panic || panic_on_unrecovered_nmi)
 		nmi_panic(regs, "NMI: Not continuing");
 
-	pr_emerg("Dazed and confused, but trying to continue\n");
+	pr_emerg_ratelimited("Dazed and confused, but trying to continue\n");
 }
 NOKPROBE_SYMBOL(unknown_nmi_error);
 
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Namhyung Kim

On some AMD machines, unknown NMI messages were printed on the console continuously when using perf command with IBS. It was reported that it can slow down the kernel. Let's ratelimit the unknown NMI messages.

Cc Ravi Bangoria <[email protected]>
Cc Guilherme Amadio <[email protected]>

The rate of messages on the console were proportional to the sampling frequency when I noticed this happening, so this is a welcome change. Thank you!

Best regards,
-Guilherme

Quoted 30 lines
Cc Stephane Eranian <[email protected]>
---
 arch/x86/kernel/nmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/nmi.c +3 -3
index 17e955ab69fe..d23867901186 100644
@@ -303,13 +303,13 @@ unknown_nmi_error(unsigned char reason, struct pt_regs *regs)
 
 	__this_cpu_add(nmi_stats.unknown, 1);
 
-	pr_emerg("Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
-		 reason, smp_processor_id());
+	pr_emerg_ratelimited("Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
+			     reason, smp_processor_id());
 
 	if (unknown_nmi_panic || panic_on_unrecovered_nmi)
 		nmi_panic(regs, "NMI: Not continuing");
 
-	pr_emerg("Dazed and confused, but trying to continue\n");
+	pr_emerg_ratelimited("Dazed and confused, but trying to continue\n");
 }
 NOKPROBE_SYMBOL(unknown_nmi_error);
 
Signature · 1 line
2.43.0.472.g3155946c3a-goog
Acked-by on v1 1/1
#2 lore raw
In reply to Namhyung Kim
Quoted 3 lines

On some AMD machines, unknown NMI messages were printed on the console continuously when using perf command with IBS. It was reported that it can slow down the kernel. Let's ratelimit the unknown NMI messages.

Continuously repeating of the same message is useless. So,

merge bot Applied
#3 lore raw
In reply to Namhyung Kim
The following commit has been merged into the x86/misc branch of tip:

The following commit has been merged into the x86/misc branch of tip:

Commit-ID:     e2fbc857d3c677ce96d9260577491e0d8f21b6f7
Gitweb:        https://git.kernel.org/tip/e2fbc857d3c677ce96d9260577491e0d8f21b6f7
Author:        Namhyung Kim <[email protected]>
AuthorDate:    Fri, 08 Dec 2023 17:52:11 -08:00
Committer:     Borislav Petkov (AMD) <[email protected]>
CommitterDate: Thu, 25 Jan 2024 17:29:06 +01:00

x86/nmi: Rate limit unknown NMI messages

On some AMD machines, unknown NMI messages were printed on the console continuously when using perf command with IBS. It was reported that it can slow down the kernel. Ratelimit the unknown NMI messages.

---
 arch/x86/kernel/nmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/nmi.c +3 -3
index 17e955a..d238679 100644
@@ -303,13 +303,13 @@ unknown_nmi_error(unsigned char reason, struct pt_regs *regs)
 
 	__this_cpu_add(nmi_stats.unknown, 1);
 
-	pr_emerg("Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
-		 reason, smp_processor_id());
+	pr_emerg_ratelimited("Uhhuh. NMI received for unknown reason %02x on CPU %d.\n",
+			     reason, smp_processor_id());
 
 	if (unknown_nmi_panic || panic_on_unrecovered_nmi)
 		nmi_panic(regs, "NMI: Not continuing");
 
-	pr_emerg("Dazed and confused, but trying to continue\n");
+	pr_emerg_ratelimited("Dazed and confused, but trying to continue\n");
 }
 NOKPROBE_SYMBOL(unknown_nmi_error);