[RFC PATCH v3 09/19] fs/resctrl: Add the L2 monitor events

Jinjie Ruan ruanjinjie at huawei.com
Mon Nov 16 04:59:04 PST 2026


MPAM monitors belong to a cache, and firmware says which level that
cache is. Add the L2 entries to the event table: l2c_occupancy for
occupancy and mbm_core_bytes for bandwidth. They have their own names
because an L2 counts the traffic the cache sees, not memory bandwidth.

Read the L2 events through the same per-domain path as the L3. The L2
has no domains to sum, so a read without a domain fails. The events only
show up once an architecture enables them; x86 never does.

Signed-off-by: Jinjie Ruan <ruanjinjie at huawei.com>
---
 fs/resctrl/monitor.c    | 12 +++++++++++-
 include/linux/resctrl.h |  2 +-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
index 7c392bd57eff..d72d53ba25c7 100644
--- a/fs/resctrl/monitor.c
+++ b/fs/resctrl/monitor.c
@@ -537,12 +537,18 @@ static int __l3_mon_event_count_sum(struct rdtgroup *rdtgrp, struct rmid_read *r
 static int __mon_event_count(struct rdtgroup *rdtgrp, struct rmid_read *rr)
 {
 	switch (rr->r->rid) {
+	case RDT_RESOURCE_L2:
 	case RDT_RESOURCE_L3:
 		WARN_ON_ONCE(rr->evt->any_cpu);
 		if (rr->hdr)
 			return __mon_event_count_one_domain(rdtgrp, rr);
-		else
+
+		/* Only the L3 has SNC domains to sum. */
+		if (rr->r->rid == RDT_RESOURCE_L3)
 			return __l3_mon_event_count_sum(rdtgrp, rr);
+
+		rr->err = -EINVAL;
+		return -EINVAL;
 	case RDT_RESOURCE_PERF_PKG: {
 		u64 tval = 0;
 
@@ -1030,6 +1036,10 @@ void free_rmid_lru_list(void)
  * when the entry has a name.
  */
 struct mon_evt mon_event_all[RESCTRL_MON_SCOPE_NUM][QOS_NUM_EVENTS] = {
+	[RESCTRL_MON_SCOPE_L2] = {
+		MON_EVENT(QOS_OCCUP_EVENT_ID,			"l2c_occupancy",	false),
+		MON_EVENT(QOS_MBM_TOTAL_EVENT_ID,		"mbm_core_bytes",	false),
+	},
 	[RESCTRL_MON_SCOPE_L3] = {
 		MON_EVENT(QOS_OCCUP_EVENT_ID,			"llc_occupancy",	false),
 		MON_EVENT(QOS_MBM_TOTAL_EVENT_ID,		"mbm_total_bytes",	false),
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 0a60372299c5..95ffff4c7925 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -180,7 +180,7 @@ struct mbm_cntr_cfg {
 };
 
 /**
- * struct rdt_l3_mon_domain - group of CPUs sharing RDT_RESOURCE_L3 monitoring
+ * struct rdt_l3_mon_domain - group of CPUs sharing L2 or L3 cache monitoring
  * @hdr:		common header for different domain types
  * @ci_id:		cache info id for this domain
  * @rmid_busy_llc:	bitmap of which limbo RMIDs are above threshold
-- 
2.34.1




More information about the linux-arm-kernel mailing list