[PATCH v2 39/45] arm_mpam: resctrl: Call resctrl_init() on platforms that can support resctrl
Jonathan Cameron
jonathan.cameron at huawei.com
Tue Jan 6 06:58:31 PST 2026
On Fri, 19 Dec 2025 18:11:41 +0000
Ben Horgan <ben.horgan at arm.com> wrote:
> From: James Morse <james.morse at arm.com>
>
> Now that MPAM links against resctrl, call resctrl_init() to register the
> filesystem and setup resctrl's structures.
>
> Signed-off-by: James Morse <james.morse at arm.com>
> Signed-off-by: Ben Horgan <ben.horgan at arm.com>
Just minor suggestions inline. I'm not sure the for loop macros
are worth doing but that particular pair of loops feel awfully familiar
at this point, so maybe.
Either way..
Reviewed-by: Jonathan Cameron <jonathan.cameron at huawei.com>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index 059148c38a38..bbb12b5dfd8c 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -1840,11 +1861,70 @@ int mpam_resctrl_setup(void)
> pr_warn("Number of PMG is not a power of 2! resctrl may misbehave");
> }
>
> - /* TODO: call resctrl_init() */
> + err = resctrl_init();
> + if (!err)
> + WRITE_ONCE(resctrl_enabled, true);
Trivial but I'd prefer the error path out of line.
if (err)
return err;
WRITE_ONCE(resctrl_enabled, true);
return 0;
>
> return err;
> }
> +
> +/*
> + * The driver is detaching an MSC from this class, if resctrl was using it,
> + * pull on resctrl_exit().
> + */
> +void mpam_resctrl_teardown_class(struct mpam_class *class)
> +{
> + int i;
> + struct mpam_resctrl_res *res;
> + struct mpam_resctrl_mon *mon;
> +
> + might_sleep();
> +
> + for (i = 0; i < RDT_NUM_RESOURCES; i++) {
There are enough iterators over these that I wonder
if it is worth some macros.
for_each_mpam_resctrl_control(res) {
}
and
for_each_mpam_resctrl_counter(mon) {
}
> + res = &mpam_resctrl_controls[i];
> + if (res->class == class) {
> + res->class = NULL;
> + break;
> + }
> + }
> + for (i = 0; i < QOS_NUM_EVENTS; i++) {
> + mon = &mpam_resctrl_counters[i];
> + if (mon->class == class) {
> + mon->class = NULL;
> +
> + mpam_resctrl_teardown_mon(mon, class);
> +
> + break;
> + }
> + }
> +}
> +
> static int __init __cacheinfo_ready(void)
> {
> cacheinfo_ready = true;
More information about the linux-arm-kernel
mailing list