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

From: Zeng Heng

Date: Mon Apr 13 2026 - 05:19:50 EST


Hi Shaopeng,

On 2026/4/11 14:50, Zeng Heng wrote:


On 2026/4/10 9:07, Shaopeng Tan (Fujitsu) wrote:
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?


"In order to be able to assign multiple reqPARTIDs freely to resource
control groups, it is necessary that all MSCs that are used by resctrl
either implement Narrow PARTID (so that PARTIDs can be remapped
explicitly) or otherwise only have controls whose resource regulation
is stateless and so whose behaviour would not be affected by splitting
a control group across multiple PARTIDs."



I've rewritten the commit message in an attempt to explain this more
clearly:
https://lore.kernel.org/all/20260413085405.1166412-4-zengheng4@xxxxxxxxxx/


Thanks for your review in advance,
Zeng Heng