[PATCH v4 04/26] sched: Let a task boosted by a deadline waiter change its policy

From: Mathieu Desnoyers

Date: Fri Nov 06 2026 - 20:45:36 EST


__sched_setscheduler() admits bandwidth for a change of or into
SCHED_DEADLINE: it calls sched_dl_overflow() where the new policy is
SCHED_DEADLINE or dl_task(p). dl_task() tests the priority, not the
policy: it holds for a task of another class boosted by a deadline waiter
blocked on an rt_mutex it holds. sched_dl_overflow() has no branch for a
change of such a task to another policy, which does not have the policy
to leave, and admits nothing: it returns -1, and the change fails with
EBUSY. sched_setscheduler() to SCHED_OTHER or SCHED_FIFO on the owner of
a priority-inheriting mutex fails while a deadline task waits on it, and
sysrq-n leaves the owner as it is.

Test the policy: a task of the class has it, and a boosted one has
nothing to admit or to leave. The deadline_bw_test selftest added later
in this series has the case, boosted_owner_policy.

Fixes: 332ac17ef5bf ("sched/deadline: Add bandwidth management for SCHED_DEADLINE tasks")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
---
kernel/sched/syscalls.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/syscalls.c b/kernel/sched/syscalls.c
index b8c036d03d6f..bdffe5452dc8 100644
--- a/kernel/sched/syscalls.c
+++ b/kernel/sched/syscalls.c
@@ -689,7 +689,9 @@ int __sched_setscheduler(struct task_struct *p,
* If setscheduling to SCHED_DEADLINE (or changing the parameters
* of a SCHED_DEADLINE task) we need to check if enough bandwidth
* is available. Last of the checks: nothing gives back the
- * bandwidth it reserves.
+ * bandwidth it reserves. A task boosted into the class by priority
+ * inheritance has nothing to admit nor to leave: the policy
+ * decides, not the priority.
*
* Nothing to admit for parameters that are kept
* (SCHED_FLAG_KEEP_PARAMS): they are the ones the task has, and
@@ -697,7 +699,8 @@ int __sched_setscheduler(struct task_struct *p,
* change of its own that landed in between would leave them stale.
*/
if (!(attr->sched_flags & SCHED_FLAG_KEEP_PARAMS) &&
- (dl_policy(policy) || dl_task(p)) && sched_dl_overflow(p, policy, attr)) {
+ (dl_policy(policy) || task_has_dl_policy(p)) &&
+ sched_dl_overflow(p, policy, attr)) {
retval = -EBUSY;
goto unlock;
}
--
2.47.3