Skip to content

Commit 22abd83

Browse files
Sebastian Andrzej Siewioringomolnar
authored andcommitted
sched/rt: Remove a preempt-disable section in rt_mutex_setprio()
rt_mutex_setprio() has only one caller: rt_mutex_adjust_prio(). It expects that task_struct::pi_lock and rt_mutex_base::wait_lock are held. Both locks are raw_spinlock_t and are acquired with disabled interrupts. Nevertheless rt_mutex_setprio() disables preemption while invoking __balance_callbacks() and raw_spin_rq_unlock(). Even if one of the balance callbacks unlocks the rq then it must not enable interrupts because rt_mutex_base::wait_lock is still locked. Therefore interrupts should remain disabled and disabling preemption is not needed. Commit 4c9a4bc ("sched: Allow balance callbacks for check_class_changed()") adds a preempt-disable section to rt_mutex_setprio() and __sched_setscheduler(). In __sched_setscheduler() the preemption is disabled before rq is unlocked and interrupts enabled but I don't see why it makes a difference in rt_mutex_setprio(). Remove the preempt_disable() section from rt_mutex_setprio(). Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://patch.msgid.link/20251127155529.t_sTatE4@linutronix.de
1 parent e38e529 commit 22abd83

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

kernel/sched/core.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7352,15 +7352,12 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task)
73527352
p->prio = prio;
73537353
}
73547354
out_unlock:
7355-
/* Avoid rq from going away on us: */
7356-
preempt_disable();
7355+
/* Caller holds task_struct::pi_lock, IRQs are still disabled */
73577356

73587357
rq_unpin_lock(rq, &rf);
73597358
__balance_callbacks(rq);
73607359
rq_repin_lock(rq, &rf);
73617360
__task_rq_unlock(rq, p, &rf);
7362-
7363-
preempt_enable();
73647361
}
73657362
#endif /* CONFIG_RT_MUTEXES */
73667363

0 commit comments

Comments
 (0)