RE: [PATCH v3 3/9] arm_mpam: Disable Narrow-PARTID when MBA lacks support

From: Shaopeng Tan (Fujitsu)

Date: Thu Apr 09 2026 - 21:07:59 EST


Hello Zeng Heng,

> MPAM supports mixed systems with MSCs that may or may not implement
> Narrow-PARTID. However, when the MBA MSC uses percentage-based
> throttling (non-bitmap partition control) and lacks Narrow-PARTID support,
> resctrl cannot correctly apply control group configurations across multiple
> PARTIDs.
>
> Since there is no straightforward way to program compatible control values in
> this scenario, disable Narrow-PARTID system-wide when detected. The
> detection occurs at initialization time on the first call to get_num_reqpartid()
> from mpam_resctrl_pick_counters(), which is guaranteed to occur after
> mpam_resctrl_pick_mba() has set up the MBA resource class.
>
> If MBA MSCs lack Narrow-PARTID support, get_num_reqpartid() falls back to
> returning the number of internal PARTIDs (mpam_intpartid_max).
>
> Signed-off-by: Zeng Heng <zengheng4@xxxxxxxxxx>
> ---
> drivers/resctrl/mpam_resctrl.c | 38
> +++++++++++++++++++++++++++++++++-
> 1 file changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
> index 222ea1d199e1..1b18c095cfce 100644
> --- a/drivers/resctrl/mpam_resctrl.c
> +++ b/drivers/resctrl/mpam_resctrl.c
> @@ -240,9 +240,45 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource
> *ignored)
> return mpam_intpartid_max + 1;
> }
>
> +/*
> + * Determine the effective number of PARTIDs available for resctrl.
> + *
> + * This function performs a one-time check to determine if
> +Narrow-PARTID
> + * can be used. It must be called after mpam_resctrl_pick_mba() has
> + * initialized the MBA resource, as the MBA class properties are used
> + * to detect Narrow-PARTID support.
> + *
> + * The first call occurs in mpam_resctrl_pick_counters(), ensuring the
> + * prerequisite initialization is complete.
> + */
> +static u32 get_num_reqpartid(void)
> +{
> + struct mpam_resctrl_res *res;
> + struct rdt_resource *r_mba;
> + struct mpam_props *cprops;
> + static bool first = true;
> +
> + if (first) {
> + r_mba = resctrl_arch_get_resource(RDT_RESOURCE_MBA);
> + res = container_of(r_mba, struct mpam_resctrl_res,
> resctrl_res);
> + if (!res->class)
> + goto out;
> +
> + /* If MBA MSCs lack Narrow-PARTID support, roll back. */
> + cprops = &res->class->props;
> + if (!mpam_has_feature(mpam_feat_partid_nrw, cprops))
> + mpam_partid_max = mpam_intpartid_max;

Isn't max reqpartid stored in mpam_partid_max? Why is a rollback necessary?

Best regards,
Shaopeng TAN

> + }
> +
> +out:
> + first = false;
> + return mpam_partid_max + 1;
> +}
> +
> u32 resctrl_arch_system_num_rmid_idx(void)
> {
> - return (mpam_pmg_max + 1) * (mpam_partid_max + 1);
> + return (mpam_pmg_max + 1) * get_num_reqpartid();
> }
>
> u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid)
> --
> 2.25.1
>