mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: "Qiuxu (Leo) Zhuo" <qzhuo@nvidia.com>
Cc: "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"tony.luck@intel.com" <tony.luck@intel.com>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v2 3/3] x86/mce: Increase MAX_NR_BANKS to 255
Date: Tue, 24 Nov 2026 09:42:23 -0500	[thread overview]
Message-ID: <20261124144223.GA2156781@yaz-khff2.amd.com> (raw)
In-Reply-To: <CY8PR12MB72909343EE7AA50BB36ED3CFD1442@CY8PR12MB7290.namprd12.prod.outlook.com>

On Tue, Nov 24, 2026 at 02:10:08AM +0000, Qiuxu (Leo) Zhuo wrote:
> > From: Yazen Ghannam <yazen.ghannam@amd.com>
> > Sent: Tuesday, November 24, 2026 7:27 AM
> > To: linux-edac@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org; tony.luck@intel.com; x86@kernel.org; Yazen
> > Ghannam <yazen.ghannam@amd.com>
> > 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@amd.com>
> > ---
> >  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

      reply	other threads:[~2026-11-24 14:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 23:26 [PATCH v2 0/3] Increase MCA bank count Yazen Ghannam
2026-11-23 23:26 ` [PATCH v2 1/3] x86/mce/amd: Fix bank lookup in amd_mce_usable_address() Yazen Ghannam
2026-11-24  1:39   ` [tip: x86/urgent] " tip-bot2 for Yazen Ghannam
2026-11-24  2:20   ` [PATCH v2 1/3] " Qiuxu (Leo) Zhuo
2026-11-23 23:27 ` [PATCH v2 2/3] x86/mce/amd: Convert bank_map to a bitmap Yazen Ghannam
2026-11-24  2:20   ` Qiuxu (Leo) Zhuo
2026-11-23 23:27 ` [PATCH v2 3/3] x86/mce: Increase MAX_NR_BANKS to 255 Yazen Ghannam
2026-11-24  2:10   ` Qiuxu (Leo) Zhuo
2026-11-24 14:42     ` Yazen Ghannam [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124144223.GA2156781@yaz-khff2.amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qzhuo@nvidia.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®