From: Ben Horgan <ben.horgan@arm.com>
To: Reinette Chatre <reinette.chatre@intel.com>,
james.morse@arm.com, Dave.Martin@arm.com, fenghuay@nvidia.com,
ruanjinjie@huawei.com
Cc: tony.luck@intel.com, yu.c.chen@intel.com, babu.moger@amd.com,
fustini@kernel.org, tan.shaopeng@fujitsu.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, patches@lists.linux.dev
Subject: Re: [PATCH v3 5/8] arm_mpam: resctrl: Split control and monitoring domain setup into helpers
Date: Wed, 18 Nov 2026 17:08:48 +0000 [thread overview]
Message-ID: <4245d7c1-1607-41d4-98f8-2dceaf33593f@arm.com> (raw)
In-Reply-To: <3d67a3dddd76cdb9981d4d7e78d657c930eb2cb6.1794283825.git.reinette.chatre@intel.com>
Hi Reinette,
On 10/11/2026 04:19, Reinette Chatre wrote:
> mpam_resctrl_alloc_domain() allocates one structure that holds both the
> control domain and the monitoring domain of a resource. It sets up
> whichever of the two domains the resource supports, with the setup of
> both open coded in the function, and undoes the control domain if
> setting up the monitoring domain fails.
>
> Apart from the code that manages domains, every user of the structure
> accesses only one of its two domains, so the monitoring domain can be
> given a structure of its own. Doing so starts with separating its setup
> from that of the control domain.
>
> Move the setup of each domain into its own helper in preparation for
> giving the monitoring domain its own structure as part of supporting
> multiple controls per resource. Keep the allocation and the error
> handling in mpam_resctrl_alloc_domain() so that a failure to set up the
> monitoring domain still undoes the control domain.
>
> No functional change intended.
>
> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> Tested-by: Jinjie Ruan <ruanjinjie@huawei.com>
> Reviewed-by: Jinjie Ruan <ruanjinjie@huawei.com>
Looks good to me.
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
> ---
> Changes since RFC v2:
> - Add Jinjie's Reviewed-by tag.
> - Add Jinjie's Tested-by tag.
> ---
> drivers/resctrl/mpam_resctrl.c | 112 ++++++++++++++++++++-------------
> 1 file changed, 68 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index ec39f3909388..db1df6e8d8c0 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -1640,13 +1640,75 @@ static struct mpam_component *find_component(struct mpam_class *class, int cpu)
> return NULL;
> }
>
> +static int mpam_resctrl_setup_ctrl_domain(unsigned int cpu,
> + struct rdt_resource *r,
> + struct mpam_component *comp,
> + struct mpam_resctrl_dom *dom)
> +{
> + struct rdt_ctrl_domain *ctrl_d = &dom->resctrl_ctrl_dom;
> + int err;
> +
> + dom->ctrl_comp = comp;
> +
> + 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)
> + return err;
> +
> + mpam_resctrl_domain_insert(&r->ctrl_domains, &ctrl_d->hdr);
> +
> + return 0;
> +}
> +
> +static int mpam_resctrl_setup_mon_domain(unsigned int cpu,
> + struct rdt_resource *r,
> + struct mpam_resctrl_dom *dom)
> +{
> + struct rdt_l3_mon_domain *mon_d = &dom->resctrl_mon_dom;
> + struct mpam_component *any_mon_comp = NULL;
> + enum resctrl_event_id eventid;
> + struct mpam_resctrl_mon *mon;
> + int err;
> +
> + /*
> + * Even if the monitor domain is backed by a different
> + * component, the L3 component IDs need to be used... only
> + * there may be no ctrl_comp for the L3.
> + * Search each event's class list for a component with
> + * overlapping CPUs and set up the dom->mon_comp array.
> + */
> +
> + for_each_mpam_resctrl_mon(mon, eventid) {
> + struct mpam_component *mon_comp;
> +
> + if (!mon->class)
> + continue; // dummy resource
> +
> + mon_comp = find_component(mon->class, cpu);
> + dom->mon_comp[eventid] = mon_comp;
> + if (mon_comp)
> + any_mon_comp = mon_comp;
> + }
> + if (WARN_ON_ONCE(!any_mon_comp))
> + return -EFAULT;
> +
> + 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)
> + return err;
> +
> + mpam_resctrl_domain_insert(&r->mon_domains, &mon_d->hdr);
> +
> + return 0;
> +}
> +
> static void mpam_resctrl_alloc_domain(unsigned int cpu,
> struct mpam_resctrl_res *res)
> {
> int err;
> struct mpam_resctrl_dom *dom;
> - struct rdt_l3_mon_domain *mon_d;
> - struct rdt_ctrl_domain *ctrl_d;
> struct mpam_class *class = res->class;
> struct mpam_component *comp;
> struct rdt_resource *r = &res->resctrl_res;
> @@ -1663,55 +1725,17 @@ static void mpam_resctrl_alloc_domain(unsigned int cpu,
> return;
>
> if (r->alloc_capable) {
> - dom->ctrl_comp = comp;
> -
> - ctrl_d = &dom->resctrl_ctrl_dom;
> - 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);
> + err = mpam_resctrl_setup_ctrl_domain(cpu, r, comp, dom);
> if (err)
> goto free_domain;
> -
> - mpam_resctrl_domain_insert(&r->ctrl_domains, &ctrl_d->hdr);
> } else {
> pr_debug("Skipped control domain online - no controls\n");
> }
>
> if (r->mon_capable) {
> - struct mpam_component *any_mon_comp = NULL;
> - struct mpam_resctrl_mon *mon;
> - enum resctrl_event_id eventid;
> -
> - /*
> - * Even if the monitor domain is backed by a different
> - * component, the L3 component IDs need to be used... only
> - * there may be no ctrl_comp for the L3.
> - * Search each event's class list for a component with
> - * overlapping CPUs and set up the dom->mon_comp array.
> - */
> -
> - for_each_mpam_resctrl_mon(mon, eventid) {
> - struct mpam_component *mon_comp;
> -
> - if (!mon->class)
> - continue; // dummy resource
> -
> - mon_comp = find_component(mon->class, cpu);
> - dom->mon_comp[eventid] = mon_comp;
> - if (mon_comp)
> - any_mon_comp = mon_comp;
> - }
> - if (WARN_ON_ONCE(!any_mon_comp))
> - goto offline_ctrl_domain;
> -
> - 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);
> + err = mpam_resctrl_setup_mon_domain(cpu, r, dom);
> 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");
> }
> @@ -1720,8 +1744,8 @@ static void mpam_resctrl_alloc_domain(unsigned int cpu,
>
> offline_ctrl_domain:
> if (r->alloc_capable) {
> - mpam_resctrl_offline_domain_hdr(cpu, &ctrl_d->hdr);
> - resctrl_offline_ctrl_domain(r, ctrl_d);
> + mpam_resctrl_offline_domain_hdr(cpu, &dom->resctrl_ctrl_dom.hdr);
> + resctrl_offline_ctrl_domain(r, &dom->resctrl_ctrl_dom);
> }
> free_domain:
> kfree(dom);
next prev parent reply other threads:[~2026-11-18 17:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 4:19 [PATCH v3 0/8] arm_mpam: resctrl: Separate MPAM domains Reinette Chatre
2026-11-10 4:19 ` [PATCH v3 1/8] arm_mpam: resctrl: Add a helper to find the component counting an event Reinette Chatre
2026-11-18 16:28 ` Ben Horgan
2026-11-10 4:19 ` [PATCH v3 2/8] arm_mpam: resctrl: Use find_component() when allocating a domain Reinette Chatre
2026-11-18 16:46 ` Ben Horgan
2026-11-10 4:19 ` [PATCH v3 3/8] arm_mpam: resctrl: Rename ctrl_comp in mpam_resctrl_alloc_domain() Reinette Chatre
2026-11-10 4:19 ` [PATCH v3 4/8] arm_mpam: resctrl: Do not fail CPU online when domain setup fails Reinette Chatre
2026-11-18 17:01 ` Ben Horgan
2026-11-10 4:19 ` [PATCH v3 5/8] arm_mpam: resctrl: Split control and monitoring domain setup into helpers Reinette Chatre
2026-11-18 17:08 ` Ben Horgan [this message]
2026-11-10 4:19 ` [PATCH v3 6/8] arm_mpam: resctrl: Require a component for each monitoring event Reinette Chatre
2026-11-10 4:19 ` [PATCH v3 7/8] arm_mpam: resctrl: Give the monitoring domain its own structure Reinette Chatre
2026-11-10 4:19 ` [PATCH v3 8/8] arm_mpam: resctrl: Rename struct mpam_resctrl_dom to mpam_resctrl_ctrl_dom Reinette Chatre
2026-11-10 11:00 ` [PATCH v3 0/8] arm_mpam: resctrl: Separate MPAM domains Ben Horgan
2026-11-11 6:10 ` Shaopeng Tan (Fujitsu)
2026-11-11 18:35 ` Reinette Chatre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4245d7c1-1607-41d4-98f8-2dceaf33593f@arm.com \
--to=ben.horgan@arm.com \
--cc=Dave.Martin@arm.com \
--cc=babu.moger@amd.com \
--cc=fenghuay@nvidia.com \
--cc=fustini@kernel.org \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@lists.linux.dev \
--cc=reinette.chatre@intel.com \
--cc=ruanjinjie@huawei.com \
--cc=tan.shaopeng@fujitsu.com \
--cc=tony.luck@intel.com \
--cc=yu.c.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®