Skip to content

Commit dc43379

Browse files
xiaochenshensuryasaimadhu
authored andcommitted
x86/resctrl: Do not reconfigure exiting tasks
When writing a pid to file "tasks", a callback function move_myself() is queued to this task to be called when the task returns from kernel mode or exits. The purpose of move_myself() is to activate the newly assigned closid and/or rmid associated with this task. This activation is done by calling resctrl_sched_in() from move_myself(), the same function that is called when switching to this task. If this work is successfully queued but then the task enters PF_EXITING status (e.g., receiving signal SIGKILL, SIGTERM) prior to the execution of the callback move_myself(), move_myself() still calls resctrl_sched_in() since the task status is not currently considered. When a task is exiting, the data structure of the task itself will be freed soon. Calling resctrl_sched_in() to write the register that controls the task's resources is unnecessary and it implies extra performance overhead. Add check on task status in move_myself() and return immediately if the task is PF_EXITING. [ bp: Massage. ] Signed-off-by: Xiaochen Shen <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent b3a987b commit dc43379

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,15 @@ static void move_myself(struct callback_head *head)
532532
kfree(rdtgrp);
533533
}
534534

535+
if (unlikely(current->flags & PF_EXITING))
536+
goto out;
537+
535538
preempt_disable();
536539
/* update PQR_ASSOC MSR to make resource group go into effect */
537540
resctrl_sched_in();
538541
preempt_enable();
539542

543+
out:
540544
kfree(callback);
541545
}
542546

0 commit comments

Comments
 (0)