Re: [PATCH v2 3/3] x86/mce: Increase MAX_NR_BANKS to 255
From: Yazen Ghannam
Date: Tue Nov 24 2026 - 09:42:46 EST
On Tue, Nov 24, 2026 at 02:10:08AM +0000, Qiuxu (Leo) Zhuo wrote:
> > From: Yazen Ghannam <yazen.ghannam@xxxxxxx>
> > Sent: Tuesday, November 24, 2026 7:27 AM
> > To: linux-edac@xxxxxxxxxxxxxxx
> > Cc: linux-kernel@xxxxxxxxxxxxxxx; tony.luck@xxxxxxxxx; x86@xxxxxxxxxx; Yazen
> > Ghannam <yazen.ghannam@xxxxxxx>
> > Subject: [PATCH v2 3/3] x86/mce: Increase MAX_NR_BANKS to 255
> >
> >
> > Machine Check Architecture (MCA) allows up to 255 MCA banks per CPU thread.
> > This is based on the size of the "Count" field of the MCG_CAP registers. The "Count"
> > field is 8 bits and holds the number of MCA banks per CPU thread. So the value
> > range is 0-255.
> >
> > Change the MAX_NR_BANKS value to match the architectural definition.
> >
> > Drop the clamps in __mcheck_cpu_cap_init() and cmci_supported().
> > MCG_CAP[Count] can no longer exceed MAX_NR_BANKS, so neither is reachable.
> >
> > cmci_supported() now takes the bank count from mce_num_banks instead of
> > reading MCG_CAP[Count] again. mcheck_cpu_init() sets it before CMCI is set up, so
> > the two agree. A CPU that skipped MCA setup now reports no banks instead of the
> > hardware count.
> >
> > MAX_NR_BANKS sizes a number of arrays and bitmaps. Growing it by 191 banks
> > costs the following, measured with size -A on the MCA objects built from x86_64
> > defconfig.
> >
> > Global bitmaps:
> > - core.c / mce_banks_ce_disabled
> > - Total: 191 new bits = 24 new bytes
> >
> > Per-CPU bitmaps:
> > - core.c / mce_poll_banks
> > - intel.c / mce_banks_owned
> > - amd.c / bank_map
> > - amd.c / mce_amd_data: thr_intr_banks and dfr_intr_banks
> > - Total: 191 new bits * 5 bitmaps = 120 new bytes
> >
> > Global structs:
> > - core.c / struct mce_bank_dev mce_bank_devs[]: 56 bytes per bank
> > - intel.c / u16 cmci_threshold[]: 2 bytes per bank
> > - Total: 191 new banks * 58 bytes = 11078 new bytes
> >
> > Per-CPU structs:
> > - core.c / struct mce_bank mce_banks_array[]: 16 bytes per bank
> > - amd.c / struct smca_bank smca_banks[]: 24 bytes per bank
> > - threshold.c / struct mca_storm_desc storm_desc: 24 bytes per bank
> > - Total: 191 new banks * 64 bytes = 12224 new bytes
> >
> > Section totals, which include alignment padding:
> >
> > Total global size increase: 11152 bytes of .bss Total per-CPU size increase: 12368
> > bytes
> >
> > The per-CPU total is replicated for every possible CPU. In the linked
> > image .data..percpu grows by 12352 bytes. The first per-CPU chunk is page aligned,
> > so each CPU retains three more pages, 229376 bytes up from 217088. That is 5.7%
> > more per-CPU memory, or 6 MiB on a 512 thread system.
> >
> > On the stack, the two bank bitmaps grow the frame of do_machine_check() by 48
> > bytes, from 232 to 280 bytes, on the 8 KiB #MC exception stack.
> >
> > One module outside defconfig also grows. Measured with size -A on
> > intel-bff.o:
> >
> > Module read-only tables:
> > - edac/intel-bff.c / enum bff_bank_type dmr_mcbanks[]: 4 bytes per bank
> > - Total: 191 new banks * 4 bytes = 764 new bytes of .rodata
> >
> > Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
> > ---
> > arch/x86/include/asm/mce.h | 2 +-
> > arch/x86/kernel/cpu/mce/core.c | 6 ------ arch/x86/kernel/cpu/mce/intel.c | 2 +-
> > 3 files changed, 2 insertions(+), 8 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index
> > 9995176d6879..e5fa0f58b305 100644
> > --- a/arch/x86/include/asm/mce.h
> > +++ b/arch/x86/include/asm/mce.h
> > @@ -273,7 +273,7 @@ void mce_log(struct mce_hw_err *err);
> > DECLARE_PER_CPU(struct device *, mce_device);
> >
> > /* Maximum number of MCA banks per CPU. */ -#define MAX_NR_BANKS 64
> > +#define MAX_NR_BANKS 255
> >
>
> Out of curiosity , are there any existing systems with more than 64 MCA banks per CPU thread?
Not currently. Future systems will have such configurations.
Thanks,
Yazen