[PATCH] arm_mpam: Round the CDP RMID count down to whole CLOSIDs

Jinjie Ruan ruanjinjie at huawei.com
Wed Nov 4 02:16:22 PST 2026


resctrl_arch_set_cdp_enabled() halves the whole RMID index space, while
the resctrl core halves the CLOSID count: schemata_list_add() divides a
CDP resource's schema by two, and closid_init() takes the smallest
across the schemata.

When the PMG count and the CLOSID count are both odd, halving the
product counts RMIDs that belong to a CLOSID resctrl never allocates.
With 3 PMGs and 5 CLOSIDs MPAM reports 7 RMIDs, but the 2 CLOSIDs that
resctrl has times 3 PMGs only allow 6. The count is visible in
/sys/fs/resctrl/info/L3_MON/num_rmids, so userspace reads a value that
includes RMIDs no CLOSID can use; RMID allocation itself is bounded by
the free list.

Derive the number of RMID groups from the index space and halve that, so
the count follows resctrl_arch_system_num_rmid_idx().

Fixes: 264c285999fc ("arm_mpam: resctrl: Add monitor initialisation and domain boilerplate")
Signed-off-by: Jinjie Ruan <ruanjinjie at huawei.com>
Cc: <stable at vger.kernel.org> # 7.1.x
Cc: James Morse <james.morse at arm.com>
Cc: Ben Horgan <ben.horgan at arm.com>
Cc: Reinette Chatre <reinette.chatre at intel.com>
Cc: Fenghua Yu <fenghuay at nvidia.com>
---
 drivers/resctrl/mpam_resctrl.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 5468367776e2..d3f957162b68 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -217,10 +217,16 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable)
 	cdp_enabled = enable;
 	mpam_resctrl_controls[rid].cdp_enabled = enable;
 
-	if (enable)
-		l3->mon.num_rmid = resctrl_arch_system_num_rmid_idx() / 2;
-	else
+	if (enable) {
+		u32 num_group;
+
+		/* Halve the number of RMID groups, keeping whole PMG rows. */
+		num_group = resctrl_arch_system_num_rmid_idx() /
+			    (mpam_pmg_max + 1);
+		l3->mon.num_rmid = (mpam_pmg_max + 1) * (num_group / 2);
+	} else {
 		l3->mon.num_rmid = resctrl_arch_system_num_rmid_idx();
+	}
 
 	/* The mbw_max feature can't hide cdp as it's a per-partid maximum. */
 	if (cdp_enabled && !mpam_resctrl_controls[RDT_RESOURCE_MBA].cdp_enabled)
-- 
2.34.1




More information about the linux-arm-kernel mailing list