[PATCH 2/3] x86/mce/amd: Convert bank_map to a bitmap

From: Yazen Ghannam

Date: Thu Sep 03 2026 - 10:35:10 EST


The per-CPU bank_map records which banks had their block 0 prepared
during mce_amd_feature_init(). It is a u64, so BIT_ULL(bank) is
undefined once the bank number reaches 64. That caps the usable bank
count at 64 regardless of MAX_NR_BANKS.

mce_banks_t is the existing type for per-bank bitmaps. It is declared
with MAX_NR_BANKS bits, so it follows the macro instead of fixing a
width of its own. thr_intr_banks and dfr_intr_banks in this file
already use it.

Convert bank_map to mce_banks_t and use the bitmap helpers. This is
preparation for raising MAX_NR_BANKS.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
---
arch/x86/kernel/cpu/mce/amd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index e6542e00dc5a..598b71d54f41 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -263,7 +263,7 @@ static DEFINE_PER_CPU(struct threshold_bank **, threshold_banks);
* A list of the banks enabled on each logical CPU. Controls which respective
* descriptors to initialize later in mce_threshold_create_device().
*/
-static DEFINE_PER_CPU(u64, bank_map);
+static DEFINE_PER_CPU(mce_banks_t, bank_map);

static void amd_threshold_interrupt(void);
static void amd_deferred_error_interrupt(void);
@@ -572,7 +572,7 @@ static int prepare_threshold_block(unsigned int bank, unsigned int block, u32 ad
int new;

if (!block)
- per_cpu(bank_map, cpu) |= BIT_ULL(bank);
+ __set_bit(bank, per_cpu(bank_map, cpu));

memset(&b, 0, sizeof(b));
b.cpu = cpu;
@@ -1272,7 +1272,7 @@ void mce_threshold_create_device(unsigned int cpu)
return;

for (bank = 0; bank < numbanks; ++bank) {
- if (!(this_cpu_read(bank_map) & BIT_ULL(bank)))
+ if (!test_bit(bank, this_cpu_ptr(bank_map)))
continue;
if (threshold_create_bank(bp, cpu, bank)) {
__threshold_remove_device(bp);
--
2.43.0