[PATCH v3 6/8] arm_mpam: resctrl: Require a component for each monitoring event

From: Reinette Chatre

Date: Mon Nov 09 2026 - 23:22:43 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>
Tested-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
Reviewed-by: Ben Horgan <ben.horgan@xxxxxxx>
---
Changes since RFC v2:
- Add Ben's Reviewed-by tag.
- Add Jinjie's Tested-by tag.
- Move ahead of "arm_mpam: resctrl: Give the monitoring domain its own
structure", which now contains a check that relies on this one.
---
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 db1df6e8d8c0..ca90b293b697 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1686,9 +1686,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.56.0