[RFC PATCH v2 18/19] arm_mpam: resctrl: Expose the L2 monitor events
From: Jinjie Ruan
Date: Thu Oct 29 2026 - 08:39:06 EST
Allow an L2 cache class to supply the CSU counters for l2c_occupancy and
the MBWU counters for mbm_core_bytes.
The L2 bandwidth event is a normal MBM event, so resctrl gives it a
counter for the life of the monitoring group. MBWU needs that: rewriting
the PARTID/PMG filter restarts the byte count, so the filter must stay
in place while traffic is counted. CSU occupancy is only a snapshot and
can still borrow a monitor for each read.
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
drivers/resctrl/mpam_resctrl.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index b9487f3c648d..62214557b673 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1123,9 +1123,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;
}
@@ -1145,7 +1146,10 @@ 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(class->level == 2 ?
+ RDT_RESOURCE_L2 :
+ RDT_RESOURCE_L3,
+ QOS_OCCUP_EVENT_ID, class);
break;
default:
break;
@@ -1169,6 +1173,14 @@ static void mpam_resctrl_pick_counters(void)
*/
counter_update_class(RDT_RESOURCE_L3, QOS_MBM_TOTAL_EVENT_ID, class);
}
+
+ 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);
+ }
}
}
--
2.34.1