[PATCH v8 next 03/10] arm_mpam: Disable reqPARTID expansion when Narrow-PARTID is unavailable

From: Zeng Heng

Date: Mon Apr 13 2026 - 05:02:05 EST


MPAM supports heterogeneous systems where some type of MSCs may implement
Narrow-PARTID while others do not. However, when an MSC uses
percentage-based throttling (non-bitmap partition control) and lacks
Narrow-PARTID support, resctrl cannot correctly apply control group
configurations across multiple PARTIDs.

To enable free assignment of multiple reqPARTIDs to resource control
groups, all MSCs used by resctrl must either: Implement Narrow-PARTID,
allowing explicit PARTID remapping, or only have stateless resource
controls (non-percentage-based), such that splitting a control group
across multiple PARTIDs does not affect behavior.

The detection occurs at initialization time on the first call to
get_num_reqpartid() from update_rmid_limits(). This call is guaranteed
to occur after mpam_resctrl_pick_{mba,caches}() have set up the
resource classes, ensuring the necessary properties are available
for the Narrow-PARTID capability check.

When an MSC with percentage-based control lacks Narrow-PARTID support,
get_num_reqpartid() falls back to returning the number of intPARTIDs,
effectively disabling the reqPARTID expansion for monitoring groups.

Signed-off-by: Zeng Heng <zengheng4@xxxxxxxxxx>
---
drivers/resctrl/mpam_resctrl.c | 43 +++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 5f4364c8101a..56859f354efa 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -257,9 +257,50 @@ 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,caches}()
+ * have initialized the resource classes, as class properties are used
+ * to detect Narrow-PARTID support.
+ *
+ * The first call occurs in update_rmid_limits(), ensuring the
+ * prerequisite initialization is complete.
+ */
+static u32 get_num_reqpartid(void)
+{
+ struct mpam_resctrl_res *res;
+ struct mpam_props *cprops;
+ static bool first = true;
+ int rid;
+
+ if (first) {
+ for_each_mpam_resctrl_control(res, rid) {
+ if (!res->class)
+ continue;
+
+ cprops = &res->class->props;
+ if (mpam_has_feature(mpam_feat_partid_nrw, cprops))
+ continue;
+
+ if (mpam_has_feature(mpam_feat_mbw_max, cprops) ||
+ mpam_has_feature(mpam_feat_mbw_min, cprops) ||
+ mpam_has_feature(mpam_feat_cmax_cmax, cprops) ||
+ mpam_has_feature(mpam_feat_cmax_cmin, cprops)) {
+ mpam_partid_max = mpam_intpartid_max;
+ break;
+ }
+ }
+ }
+
+ 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