[PATCH 5/5] x86/mce: Change default mce logger to check mce->handled

From: Tony Luck
Date: Wed Feb 12 2020 - 15:46:58 EST


Instead of keeping count of how many handlers are registered on the
mce chain and printing if we are below some magic value. Look at the
mce->handled to see if anyone claims to have handled/logged this error.

[debug to always print in this version]

Signed-off-by: Tony Luck <tony.luck@xxxxxxxxx>
---
arch/x86/kernel/cpu/mce/core.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index ce7a78872f8f..5b73df383300 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -156,29 +156,17 @@ void mce_log(struct mce *m)
}
EXPORT_SYMBOL_GPL(mce_log);

-/*
- * We run the default notifier if we have only the UC, the first and the
- * default notifier registered. I.e., the mandatory NUM_DEFAULT_NOTIFIERS
- * notifiers registered on the chain.
- */
-#define NUM_DEFAULT_NOTIFIERS 3
-static atomic_t num_notifiers;
-
void mce_register_decode_chain(struct notifier_block *nb)
{
if (WARN_ON(nb->priority > MCE_PRIO_MCELOG && nb->priority < MCE_PRIO_EDAC))
return;

- atomic_inc(&num_notifiers);
-
blocking_notifier_chain_register(&x86_mce_decoder_chain, nb);
}
EXPORT_SYMBOL_GPL(mce_register_decode_chain);

void mce_unregister_decode_chain(struct notifier_block *nb)
{
- atomic_dec(&num_notifiers);
-
blocking_notifier_chain_unregister(&x86_mce_decoder_chain, nb);
}
EXPORT_SYMBOL_GPL(mce_unregister_decode_chain);
@@ -261,6 +249,8 @@ static void __print_mce(struct mce *m)
}

pr_cont("\n");
+ if (m->handled)
+ pr_emerg(HW_ERR "handled = %x\n", m->handled);
/*
* Note this output is parsed by external tools and old fields
* should not be changed.
@@ -600,10 +590,8 @@ static int mce_default_notifier(struct notifier_block *nb, unsigned long val,
if (!m)
return NOTIFY_DONE;

- if (atomic_read(&num_notifiers) > NUM_DEFAULT_NOTIFIERS)
- return NOTIFY_DONE;
-
- __print_mce(m);
+ if (1 || !m->handled)
+ __print_mce(m);

return NOTIFY_DONE;
}
--
2.21.1