Re: [PATCH v2 16/45] arm_mpam: resctrl: Sort the order of the domain lists

Jonathan Cameron
2026-01-05T17:42:38Z

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

> From: James Morse <james.morse@arm.com>
>
> resctrl documents that the domains appear in numeric order in the schemata
> file. This means a little more work is needed when bringing a domain
> online.
>
> Add the support for this, using resctrl_find_domain() to find the point to
> insert in the list.
>
> Signed-off-by: James Morse <james.morse@arm.com>
> Signed-off-by: Ben Horgan <ben.horgan@arm.com>
I guess this was split out to try and make previous patch easier to read.
I'm not sure I'd bother in this particular case as those TODOs were
ugly, but anyhow LGTM

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>

> ---
> drivers/resctrl/mpam_resctrl.c | 21 +++++++++++++++++----
> 1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index 4beeeded00ff..5481d9cc69d9 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -117,6 +117,21 @@ static bool mpam_resctrl_offline_domain_hdr(unsigned int cpu,
> return false;
> }
>
> +static void mpam_resctrl_domain_insert(struct list_head *list,
> + struct rdt_domain_hdr *new)
> +{
> + struct rdt_domain_hdr *err;
> + struct list_head *pos = NULL;
> +
> + lockdep_assert_held(&domain_list_lock);
> +
> + err = resctrl_find_domain(list, new->id, &pos);
> + if (WARN_ON_ONCE(err))
> + return;
> +
> + list_add_tail_rcu(&new->list, pos);
> +}
> +
> static struct mpam_resctrl_dom *
> mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
> {
> @@ -154,8 +169,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
> ctrl_d = &dom->resctrl_ctrl_dom;
> mpam_resctrl_domain_hdr_init(cpu, ctrl_comp, &ctrl_d->hdr);
> ctrl_d->hdr.type = RESCTRL_CTRL_DOMAIN;
> - /* TODO: this list should be sorted */
> - list_add_tail_rcu(&ctrl_d->hdr.list, &r->ctrl_domains);
> + mpam_resctrl_domain_insert(&r->ctrl_domains, &ctrl_d->hdr);
> err = resctrl_online_ctrl_domain(r, ctrl_d);
> if (err) {
> dom = ERR_PTR(err);
> @@ -169,8 +183,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res)
> mon_d = &dom->resctrl_mon_dom;
> mpam_resctrl_domain_hdr_init(cpu, ctrl_comp, &mon_d->hdr);
> mon_d->hdr.type = RESCTRL_MON_DOMAIN;
> - /* TODO: this list should be sorted */
> - list_add_tail_rcu(&mon_d->hdr.list, &r->mon_domains);
> + mpam_resctrl_domain_insert(&r->mon_domains, &mon_d->hdr);
> err = resctrl_online_mon_domain(r, mon_d);
> if (err) {
> dom = ERR_PTR(err);