[tip: sched/urgent] sched/mmcid: Remove pointless preempt guard
From: tip-bot2 for Thomas Gleixner
Date: Wed Mar 11 2026 - 07:05:28 EST
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: 7574ac6e49789ddee1b1be9b2afb42b4a1b4b1f4
Gitweb: https://git.kernel.org/tip/7574ac6e49789ddee1b1be9b2afb42b4a1b4b1f4
Author: Thomas Gleixner <tglx@xxxxxxxxxx>
AuthorDate: Tue, 10 Mar 2026 21:29:04 +01:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Wed, 11 Mar 2026 12:01:06 +01:00
sched/mmcid: Remove pointless preempt guard
This is a leftover from the early versions of this function where it could
be invoked without mm::mm_cid::lock held.
Remove it and add lockdep asserts instead.
Fixes: 653fda7ae73d ("sched/mmcid: Switch over to the new mechanism")
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Tested-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>
Link: https://patch.msgid.link/20260310202526.116363613@xxxxxxxxxx
---
kernel/sched/core.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ee59cd1..f56156f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -10684,6 +10684,8 @@ static void mm_cid_fixup_tasks_to_cpus(void)
static bool sched_mm_cid_add_user(struct task_struct *t, struct mm_struct *mm)
{
+ lockdep_assert_held(&mm->mm_cid.lock);
+
t->mm_cid.active = 1;
mm->mm_cid.users++;
return mm_update_max_cids(mm);
@@ -10736,12 +10738,12 @@ static void sched_mm_cid_fork(struct task_struct *t)
static bool sched_mm_cid_remove_user(struct task_struct *t)
{
+ lockdep_assert_held(&t->mm->mm_cid.lock);
+
t->mm_cid.active = 0;
- scoped_guard(preempt) {
- /* Clear the transition bit */
- t->mm_cid.cid = cid_from_transit_cid(t->mm_cid.cid);
- mm_unset_cid_on_task(t);
- }
+ /* Clear the transition bit */
+ t->mm_cid.cid = cid_from_transit_cid(t->mm_cid.cid);
+ mm_unset_cid_on_task(t);
t->mm->mm_cid.users--;
return mm_update_max_cids(t->mm);
}