fs/resctrl: Fix CLOSID propagation when reparenting monitor groups
PATCH 1/1 fs/resctrl: Fix CLOSID propagation when reparenting monitor groups
Renaming a monitor group to move it below a different control group changes the CLOSID of every task in that monitor group. mongrp_reparent() updates rdtgrp->mon.parent and rdtgrp->closid before calling rdt_move_group_tasks() to propagate the new CLOSID to the tasks.
rdt_move_group_tasks() uses its first argument to identify the tasks to move. For a monitor group this is is_rmid_match(), which on MPAM compares both the PARTID and the PMG of the task with the parent control group's CLOSID and the monitor group's RMID. After rdtgrp->mon.parent and rdtgrp->closid have been updated, the match uses the new CLOSID, so no task in the monitor group matches and none is moved. The tasks keep the old PARTID and continue to use the old control group's allocation.
x86 matches on the RMID alone, so it is unaffected. Now only arm64 mpam affected.
Save the monitor group state before it is modified and use the saved state as the source of the task move. The updated group remains the destination, so matching tasks are moved to the new CLOSID and RMID.
--- fs/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/resctrl/rdtgroup.c +2 -1
@@ -4322,6 +4322,7 @@ static void mongrp_reparent(struct rdtgroup *rdtgrp, cpumask_var_t cpus) {struct rdtgroup *prdtgrp = rdtgrp->mon.parent; +struct rdtgroup old_rdtgrp = *rdtgrp;WARN_ON (rdtgrp->type !=RDTMON_GROUP );WARN_ON (new_prdtgrp->type !=RDTCTRL_GROUP );
@@ -4338,7 +4339,7 @@ static void mongrp_reparent(struct rdtgroup *rdtgrp, rdtgrp->closid = new_prdtgrp->closid;/* Propagate updated closid to all tasks in this group. */ -rdt_move_group_tasks (rdtgrp, rdtgrp, cpus); +rdt_move_group_tasks (&old_rdtgrp, rdtgrp, cpus);update_closid_rmid (cpus,NULL ); }
Signature · 1 line
2.43.0
Hi Jinjie,
Quoted 5 lines · Jinjie Ruan
Renaming a monitor group to move it below a different control group changes the CLOSID of every task in that monitor group.
mongrp_reparent()updatesrdtgrp->mon.parentandrdtgrp->closidbefore callingrdt_move_group_tasks()to propagate the new CLOSID to the tasks.
Quoted 7 lines
rdt_move_group_tasks()uses its first argument to identify the tasks to move. For a monitor group this isis_rmid_match(), which on MPAM compares both the PARTID and the PMG of the task with the parent control group's CLOSID and the monitor group's RMID. Afterrdtgrp->mon.parentandrdtgrp->closidhave been updated, the match uses the new CLOSID, so no task in the monitor group matches and none is moved. The tasks keep the old PARTID and continue to use the old control group's allocation.
Ah, that's pretty broken.
I was previously under the impression that moving monitor groups on MPAM systems was not permitted as the monitor bandwidth counters are required to be always running and so would glitch when moved. Peter Newman posted a patch in 2024 which added this restriction [1] but it didn't reach upstream. As, the moving of monitor groups is already broken for MPAM systems I think it would be ok to forbid them.
[1] https://lore.kernel.org/lkml/[email protected]/
Thanks,
Ben
Quoted 36 lines
x86 matches on the RMID alone, so it is unaffected. Now only arm64 mpam affected.
Save the monitor group state before it is modified and use the saved state as the source of the task move. The updated group remains the destination, so matching tasks are moved to the new CLOSID and RMID.
Fixes 8da2b938eb7e ("x86/resctrl: Implement rename op for mon groups")Signed-off-by Jinjie Ruan <[email protected]>Cc [email protected] # 7.1.x--- fs/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/resctrl/rdtgroup.c +2
-1@@ -4322,6 +4322,7 @@ static void mongrp_reparent(struct rdtgroup *rdtgrp, cpumask_var_t cpus) {struct rdtgroup *prdtgrp = rdtgrp->mon.parent; +struct rdtgroup old_rdtgrp = *rdtgrp;WARN_ON (rdtgrp->type !=RDTMON_GROUP );WARN_ON (new_prdtgrp->type !=RDTCTRL_GROUP );@@ -4338,7 +4339,7 @@ static void mongrp_reparent(struct rdtgroup *rdtgrp, rdtgrp->closid = new_prdtgrp->closid;/* Propagate updated closid to all tasks in this group. */ -rdt_move_group_tasks (rdtgrp, rdtgrp, cpus); +rdt_move_group_tasks (&old_rdtgrp, rdtgrp, cpus);update_closid_rmid (cpus,NULL ); }
Quoted 16 lines · Ben Horgan
Hi Jinjie,
Quoted 5 lines · Jinjie Ruan
Renaming a monitor group to move it below a different control group changes the CLOSID of every task in that monitor group.
mongrp_reparent()updatesrdtgrp->mon.parentandrdtgrp->closidbefore callingrdt_move_group_tasks()to propagate the new CLOSID to the tasks.Quoted 7 lines
rdt_move_group_tasks()uses its first argument to identify the tasks to move. For a monitor group this isis_rmid_match(), which on MPAM compares both the PARTID and the PMG of the task with the parent control group's CLOSID and the monitor group's RMID. Afterrdtgrp->mon.parentandrdtgrp->closidhave been updated, the match uses the new CLOSID, so no task in the monitor group matches and none is moved. The tasks keep the old PARTID and continue to use the old control group's allocation.
Quoted 1 line
Ah, that's pretty broken.
Hi Ben,
You are right! I found several issues about this with mpam.
Quoted 3 lines
I was previously under the impression that moving monitor groups on MPAM systems was not permitted as the monitor bandwidth counters are required to be always running and so would glitch when moved.
Got it. Then this operation should indeed be forbidden. Unfortunately, in practice it hasn't been forbidden yet.
Quoted 3 lines
Peter Newman posted a patch in 2024 which added this restriction [1] but it didn't reach upstream. As, the moving of monitor groups is already broken for MPAM systems I think it would be ok to forbid them.
Should I pick it up and rebased on v7.4-rc1 and send out it again?
Quoted 44 lines
[1] https://lore.kernel.org/lkml/[email protected]/
Thanks,
Ben
Quoted 36 lines
x86 matches on the RMID alone, so it is unaffected. Now only arm64 mpam affected.
Save the monitor group state before it is modified and use the saved state as the source of the task move. The updated group remains the destination, so matching tasks are moved to the new CLOSID and RMID.
Fixes 8da2b938eb7e ("x86/resctrl: Implement rename op for mon groups")Signed-off-by Jinjie Ruan <[email protected]>Cc [email protected] # 7.1.x--- fs/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/resctrl/rdtgroup.c +2
-1@@ -4322,6 +4322,7 @@ static void mongrp_reparent(struct rdtgroup *rdtgrp, cpumask_var_t cpus) {struct rdtgroup *prdtgrp = rdtgrp->mon.parent; +struct rdtgroup old_rdtgrp = *rdtgrp;WARN_ON (rdtgrp->type !=RDTMON_GROUP );WARN_ON (new_prdtgrp->type !=RDTCTRL_GROUP );@@ -4338,7 +4339,7 @@ static void mongrp_reparent(struct rdtgroup *rdtgrp, rdtgrp->closid = new_prdtgrp->closid;/* Propagate updated closid to all tasks in this group. */ -rdt_move_group_tasks (rdtgrp, rdtgrp, cpus); +rdt_move_group_tasks (&old_rdtgrp, rdtgrp, cpus);update_closid_rmid (cpus,NULL ); }
Signature · 2 lines
Best regards, Jinjie
Hi Jinjie,
Quoted 29 lines · Jinjie Ruan
Quoted 16 lines · Ben Horgan
Hi Jinjie,
Quoted 5 lines · Jinjie Ruan
Renaming a monitor group to move it below a different control group changes the CLOSID of every task in that monitor group.
mongrp_reparent()updatesrdtgrp->mon.parentandrdtgrp->closidbefore callingrdt_move_group_tasks()to propagate the new CLOSID to the tasks.Quoted 7 lines
rdt_move_group_tasks()uses its first argument to identify the tasks to move. For a monitor group this isis_rmid_match(), which on MPAM compares both the PARTID and the PMG of the task with the parent control group's CLOSID and the monitor group's RMID. Afterrdtgrp->mon.parentandrdtgrp->closidhave been updated, the match uses the new CLOSID, so no task in the monitor group matches and none is moved. The tasks keep the old PARTID and continue to use the old control group's allocation.Quoted 1 line
Ah, that's pretty broken.
Hi Ben,
You are right! I found several issues about this with mpam.
Quoted 3 lines
I was previously under the impression that moving monitor groups on MPAM systems was not permitted as the monitor bandwidth counters are required to be always running and so would glitch when moved.
Quoted 8 lines
Got it. Then this operation should indeed be forbidden. Unfortunately, in practice it hasn't been forbidden yet.
Quoted 3 lines
Peter Newman posted a patch in 2024 which added this restriction [1] but it didn't reach upstream. As, the moving of monitor groups is already broken for MPAM systems I think it would be ok to forbid them.
Should I pick it up and rebased on v7.4-rc1 and send out it again?
That makes sense to me. So, yes please.
Thanks,
Ben
Quoted 46 lines
Quoted 45 lines
[1] https://lore.kernel.org/lkml/[email protected]/
Thanks,
Ben
Quoted 36 lines
x86 matches on the RMID alone, so it is unaffected. Now only arm64 mpam affected.
Save the monitor group state before it is modified and use the saved state as the source of the task move. The updated group remains the destination, so matching tasks are moved to the new CLOSID and RMID.
Fixes 8da2b938eb7e ("x86/resctrl: Implement rename op for mon groups")Signed-off-by Jinjie Ruan <[email protected]>Cc [email protected] # 7.1.x--- fs/resctrl/rdtgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/resctrl/rdtgroup.c +2
-1@@ -4322,6 +4322,7 @@ static void mongrp_reparent(struct rdtgroup *rdtgrp, cpumask_var_t cpus) {struct rdtgroup *prdtgrp = rdtgrp->mon.parent; +struct rdtgroup old_rdtgrp = *rdtgrp;WARN_ON (rdtgrp->type !=RDTMON_GROUP );WARN_ON (new_prdtgrp->type !=RDTCTRL_GROUP );@@ -4338,7 +4339,7 @@ static void mongrp_reparent(struct rdtgroup *rdtgrp, rdtgrp->closid = new_prdtgrp->closid;/* Propagate updated closid to all tasks in this group. */ -rdt_move_group_tasks (rdtgrp, rdtgrp, cpus); +rdt_move_group_tasks (&old_rdtgrp, rdtgrp, cpus);update_closid_rmid (cpus,NULL ); }