Re: [PATCH v6 1/4] x86/mce: Cleanup bank processing on init

From: Borislav Petkov
Date: Fri Dec 23 2022 - 08:24:02 EST


On Tue, Dec 06, 2022 at 11:36:04AM -0600, Yazen Ghannam wrote:
> -static void __mcheck_cpu_init_clear_banks(void)
> +static void __mcheck_cpu_init_prepare_banks(void)
> {
> struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array);
> + mce_banks_t all_banks;
> + u64 msrval;
> int i;
>
> - for (i = 0; i < this_cpu_read(mce_num_banks); i++) {
> - struct mce_bank *b = &mce_banks[i];
> -
> - if (!b->init)
> - continue;
> - wrmsrl(mca_msr_reg(i, MCA_CTL), b->ctl);
> - wrmsrl(mca_msr_reg(i, MCA_STATUS), 0);
> + /*
> + * Log the machine checks left over from the previous reset. Log them
> + * only, do not start processing them. That will happen in mcheck_late_init()
> + * when all consumers have been registered on the notifier chain.
> + */
> + if (mca_cfg.bootlog) {
> + bitmap_fill(all_banks, MAX_NR_BANKS);
> + machine_check_poll(MCP_UC | MCP_QUEUE_LOG, &all_banks);
> }

Yeah, just a nit ontop - lemme move all_banks into the if branch so that
it is closer and obvious:

---
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 5f406d135d32..a90d3eb6fcd8 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1755,7 +1755,6 @@ static void __mcheck_cpu_init_generic(void)
static void __mcheck_cpu_init_prepare_banks(void)
{
struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array);
- mce_banks_t all_banks;
u64 msrval;
int i;

@@ -1765,6 +1764,8 @@ static void __mcheck_cpu_init_prepare_banks(void)
* when all consumers have been registered on the notifier chain.
*/
if (mca_cfg.bootlog) {
+ mce_banks_t all_banks;
+
bitmap_fill(all_banks, MAX_NR_BANKS);
machine_check_poll(MCP_UC | MCP_QUEUE_LOG, &all_banks);
}

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette