mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Swapnil Sapkal <swapnil.sapkal@amd.com>
To: <tony.luck@intel.com>, <reinette.chatre@intel.com>,
	<babu.moger@amd.com>, <fenghua.yu@intel.com>, <shuah@kernel.org>
Cc: <Dave.Martin@arm.com>, <james.morse@arm.com>,
	<peternewman@google.com>, <eranian@google.com>,
	<tan.shaopeng@fujitsu.com>, <linux-kernel@vger.kernel.org>,
	<linux-kselftest@vger.kernel.org>, <x86@kernel.org>,
	<swapnil.sapkal@amd.com>
Subject: [PATCH v6 0/5] selftests/resctrl: Add MBM and MBA test support for AMD
Date: Tue, 1 Dec 2026 08:34:21 +0000	[thread overview]
Message-ID: <20261201083426.26730-1-swapnil.sapkal@amd.com> (raw)

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@amd.com/

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


             reply	other threads:[~2026-12-01  8:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  8:34 Swapnil Sapkal [this message]
2026-12-01  8:34 ` [PATCH v6 1/5] selftests/resctrl: Rename variables and functions to generic names Swapnil Sapkal
2026-12-01  8:34 ` [PATCH v6 2/5] selftests/resctrl: Detect vendor to select memory controller sysfs name Swapnil Sapkal
2026-12-01  8:34 ` [PATCH v6 3/5] selftests/resctrl: Add support for MBM and MBA tests on AMD Swapnil Sapkal
2026-12-01  8:34 ` [PATCH v6 4/5] selftests/resctrl: Use bandwidth values for AMD MBA schemata Swapnil Sapkal
2026-12-01  8:34 ` [PATCH v6 5/5] selftests/resctrl: Enable MBM and MBA tests on AMD Swapnil Sapkal

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=20261201083426.26730-1-swapnil.sapkal@amd.com \
    --to=swapnil.sapkal@amd.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=eranian@google.com \
    --cc=fenghua.yu@intel.com \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=peternewman@google.com \
    --cc=reinette.chatre@intel.com \
    --cc=shuah@kernel.org \
    --cc=tan.shaopeng@fujitsu.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®