Re: [PATCH v3 2/2] x86/mce: Rate-limit the CMCI storm transition notices
From: Sohil Mehta
Date: Fri Nov 13 2026 - 16:58:37 EST
On 11/13/2026 4:49 AM, Breno Leitao wrote:
> mce_track_storm() prints a line every time a bank enters storm mode and
> another every time it leaves. Neither is bounded, so the log volume
> follows whatever rate the bank flaps at.
>
> One host in our fleet logged 9970726 "CMCI storm detected" and 9970734
> "CMCI storm subsided" lines for a single bank over four days, which is
> a bit excessive for all monitoring purposes.
>
> Put both transitions behind one ratelimit.
>
> Acked-by: Tony Luck <tony.luck@xxxxxxxxx>
> Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
> ---
Reviewed-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>
A minor nit below.
> arch/x86/kernel/cpu/mce/threshold.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mce/threshold.c b/arch/x86/kernel/cpu/mce/threshold.c
> index 6c370d5af5bd23..8591715ce24306 100644
> --- a/arch/x86/kernel/cpu/mce/threshold.c
> +++ b/arch/x86/kernel/cpu/mce/threshold.c
> @@ -4,6 +4,7 @@
> */
> #include <linux/interrupt.h>
> #include <linux/kernel.h>
> +#include <linux/ratelimit.h>
>
> #include <asm/irq_vectors.h>
> #include <asm/traps.h>
> @@ -111,6 +112,13 @@ void cmci_storm_end(unsigned int bank)
> mce_timer_kick(false);
> }
>
> +/*
> + * Shared by both transitions so that a bank flapping between them cannot
> + * outrun the console.
> + */
> +static DEFINE_RATELIMIT_STATE(storm_rs, DEFAULT_RATELIMIT_INTERVAL,
> + DEFAULT_RATELIMIT_BURST);
> +
Should this be defined as a function local similar to patch 1?
> void mce_track_storm(struct mce *mce)
> {
> struct mca_storm_desc *storm = this_cpu_ptr(&storm_desc);
> @@ -150,13 +158,17 @@ void mce_track_storm(struct mce *mce)
> if (storm->banks[mce->bank].in_storm_mode) {
> if (history & GENMASK_ULL(STORM_END_POLL_THRESHOLD, 0))
> return;
> - printk_deferred(KERN_NOTICE "CPU%d BANK%d CMCI storm subsided\n", smp_processor_id(), mce->bank);
> + if (__ratelimit(&storm_rs))
> + printk_deferred(KERN_NOTICE "CPU%d BANK%d CMCI storm subsided\n",
> + smp_processor_id(), mce->bank);
> mce_handle_storm(mce->bank, false);
> cmci_storm_end(mce->bank);
> } else {
> if (hweight64(history) < STORM_BEGIN_THRESHOLD)
> return;
> - printk_deferred(KERN_NOTICE "CPU%d BANK%d CMCI storm detected\n", smp_processor_id(), mce->bank);
> + if (__ratelimit(&storm_rs))
> + printk_deferred(KERN_NOTICE "CPU%d BANK%d CMCI storm detected\n",
> + smp_processor_id(), mce->bank);
> mce_handle_storm(mce->bank, true);
> cmci_storm_begin(mce->bank);
> }
>