mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] sched: Remove a preempt-disable section in rt_mutex_setprio()
@ 2025-06-10 14:47 Sebastian Andrzej Siewior
  2025-06-11  9:03 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2025-06-10 14:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ben Segall, Dietmar Eggemann, Ingo Molnar, Juri Lelli,
	Mel Gorman, Peter Zijlstra, Steven Rostedt, Thomas Gleinxer,
	Valentin Schneider, Vincent Guittot

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 4c9a4bc89a9cc ("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>
---

v1…v2: https://lore.kernel.org/all/20250513142954.ZM5QSQNc@linutronix.de/
  - Repost without RFC

 kernel/sched/core.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index dce50fa57471d..362d8ab888748 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7292,14 +7292,10 @@ void rt_mutex_setprio(struct task_struct *p, struct task_struct *pi_task)
 
 	check_class_changed(rq, p, prev_class, oldprio);
 out_unlock:
-	/* Avoid rq from going away on us: */
-	preempt_disable();
 
 	rq_unpin_lock(rq, &rf);
 	__balance_callbacks(rq);
 	raw_spin_rq_unlock(rq);
-
-	preempt_enable();
 }
 #endif
 
-- 
2.49.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-06-11 14:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-10 14:47 [PATCH v2] sched: Remove a preempt-disable section in rt_mutex_setprio() Sebastian Andrzej Siewior
2025-06-11  9:03 ` Peter Zijlstra
2025-06-11  9:54   ` [PATCH v3] " Sebastian Andrzej Siewior
2025-06-11 14:14   ` [PATCH v2] " Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®