Skip to content

Commit a0195f3

Browse files
Fenghua Yusuryasaimadhu
authored andcommitted
x86/resctrl: Don't move a task to the same resource group
Shakeel Butt reported in [1] that a user can request a task to be moved to a resource group even if the task is already in the group. It just wastes time to do the move operation which could be costly to send IPI to a different CPU. Add a sanity check to ensure that the move operation only happens when the task is not already in the resource group. [1] https://lore.kernel.org/lkml/CALvZod7E9zzHwenzf7objzGKsdBmVwTgEJ0nPgs0LUFU3SN5Pw@mail.gmail.com/ Fixes: e02737d ("x86/intel_rdt: Add tasks files") Reported-by: Shakeel Butt <[email protected]> Signed-off-by: Fenghua Yu <[email protected]> Signed-off-by: Reinette Chatre <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Tony Luck <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/962ede65d8e95be793cb61102cca37f7bb018e66.1608243147.git.reinette.chatre@intel.com
1 parent ae28d1a commit a0195f3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,13 @@ static void update_task_closid_rmid(struct task_struct *t)
546546
static int __rdtgroup_move_task(struct task_struct *tsk,
547547
struct rdtgroup *rdtgrp)
548548
{
549+
/* If the task is already in rdtgrp, no need to move the task. */
550+
if ((rdtgrp->type == RDTCTRL_GROUP && tsk->closid == rdtgrp->closid &&
551+
tsk->rmid == rdtgrp->mon.rmid) ||
552+
(rdtgrp->type == RDTMON_GROUP && tsk->rmid == rdtgrp->mon.rmid &&
553+
tsk->closid == rdtgrp->mon.parent->closid))
554+
return 0;
555+
549556
/*
550557
* Set the task's closid/rmid before the PQR_ASSOC MSR can be
551558
* updated by them.

0 commit comments

Comments
 (0)