linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/nmi: Rate limit unknown NMI messages
@ 2023-12-09  1:52 Namhyung Kim
  2023-12-10 10:39 ` Guilherme Amadio
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Namhyung Kim @ 2023-12-09  1:52 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Borislav Petkov,
	Dave Hansen
  Cc: Peter Zijlstra, Arnaldo Carvalho de Melo, LKML, x86,
	Ravi Bangoria, Guilherme Amadio, Stephane Eranian

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 <ravi.bangoria@amd.com>
Cc: Guilherme Amadio <amadio@gentoo.org>
Cc: Stephane Eranian <eranian@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 arch/x86/kernel/nmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 17e955ab69fe..d23867901186 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -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);
 
-- 
2.43.0.472.g3155946c3a-goog


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

* Re: [PATCH] x86/nmi: Rate limit unknown NMI messages
  2023-12-09  1:52 [PATCH] x86/nmi: Rate limit unknown NMI messages Namhyung Kim
@ 2023-12-10 10:39 ` Guilherme Amadio
  2023-12-12  4:16 ` Ravi Bangoria
  2024-01-25 16:35 ` [tip: x86/misc] " tip-bot2 for Namhyung Kim
  2 siblings, 0 replies; 4+ messages in thread
From: Guilherme Amadio @ 2023-12-10 10:39 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Borislav Petkov,
	Dave Hansen, Peter Zijlstra, Arnaldo Carvalho de Melo, LKML, x86,
	Ravi Bangoria, Stephane Eranian

On Fri, Dec 08, 2023 at 05:52:11PM -0800, Namhyung Kim wrote:
> 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 <ravi.bangoria@amd.com>
> Cc: Guilherme Amadio <amadio@gentoo.org>

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!

Acked-by: Guilherme Amadio <amadio@gentoo.org>

Best regards,
-Guilherme

> Cc: Stephane Eranian <eranian@google.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>  arch/x86/kernel/nmi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
> index 17e955ab69fe..d23867901186 100644
> --- a/arch/x86/kernel/nmi.c
> +++ b/arch/x86/kernel/nmi.c
> @@ -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);
>  
> -- 
> 2.43.0.472.g3155946c3a-goog
> 

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

* Re: [PATCH] x86/nmi: Rate limit unknown NMI messages
  2023-12-09  1:52 [PATCH] x86/nmi: Rate limit unknown NMI messages Namhyung Kim
  2023-12-10 10:39 ` Guilherme Amadio
@ 2023-12-12  4:16 ` Ravi Bangoria
  2024-01-25 16:35 ` [tip: x86/misc] " tip-bot2 for Namhyung Kim
  2 siblings, 0 replies; 4+ messages in thread
From: Ravi Bangoria @ 2023-12-12  4:16 UTC (permalink / raw)
  To: Namhyung Kim, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	Borislav Petkov, Dave Hansen
  Cc: Peter Zijlstra, Arnaldo Carvalho de Melo, LKML, x86,
	Guilherme Amadio, Stephane Eranian, Ravi Bangoria

> 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,

Acked-by: Ravi Bangoria <ravi.bangoria@amd.com>

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

* [tip: x86/misc] x86/nmi: Rate limit unknown NMI messages
  2023-12-09  1:52 [PATCH] x86/nmi: Rate limit unknown NMI messages Namhyung Kim
  2023-12-10 10:39 ` Guilherme Amadio
  2023-12-12  4:16 ` Ravi Bangoria
@ 2024-01-25 16:35 ` tip-bot2 for Namhyung Kim
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Namhyung Kim @ 2024-01-25 16:35 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Namhyung Kim, Borislav Petkov (AMD),
	Ravi Bangoria, Guilherme Amadio, Thomas Gleixner, x86,
	linux-kernel

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 <namhyung@kernel.org>
AuthorDate:    Fri, 08 Dec 2023 17:52:11 -08:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
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.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Ravi Bangoria <ravi.bangoria@amd.com>
Acked-by: Guilherme Amadio <amadio@gentoo.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20231209015211.357983-1-namhyung@kernel.org
---
 arch/x86/kernel/nmi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 17e955a..d238679 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -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);
 

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

end of thread, other threads:[~2024-01-25 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-09  1:52 [PATCH] x86/nmi: Rate limit unknown NMI messages Namhyung Kim
2023-12-10 10:39 ` Guilherme Amadio
2023-12-12  4:16 ` Ravi Bangoria
2024-01-25 16:35 ` [tip: x86/misc] " tip-bot2 for Namhyung Kim

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).