[PATCH 00/12] fs/resctrl: Support mba_MBps on MPAM

From: Jinjie Ruan

Date: Sun Nov 29 2026 - 22:25:18 EST


Resctrl offers two ways to describe an MBA policy:

- The percentage interface writes a fraction of the maximum bandwidth
into the hardware control register.

- The MBA software controller (mounted with -o mba_MBps) takes an
absolute target in MiB/s and adjusts that percentage based on the
MBM counters sampled once per second.

A percentage alone is not enough for an absolute budget. The bandwidth
it corresponds to depends on the memory frequency, the channel count,
the number of threads generating traffic, the access pattern and the
traffic of other groups, and neither MPAM nor x86 reports the maximum
bandwidth in MiB/s. x86 has had the software controller since 2018;
MPAM has never been able to use it. This series makes mba_MBps work on
MPAM.

What this series does
=====================

MPAM refuses mba_MBps in two places:

- Its MBM counters are assignable, and supports_mba_mbps() refuses the
option when they are.
- Its maximum bandwidth control is a soft limit by default, which can't
hold a single requester down to the target.

MPAM also makes three generic defects in the controller reachable:
- With a 16-bit fraction min_bw rounds to 0%, so the estimate oscillates
and can divide by zero.
- A failed counter read is turned into a huge bandwidth.
- writing the control register sleeps while the worker holds the RCU
read lock.

The patch organization is as follows:

- Patch 1-4: Fix 3 bugs related to MPAM MBps.

- Patch 5: Fix MPAM so that adopting a configuration feature with its
reset value is programmed into the hardware.

- Patch 6: Add resctrl_arch_rmid_valid(), so that an architecture can
refuse the RMIDs resctrl would otherwise allocate, without
changing the rmid_idx space.

- Patch 7: Make the default counter assignment mode generally
available. (Ben)

- Patch 8-9: Refuse mba_MBps where only the soft limit is implemented.
And uses that to set MBW_MAX.HARDLIM while the controller
is enabled.

- Patch 10: Extract the counter assignment mode switch from the
mbm_assign_mode write path into a helper of its own.

- Patch 11: Allow mba_MBps with assignable counters: mounting switches
to default mode, and restores the mode when the umount. The
mode cannot be switched back while the controller is enabled.

- Patch 12: Add KUnit tests for the cap and the hard-limit merge.

On x86 the new hook is a no-op, and nothing else changes: the only
systems with assignable counters refuse the controller, as their MBA
is not linear.

Testing
=======

With the MPAM MSC model in QEMU:

- From a ~9600 MiB/s baseline, a 7000 MiB/s target converges to
~6945 MiB/s, and a 9000 MiB/s target to 8630-8770 MiB/s.
mbm_assign_mode shows [default] while the controller is enabled.

- Writing "default" to mbm_assign_mode on a plain mount caps the
groups: with 8 counters and 32 PARTIDs the numbers go from 32/32 to
8/8 CLOSIDs/RMIDs, and writing "mbm_event" restores 32/32. While the
software controller is enabled, writing "mbm_event" is refused, with
an explanation in last_cmd_status.

- A modelled MSC that implements only the soft limit refuses the
mba_MBps mount, while a plain mount succeeds.

- With 8 counters and 32 PARTIDs, an mba_MBps mount reports 8 CLOSIDs
and 8 RMIDs, 7 groups can be created, the 8th mkdir fails, and a
group with a 5000 MiB/s target is throttled.

- With 8 counters and 32 PARTIDs, a plain mount, an mba_MBps mount
and a plain mount again report 32/32, 8/8 and 32/32 CLOSIDs/RMIDs.
During the mba_MBps mount, mbm_assign_on_mkdir, available_mbm_cntrs
and mbm_L3_assignments fail with -EINVAL and an explanation in
last_cmd_status.

- With 4 PMGs and 64 counters, a plain mount reports 32 CLOSIDs and
128 RMIDs, an mba_MBps mount reports 32 and 64 and allows one
monitoring group per control group, and a plain mount after it
reports 32 and 128 again.

