Re: [RFC PATCH v2 02/10] arm_mpam: resctrl: Rename ctrl_comp in mpam_resctrl_alloc_domain()

From: Jinjie Ruan

Date: Fri Oct 23 2026 - 04:09:05 EST




在 2026/10/20 6:07, Reinette Chatre 写道:
> mpam_resctrl_alloc_domain() looks up the component of the resource's
> class that contains the CPU and fails the domain allocation if there is
> none. The component is held in a local variable named ctrl_comp and, when
> the resource supports allocation, it also backs the control domain.
>
> The lookup and its check apply to every resource, including one that
> supports only monitoring. For such a resource the component does not
> back a control domain, so the name ctrl_comp is misleading. The name also
> makes a comment in the same function ambiguous. The comment notes that
> there may be no ctrl_comp for the L3, which is true of the control
> domain's component but contradicts the local variable, which always
> refers to a component once the lookup succeeds.
>
> Rename the local variable to comp. Keep the ctrl_comp name for the
> control domain's reference to its component because it only ever refers
> to the component that backs the control domain. Leave the comment
> unchanged since it now unambiguously refers to that component.
>
> No functional change.
>
> Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
> ---
> drivers/resctrl/mpam_resctrl.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index 3d5f90f9f1f3..b07e5dd895dd 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -1623,14 +1623,14 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
> struct rdt_l3_mon_domain *mon_d;
> struct rdt_ctrl_domain *ctrl_d;
> struct mpam_class *class = res->class;
> - struct mpam_component *ctrl_comp;
> + struct mpam_component *comp;
> struct rdt_resource *r = &res->resctrl_res;

Reviewed-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>


>
> lockdep_assert_held(&domain_list_lock);
>
> - ctrl_comp = find_component(class, cpu);
> + comp = find_component(class, cpu);
> /* class has no component for this CPU */
> - if (WARN_ON_ONCE(!ctrl_comp))
> + if (WARN_ON_ONCE(!comp))
> return ERR_PTR(-EINVAL);
>
> dom = kzalloc_node(sizeof(*dom), GFP_KERNEL, cpu_to_node(cpu));
> @@ -1638,10 +1638,10 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
> return ERR_PTR(-ENOMEM);
>
> if (r->alloc_capable) {
> - dom->ctrl_comp = ctrl_comp;
> + dom->ctrl_comp = comp;
>
> ctrl_d = &dom->resctrl_ctrl_dom;
> - mpam_resctrl_domain_hdr_init(cpu, ctrl_comp, r->rid, &ctrl_d->hdr);
> + mpam_resctrl_domain_hdr_init(cpu, comp, r->rid, &ctrl_d->hdr);
> ctrl_d->hdr.type = RESCTRL_CTRL_DOMAIN;
> err = resctrl_online_ctrl_domain(r, ctrl_d);
> if (err)

--
Best regards,
Jinjie