Skip to content

Commit b1b9a9d

Browse files
committed
Merge tag 'sched-urgent-2026-03-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fix from Ingo Molnar: "Fix a DL scheduler bug that may corrupt internal metrics during PI and setscheduler() syscalls, resulting in kernel warnings and misbehavior. Found during stress-testing" * tag 'sched-urgent-2026-03-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/deadline: Fix missing ENQUEUE_REPLENISH during PI de-boosting
2 parents 1954c4f + d658686 commit b1b9a9d

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

kernel/sched/syscalls.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,35 @@ static bool check_same_owner(struct task_struct *p)
284284
uid_eq(cred->euid, pcred->uid));
285285
}
286286

287+
#ifdef CONFIG_RT_MUTEXES
288+
static inline void __setscheduler_dl_pi(int newprio, int policy,
289+
struct task_struct *p,
290+
struct sched_change_ctx *scope)
291+
{
292+
/*
293+
* In case a DEADLINE task (either proper or boosted) gets
294+
* setscheduled to a lower priority class, check if it neeeds to
295+
* inherit parameters from a potential pi_task. In that case make
296+
* sure replenishment happens with the next enqueue.
297+
*/
298+
299+
if (dl_prio(newprio) && !dl_policy(policy)) {
300+
struct task_struct *pi_task = rt_mutex_get_top_task(p);
301+
302+
if (pi_task) {
303+
p->dl.pi_se = pi_task->dl.pi_se;
304+
scope->flags |= ENQUEUE_REPLENISH;
305+
}
306+
}
307+
}
308+
#else /* !CONFIG_RT_MUTEXES */
309+
static inline void __setscheduler_dl_pi(int newprio, int policy,
310+
struct task_struct *p,
311+
struct sched_change_ctx *scope)
312+
{
313+
}
314+
#endif /* !CONFIG_RT_MUTEXES */
315+
287316
#ifdef CONFIG_UCLAMP_TASK
288317

289318
static int uclamp_validate(struct task_struct *p,
@@ -655,6 +684,7 @@ int __sched_setscheduler(struct task_struct *p,
655684
__setscheduler_params(p, attr);
656685
p->sched_class = next_class;
657686
p->prio = newprio;
687+
__setscheduler_dl_pi(newprio, policy, p, scope);
658688
}
659689
__setscheduler_uclamp(p, attr);
660690

0 commit comments

Comments
 (0)