- The MPAM KUnit tests pass (including the new ones).

Kunpeng HIP12(32 CLOSIDs and 4 PMGs, 128 RMIDs):

- Baseline with no limit is ~82 GB/s:
- A 49 GB/s target converges to ~40 GB/s.
- MBW_MAX is written with HARDLIM (bit 31) set throughout.

- On a plain mount resctrl starts in mbm_event mode.

- With the software controller enabled the mode is pinned:
- An mba_MBps mount shows `[default]`.
- Writing `mbm_event` is refused, `last_cmd_status` reads
`Unsupported assign mode`.
- Writing `default` succeeds as already the current mode.
- `event_filter` under `info/L3_MON/event_configs` returns -EINVAL
with an explanation in `last_cmd_status`.
- `num_rmids` reports 128 in both modes, which is 4 PMGs x 32 CLOSIDs
either way.

Changes in v1:
- Drup RFC tag as the discussion has been quite clear.
- Make the default counter assignment mode generally available (Ben).
- Refuse switching to "mbm_event" while software controller is enabled.
- Switch the assignment mode from set_mba_sc() through the same path
as the mbm_assign_mode file, so that the policy lives in resctrl.
- Treat adopting a config feature as a change.
- Record only whether the hard limit is implemented.
- Make resctrl_find_cleanest_closid() skip a CLOSID whose allowed RMIDs
are all in limbo, and take a CLOSID with no RMID in limbo without
scanning the free list.
- Warn when there is only one bandwidth counter.
- Document default mode and capped num_closids/rmids during mba_MBps mount.
- Add KUnit tests.
- Reorder the patches to make it more cleaer.
- Rebase on v7.4-rc3.
- Link to RFC v2: https://lore.kernel.org/all/20261112131255.4043381-1-ruanjinjie@xxxxxxxxxx/

Changes in RFC v2
- Extract the step decision into a helper, with no behaviour change
- Use bw_gran instead of min_bw in the estimate
- Drop the warning when a monitor group gets no counter, as
the new cap makes it unreachable (Ben)
- While the controller is enabled, cap the CLOSID/RMID space to the
number of bandwidth counters (Ben)
- Link to RFC v1:
- https://lore.kernel.org/all/20261109132621.3862497-1-ruanjinjie01@xxxxxxxxx/
- https://lore.kernel.org/all/dc1398f4-b81c-4ad8-b706-df89a1622e6c@xxxxxxx/

Jinjie Ruan (12):
fs/resctrl: Do not update bandwidth from a failed counter read
fs/resctrl: Extract the software controller's step decision
fs/resctrl: Fix the step-up estimate of the MBA software controller
fs/resctrl: Take the CPU hotplug lock for software controller updates
arm_mpam: Treat adopting a config feature as a change
x86,fs/resctrl: Let the architecture refuse RMIDs
arm_mpam: resctrl: Support the default counter assignment mode
fs/resctrl: Reject mba_MBps when the maximum is only a soft limit
arm_mpam: Program the hard limit for the software controller
fs/resctrl: Extract the counter assignment mode switch
fs/resctrl: Allow mba_MBps with assignable MBM counters
arm_mpam: kunit: Test the capped groups and the hard limit

Documentation/filesystems/resctrl.rst | 16 ++-
arch/x86/include/asm/resctrl.h | 6 +
drivers/resctrl/mpam_devices.c | 53 ++++++--
drivers/resctrl/mpam_internal.h | 4 +
drivers/resctrl/mpam_resctrl.c | 157 ++++++++++++++++++---
drivers/resctrl/test_mpam_devices.c | 45 ++++++
drivers/resctrl/test_mpam_resctrl.c | 54 ++++++++
fs/resctrl/internal.h | 2 +
fs/resctrl/monitor.c | 188 ++++++++++++++++++--------
fs/resctrl/rdtgroup.c | 65 +++++++--
include/linux/arm_mpam.h | 2 +
include/linux/resctrl.h | 3 +
12 files changed, 490 insertions(+), 105 deletions(-)

--
2.34.1