Skip to content

Commit 007d842

Browse files
Thomas GleixnerPeter Zijlstra
authored andcommitted
sched/mmcid: Drop per CPU CID immediately when switching to per task mode
When a exiting task initiates the switch from per CPU back to per task mode, it has already dropped its CID and marked itself inactive. But a leftover from an earlier iteration of the rework then reassigns the per CPU CID to the exiting task with the transition bit set. That's wrong as the task is already marked CID inactive, which means it is inconsistent state. It's harmless because the CID is marked in transit and therefore dropped back into the pool when the exiting task schedules out either through preemption or the final schedule(). Simply drop the per CPU CID when the exiting task triggered the transition. Fixes: fbd0e71 ("sched/mmcid: Provide CID ownership mode fixup functions") Signed-off-by: Thomas Gleixner <tglx@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://patch.msgid.link/20260201192835.032221009@kernel.org
1 parent 47ee94e commit 007d842

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

kernel/sched/core.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10727,8 +10727,14 @@ void sched_mm_cid_exit(struct task_struct *t)
1072710727
scoped_guard(raw_spinlock_irq, &mm->mm_cid.lock) {
1072810728
if (!__sched_mm_cid_exit(t))
1072910729
return;
10730-
/* Mode change required. Transfer currents CID */
10731-
mm_cid_transit_to_task(current, this_cpu_ptr(mm->mm_cid.pcpu));
10730+
/*
10731+
* Mode change. The task has the CID unset
10732+
* already. The CPU CID is still valid and
10733+
* does not have MM_CID_TRANSIT set as the
10734+
* mode change has just taken effect under
10735+
* mm::mm_cid::lock. Drop it.
10736+
*/
10737+
mm_drop_cid_on_cpu(mm, this_cpu_ptr(mm->mm_cid.pcpu));
1073210738
}
1073310739
mm_cid_fixup_cpus_to_tasks(mm);
1073410740
return;

0 commit comments

Comments
 (0)