Re: [PATCH v5 26/41] arm_mpam: resctrl: Add monitor initialisation and domain boilerplate

Zeng Heng
2026-02-26T03:47:11Z

Hi Ben,

On 2026/2/25 1:57, Ben Horgan wrote:
> Add the boilerplate that tells resctrl about the mpam monitors that are
> available. resctrl expects all (non-telemetry) monitors to be on the L3 and
> so advertise them there and invent an L3 resctrl resource if required. The
> L3 cache itself has to exist as the cache ids are used as the domain
> ids.
>
> Bring the resctrl monitor domains online and offline based on the cpus
> they contain.
>
> Support for specific monitor types is left to later.
>
> Signed-off-by: Ben Horgan <ben.horgan@arm.com>
> ---
> New patch but mostly moved from the existing patches to
> separate the monitors from the controls and the boilerplate
> from the specific counters.
> Use l3->mon_capable in resctrl_arch_mon_capable() as
> resctrl_enable_mon_event() now returns a bool.
> ---
> drivers/resctrl/mpam_internal.h | 7 ++
> drivers/resctrl/mpam_resctrl.c | 142 +++++++++++++++++++++++++++++---
> 2 files changed, 139 insertions(+), 10 deletions(-)
>

[...]

> @@ -922,6 +1000,20 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
> } else {
> pr_debug("Skipped control domain online - no controls\n");
> }
> +
> + if (resctrl_arch_mon_capable()) {
> + mon_d = &dom->resctrl_mon_dom;
> + mpam_resctrl_domain_hdr_init(cpu, any_mon_comp, r->rid, &mon_d->hdr);
> + mon_d->hdr.type = RESCTRL_MON_DOMAIN;
> + err = resctrl_online_mon_domain(r, &mon_d->hdr);
> + if (err)
> + goto offline_ctrl_domain;
> +
> + mpam_resctrl_domain_insert(&r->mon_domains, &mon_d->hdr);
> + } else {
> + pr_debug("Skipped monitor domain online - no monitors\n");
> + }
> +
> return dom;
>

I noticed that resctrl_arch_mon_capable() only performs checks for L3
monitoring functionality. This leads to an issue on platforms that
include L2 monitoring capabilities, where the code incorrectly enters
this branch and triggers the following warning by
mpam_resctrl_domain_insert():

[ 22.867070] ------------[ cut here ]------------
[ 22.867073] WARNING: drivers/resctrl/mpam_resctrl.c:1495 at
mpam_resctrl_domain_insert+0x74/0x80, CPU#2: cpuhp/2/25
[ 29.376035] Modules linked in:
[ 29.379080] CPU: 2 UID: 0 PID: 25 Comm: cpuhp/2 Not tainted
7.0.0-rc1-g4288ec146462 #30 PREEMPT
[ 29.387853] Hardware name: To Be Filled By O.E.M. 183.0/To Be Filled
By O.E.M., BIOS 183.0 02/12/2026
[ 29.397058] pstate: 61400009 (nZCv daif +PAN -UAO -TCO +DIT -SSBS
BTYPE=--)
[ 29.404007] pc : mpam_resctrl_domain_insert+0x74/0x80
[ 29.409048] lr : mpam_resctrl_domain_insert+0x34/0x80
[ 29.414088] sp : ffff8000876abc60
...
[ 29.488625] Call trace:
[ 29.491060] mpam_resctrl_domain_insert+0x74/0x80 (P)
[ 29.496100] mpam_resctrl_online_cpu+0x2b4/0x428
[ 29.500706] mpam_cpu_online+0x274/0x298
[ 29.504618] cpuhp_invoke_callback+0x104/0x20c
[ 29.509052] cpuhp_thread_fun+0xa4/0x17c
[ 29.512963] smpboot_thread_fn+0x220/0x24c
[ 29.517048] kthread+0x120/0x12c
[ 29.520265] ret_from_fork+0x10/0x20
[ 29.523830] ---[ end trace 0000000000000000 ]---

To preserve the existing public interface of resctrl_arch_mon_capable(),
please consider the following approach:

diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 694ea8548a05..b06a89494ff0 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -1563,6 +1563,10 @@ mpam_resctrl_alloc_domain(unsigned int cpu,
struct mpam_resctrl_res *res)
if (resctrl_arch_mon_capable()) {
struct mpam_component *any_mon_comp;
struct mpam_resctrl_mon *mon;
enum resctrl_event_id eventid;

+ /* TODO: Only supports L3 monitor type currently. */
+ if (r->rid != RDT_RESOURCE_L3)
+ return dom;

Best regards,
Zeng Heng