[PATCH v10 09/15] arm_mpam: Add a helper to check a PARTID is in a CLOSID
From: Jinjie Ruan
Date: Mon Oct 19 2026 - 03:37:01 EST
From: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
match_closid() open codes the CDP special case that turns the task
PARTID into the CLOSID it belongs to. Move it into
resctrl_partid_in_closid(), so the question "does this PARTID belong to
this control group" is answered in one place.
No functional change.
Cc: James Morse <james.morse@xxxxxxx>
Cc: Ben Horgan <ben.horgan@xxxxxxx>
Cc: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Cc: Fenghua Yu <fenghuay@xxxxxxxxxx>
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
drivers/resctrl/mpam_resctrl.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index cf5db752aa35..332388a092ce 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -353,15 +353,21 @@ void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid)
mpam_set_task_partid_pmg(tsk, partid_d, partid_i, pmg_d, pmg_i);
}
+/* Does the request PARTID belong to this control group? */
+static bool resctrl_partid_in_closid(u16 partid, u32 closid)
+{
+ if (cdp_enabled)
+ partid >>= 1;
+
+ return partid == closid;
+}
+
bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid)
{
u64 regval = mpam_get_regval(tsk);
- u32 tsk_closid = FIELD_GET(MPAM0_EL1_PARTID_D, regval);
-
- if (cdp_enabled)
- tsk_closid >>= 1;
+ u32 tsk_partid = FIELD_GET(MPAM0_EL1_PARTID_D, regval);
- return tsk_closid == closid;
+ return resctrl_partid_in_closid(tsk_partid, closid);
}
/* The task's pmg is not unique, the partid must be considered too */
--
2.43.0