[PATCH v6 0/5] selftests/resctrl: Add MBM and MBA test support for AMD
From: Swapnil Sapkal
Date: Tue Dec 01 2026 - 03:35:26 EST
The MBM (Memory Bandwidth Monitoring) and MBA (Memory Bandwidth
Allocation) resctrl selftests validate the bandwidth numbers reported by
resctrl against the memory controller performance counters. Today this
only works on Intel, where the counters are the iMC (Integrated Memory
Controller) PMUs and the tests are gated behind an ARCH_INTEL vendor
check.
This series teaches the tests about the AMD UMC (Unified Memory
Controller) PMUs and enables MBM and MBA on AMD.
The work is done in a few steps:
1. Rename the Intel specific imc/IMC identifiers to the generic
mc/MC so the code can serve both vendors.
2. Detect the vendor and select the memory controller PMU sysfs name
accordingly, keeping the rest of the code generic.
3. Add the AMD UMC support. Unlike Intel, the UMC PMU does not expose
the CAS command events via sysfs, so the read event is programmed
directly (EventCode 0x0a, umask 0x1). All vendor detection is
contained in enumerate_mcs() and dispatched to per-vendor routines.
On AMD each UMC is a per-NUMA-node PMU that can only be opened from
a CPU on the same node, so UMCs that fail with -ENODEV are dropped
from the counter list and only the ones local to the benchmark are
measured.
4. Sweep the AMD MBA schemata using absolute bandwidth values (4 GB/s
to 40 GB/s) instead of percentages (10% to 100%).
5. Extend the vendor_specific gate of the tests to Intel and AMD so
they run on AMD as well, and stop the MBM test from writing a
hardcoded "100" as the unthrottled allocation.
Use of AI
---------
AI tooling (Claude) was used while preparing this series: to port the
original patches across the upstream resctrl_val.c refactors, to help
draft commit messages, and to review the changes. All of the resulting
code and changelogs were reviewed, corrected and tested by the authors,
who take full responsibility for the content.
Testing
-------
Tested on AMD Zen5 (multi-NUMA) and Intel systems; MBM and MBA tests
pass on both.
This series applies on top of the kselftest tree's "next" branch.
v5: https://lore.kernel.org/all/20261022132517.46805-1-swapnil.sapkal@xxxxxxx/
Changes since v5 (per-patch changelogs are below the '---' of each patch):
- Dropped the Assisted-by: tags (commit 1e035297ffda) in favour of the
statement above.
- Renamed UNCORE_IMC to INTEL_IMC.
- Drop memory controllers that cannot be opened (-ENODEV) from
mc_counters_list rather than carrying them with an invalid fd, which
removes the repeated open attempts and all the fd validity checks.
- Reworked the MBA sweep to be index based and bounded by NUM_OF_ALLOCS
(now a plain 10), which removes mba_alloc_max() and the
'allocation == 0' sentinel. With the sweep length no longer derived
from the per vendor constants, ALLOCATION_MAX and AMD_ALLOCATION_MAX
lost their last user and were dropped along with the build time
checks on them.
- Dropped the unrelated result-count check in check_results().
- Fixed the issue reported by Sashiko: the MBM test wrote a hardcoded
"100" to leave the bandwidth unthrottled, which throttled the
benchmark to 12.5 GB/s on AMD. The write is dropped entirely, since
the con_mon grp is created fresh for each test and already carries
the default (maximum) allocation.
Babu Moger (4):
selftests/resctrl: Rename variables and functions to generic names
selftests/resctrl: Detect vendor to select memory controller sysfs
name
selftests/resctrl: Add support for MBM and MBA tests on AMD
selftests/resctrl: Enable MBM and MBA tests on AMD
Swapnil Sapkal (1):
selftests/resctrl: Use bandwidth values for AMD MBA schemata
tools/testing/selftests/resctrl/mba_test.c | 94 +++--
tools/testing/selftests/resctrl/mbm_test.c | 41 +-
tools/testing/selftests/resctrl/resctrl.h | 6 +-
tools/testing/selftests/resctrl/resctrl_val.c | 377 +++++++++++-------
4 files changed, 314 insertions(+), 204 deletions(-)
--
2.43.0