[RFC PATCH v2 08/10] arm_mpam: resctrl: Require a component for each monitoring event
From: Reinette Chatre
Date: Mon Oct 19 2026 - 18:08:23 EST
Setting up a monitoring domain looks up, for each monitoring event, the
component of the event's class that contains the CPU and records it in
the domain. Reading and resetting the event's counters in the domain
then use the recorded component.
If an event's class has no component for the CPU, the domain is still
set up as long as another event's class has one, and the event is left
without a component. Reading or resetting the event's counters in that
domain then dereferences a NULL component. This is not expected to
happen since only classes that cover all possible CPUs are picked for
monitoring.
Fail setting up the monitoring domain, with a warning, if an event's
class has no component for the CPU, so that every event of a monitoring
domain has a component.
Keep the check that at least one component was found. It now only fails
if no event has a class, and so captures that a resource that supports
monitoring has at least one monitoring event with a class.
Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
---
drivers/resctrl/mpam_resctrl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 63c5bf45856d..36a924734484 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1661,9 +1661,11 @@ static int mpam_resctrl_setup_mon_domain(unsigned int cpu,
continue; // dummy resource
mon_comp = find_component(mon->class, cpu);
+ if (WARN_ON_ONCE(!mon_comp))
+ return -EFAULT;
+
dom->mon_comp[eventid] = mon_comp;
- if (mon_comp)
- any_mon_comp = mon_comp;
+ any_mon_comp = mon_comp;
}
if (WARN_ON_ONCE(!any_mon_comp))
return -EFAULT;
--
2.55.0