Re: [PATCH v2 18/45] arm_mpam: resctrl: Implement resctrl_arch_reset_all_ctrls()

Jonathan Cameron
2026-01-05T17:52:00Z

On Fri, 19 Dec 2025 18:11:20 +0000
Ben Horgan <ben.horgan@arm.com> wrote:

> From: James Morse <james.morse@arm.com>
>
> We already have a helper for resetting an mpam class and component. Hook
> it up to resctrl_arch_reset_all_ctrls() and the domain offline path.
>
> Signed-off-by: James Morse <james.morse@arm.com>
> Signed-off-by: Ben Horgan <ben.horgan@arm.com>
I left all the context as my one comment on this is I don't see a reason
to expose mpam_reset_class() Only the _locked() variant ever seems to be
used outside of mpam_devices.c

> ---
> drivers/resctrl/mpam_devices.c | 6 +++---
> drivers/resctrl/mpam_internal.h | 7 +++++++
> drivers/resctrl/mpam_resctrl.c | 15 +++++++++++++++
> 3 files changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
> index 303aacfcb9d6..4f5d908d02a9 100644
> --- a/drivers/resctrl/mpam_devices.c
> +++ b/drivers/resctrl/mpam_devices.c
> @@ -2544,7 +2544,7 @@ static void mpam_enable_once(void)
> mpam_partid_max + 1, mpam_pmg_max + 1);
> }
>
> -static void mpam_reset_component_locked(struct mpam_component *comp)
> +void mpam_reset_component_locked(struct mpam_component *comp)
> {
> struct mpam_vmsc *vmsc;
>
> @@ -2568,7 +2568,7 @@ static void mpam_reset_component_locked(struct mpam_component *comp)
> }
> }
>
> -static void mpam_reset_class_locked(struct mpam_class *class)
> +void mpam_reset_class_locked(struct mpam_class *class)
> {
> struct mpam_component *comp;
>
> @@ -2580,7 +2580,7 @@ static void mpam_reset_class_locked(struct mpam_class *class)
> mpam_reset_component_locked(comp);
> }
>
> -static void mpam_reset_class(struct mpam_class *class)
> +void mpam_reset_class(struct mpam_class *class)
> {
> cpus_read_lock();
> mpam_reset_class_locked(class);
> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
> index 554e4887ba81..b9a739abb101 100644
> --- a/drivers/resctrl/mpam_internal.h
> +++ b/drivers/resctrl/mpam_internal.h
> @@ -389,6 +389,13 @@ extern u8 mpam_pmg_max;
> void mpam_enable(struct work_struct *work);
> void mpam_disable(struct work_struct *work);
>
> +/* Reset all the RIS in a class, optionally while holding cpus_read_lock() */
> +void mpam_reset_class_locked(struct mpam_class *class);
> +void mpam_reset_class(struct mpam_class *class);

Not clear from this patch why we need to expose mpam_reset_class()

> +
> +/* Reset all the RIS in a component under cpus_read_lock() */
> +void mpam_reset_component_locked(struct mpam_component *comp);
> +
> int mpam_apply_config(struct mpam_component *comp, u16 partid,
> struct mpam_config *cfg);
>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index bc4f1c80eab5..d32e87002457 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -167,6 +167,19 @@ static int mpam_resctrl_pick_domain_id(int cpu, struct mpam_component *comp)
> return comp->comp_id;
> }
>
> +void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
> +{
> + struct mpam_resctrl_res *res;
> +
> + lockdep_assert_cpus_held();
> +
> + if (!mpam_is_enabled())
> + return;
> +
> + res = container_of(r, struct mpam_resctrl_res, resctrl_res);
> + mpam_reset_class_locked(res->class);
> +}
> +
> static void mpam_resctrl_domain_hdr_init(int cpu, struct mpam_component *comp,
> struct rdt_domain_hdr *hdr)
> {
> @@ -353,6 +366,8 @@ void mpam_resctrl_offline_cpu(unsigned int cpu)
>
> ctrl_dom_empty = true;
> if (exposed_alloc_capable) {
> + mpam_reset_component_locked(dom->ctrl_comp);
> +
> ctrl_d = &dom->resctrl_ctrl_dom;
> ctrl_dom_empty = mpam_resctrl_offline_domain_hdr(cpu, &ctrl_d->hdr);
> if (ctrl_dom_empty)