[RFC PATCH v3 18/19] arm_mpam: resctrl: Expose the L2 monitor events

From: Jinjie Ruan

Date: Mon Nov 16 2026 - 08:00:52 EST


mpam_resctrl_pick_counters() skips cache classes that are not the L3, so
the CSU and MBWU monitors of an L2 MSC are never used. Allow L2 cache
classes to supply the L2 resource, and let an L2 class with usable MBWU
counters become the L2 bandwidth event.

Check the traffic match before the topology match. An L2 class can never
match the L3 traffic, and topology_matches_l3() warns when a cache has no
online CPU, which is reachable for an L2 cache during boot.

The L3 checks describe where memory bandwidth is measured.
'mbm_core_bytes' is the number of bytes the L2 cache sees rather than the
memory bandwidth, and an L2 class has its own scope and domain ids, so
neither check is needed for it.

No function change for the L3.

Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
drivers/resctrl/mpam_resctrl.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 704383304f6b..ce16afcdc1b0 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1128,9 +1128,10 @@ static void mpam_resctrl_pick_counters(void)
guard(srcu)(&mpam_srcu);
list_for_each_entry_srcu(class, &mpam_classes, classes_list,
srcu_read_lock_held(&mpam_srcu)) {
- /* The name of the resource is L3... */
- if (class->type == MPAM_CLASS_CACHE && class->level != 3) {
- pr_debug("class %u is a cache but not the L3", class->level);
+ if (class->type == MPAM_CLASS_CACHE && class->level != 2 &&
+ class->level != 3) {
+ pr_debug("class %u is a cache but not L2 or L3",
+ class->level);
continue;
}

@@ -1150,13 +1151,22 @@ static void mpam_resctrl_pick_counters(void)
if (update_rmid_limits(class))
break;

- counter_update_class(RDT_RESOURCE_L3, QOS_OCCUP_EVENT_ID, class);
+ counter_update_class(mpam_class_rid(class),
+ QOS_OCCUP_EVENT_ID, class);
break;
default:
break;
}
}

+ if (class->type == MPAM_CLASS_CACHE && class->level == 2 &&
+ class_has_usable_mbwu(class)) {
+ pr_debug("class %u has usable MBWU for the L2 resource\n",
+ class->level);
+ counter_update_class(RDT_RESOURCE_L2, QOS_MBM_TOTAL_EVENT_ID, class);
+ continue;
+ }
+
if (class_has_usable_mbwu(class) &&
topology_matches_l3(class) &&
traffic_matches_l3(class)) {
--
2.34.1