Re: [RFC PATCH 24/38] arm_mpam: resctrl: Allow resctrl to allocate monitors

Jonathan Cameron
2025-12-18T13:49:59Z

On Fri, 5 Dec 2025 21:58:47 +0000
James Morse <james.morse@arm.com> wrote:

> When resctrl wants to read a domain's 'QOS_L3_OCCUP', it needs
> to allocate a monitor on the corresponding resource. Monitors are
> allocated by class instead of component.
>
> MBM monitors are much more complicated, if there are enough monitors,
> they will be pre-allocated and free-running. If ABMC is in use instead
> then 'some' are pre-allocated in a different way, and need assigning.
>
> Add helpers to allocate a CSU monitor. These helper return an out
> of range value for MBM counters.
>
> Allocating a montitor context is expected to block until hardware
> resources become available. This only makes sense for QOS_L3_OCCUP
> as unallocated MBM counters are losing data.
>
> Signed-off-by: James Morse <james.morse@arm.com>
> ---
> Since ABMC got merged it may be possible to remove the monitor alloc
> call for MBM counters from resctrl as this work is now done by ABMC's
> assign call.
> ---
> drivers/resctrl/mpam_internal.h | 14 ++++++-
> drivers/resctrl/mpam_resctrl.c | 68 +++++++++++++++++++++++++++++++++
> include/linux/arm_mpam.h | 4 ++
> 3 files changed, 85 insertions(+), 1 deletion(-)
>

> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index 22ad5dd3c383..a2b238d47117 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c

> +
> +void resctrl_arch_mon_ctx_free(struct rdt_resource *r,
> + enum resctrl_event_id evtid, void *arch_mon_ctx)
> +{
> + u32 mon_idx = *(u32 *)arch_mon_ctx;
> +
> + kfree(arch_mon_ctx);
> + arch_mon_ctx = NULL;

Why is this useful? Updating the local pointer copy which is not
used again. Maybe I need more coffee.

> +
> + resctrl_arch_mon_ctx_free_no_wait(evtid, mon_idx);
> +}