[RFC PATCH v3 00/19] arm_mpam: Add L2 cache monitors

From: Jinjie Ruan

Date: Mon Nov 16 2026 - 07:59:51 EST


Resctrl exposes cache occupancy and bandwidth monitoring only at the L3
scope. MPAM can count the same things on an L2 cache: firmware points
an MSC at the cache it belongs to, and its CSU and MBWU counters can
report the occupancy of that L2 slice and the traffic the cache sees.

This series first reworks resctrl's monitor bookkeeping to track events
by scope instead of by resource, and then exposes those counters as
"l2c_occupancy" and "mbm_core_bytes"

The patch set is organized as follows:

- Patches 1-4: Rename to drop the L3 prefix
- Patches 5-7: Rework the bookkeeping, index monitor state by resource
and event, index the event table by scope and eventid
- Patches 8-13: Make the core per-resource and add the L2 events
- Patches 14-18: Let the driver pick L2 classes for the L2 resource,
and expose the L2 events
- Patch 19: Update the documentation

Notes on the user interface
===========================

The L3 event names and semantics, the L3_MON and mon_L3_xx names and
the x86 PERF_PKG files are unchanged.

The L2 bandwidth event is called mbm_core_bytes because it counts the
bytes the L2 cache sees, which is not memory bandwidth.

And mbm_L3_assignments remains L3-only.

Testing
=======

QEMU, topology with L2, L3 and memory-controller MSCs:

- info/L2_MON lists l2c_occupancy and mbm_core_bytes, and per-core
mon_L2_xx directories are created.

- Reads: l2c_occupancy 262144 bytes (50% of a 512KiB L2),
llc_occupancy unchanged, mbm_core_bytes advances about 20GB per 2s
sample.

- CDP halves num_closids and the monitor counts of every monitor
resource.

- RMID limbo: a freed RMID is marked busy in every L2 and L3 monitor
domain, and becomes allocatable again once those domains are
offlined and the busy count reaches zero.

QEMU branch: https://github.com/ruanjinjie-eng/qemu/tree/mpam
Test cases: https://github.com/ruanjinjie-eng/mpam_testcase

This series is rebased on v7.4 rc3 and also available at:
https://github.com/ruanjinjie-eng/linux/commits/mpam-l2mon-scope

Changes in RFC v3
- The event table is indexed by scope instead of by resource (Reinette)
- Patch 6 is split out so no helper takes an unused argument.
- The RMID limbo threshold is kept per resource, so an L3 domain no
longer compares its occupancy with an L2-sized value
- Bugfixes are split out as their own series.
- RFC v2: https://lore.kernel.org/all/20261029123611.1108424-1-ruanjinjie@xxxxxxxxxx/

Changes in RFC v2:
- As Ben suggested, the existing event types now apply to any resource,
instead of adding L2-only event IDs.
- As Ben suggested, L2 bandwidth uses an assignable counter that stays
with the monitoring group, not a monitor borrowed for each read.
- The CDP change also halves the assignable counter count, for every
monitor resource.
- Split by subsystem so resctrl, x86 and MPAM can be reviewed separately.
- Fix a CDP bug: a failed enable left the driver believing CDP was on.
- RFC v1: https://lore.kernel.org/all/20261022084821.4014873-1-ruanjinjie@xxxxxxxxxx/

Jinjie Ruan (19):
fs/resctrl: Rename monitor events to drop the L3 prefix
x86/resctrl: Use the resource-agnostic monitor event names
arm_mpam: resctrl: Use the resource-agnostic monitor event names
resctrl: Remove the L3 monitor event names
arm_mpam: resctrl: Index monitor state by resource and event
x86,fs/resctrl: Record the resource that enables a monitor event
x86,fs/resctrl: Track monitor events by scope
fs/resctrl: Generalize __l3_mon_event_count for non-L3 resources
fs/resctrl: Add the L2 monitor events
fs/resctrl: Set up MBM state and workers for every monitor resource
resctrl: Keep the RMID limbo threshold per resource
fs/resctrl: Check RMID limbo on every resource with occupancy
fs/resctrl: Manage assignable counters for every monitor resource
arm_mpam: resctrl: Halve the monitor counts of every resource on CDP
arm_mpam: resctrl: Look up the monitor domain id from the components
arm_mpam: resctrl: Report counter assignment per resource
arm_mpam: resctrl: Allow monitoring on resources other than the L3
arm_mpam: resctrl: Expose the L2 monitor events
Documentation: arm64: mpam: Describe the L2 monitor events

Documentation/arch/arm64/mpam.rst | 25 +-
Documentation/filesystems/resctrl.rst | 11 +
arch/x86/kernel/cpu/resctrl/core.c | 13 +-
arch/x86/kernel/cpu/resctrl/intel_aet.c | 2 +-
arch/x86/kernel/cpu/resctrl/internal.h | 2 +-
arch/x86/kernel/cpu/resctrl/monitor.c | 10 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 +-
drivers/resctrl/mpam_resctrl.c | 357 ++++++++++++++----------
fs/resctrl/ctrlmondata.c | 13 +-
fs/resctrl/internal.h | 55 +++-
fs/resctrl/monitor.c | 328 +++++++++++++---------
fs/resctrl/rdtgroup.c | 158 ++++++-----
include/linux/resctrl.h | 36 ++-
include/linux/resctrl_types.h | 16 +-
14 files changed, 619 insertions(+), 415 deletions(-)

--
2.34.1