[PATCH v34 12/14] sched/deadline: Try to handle dl bandwidth properly with proxy blocked-waiter activations
From: John Stultz
Date: Tue Dec 01 2026 - 22:53:46 EST
Andrea raised an interesting point that with the proxy-exec
sleeping owner enqueuing logic (added later in this series)
we could confuse the deadline bandwidth calculations.
The case is when a task blocked on a lock owned by a sleeping
owner is enqueued on that sleeping owner and off the runqueue,
then when the owner wakes up, we enqueue all the waiters onto
the same rq as the owner.
With earlier fixes in this series, we do now call
migrate_task_rq() when this occurs, but the migrate_task_rq_dl()
implementation will bail when task->__state != TASK_WAKING.
So following K Prateek and Juri's suggestion[1] soften this a
bit so that we catch the case where a is_blocked task which is
also !task_on_rq_migrating() is changing cpus. Fixing it before
we add the sleeping owner handling.
[1] https://lore.kernel.org/lkml/faec8c94-0837-430b-ba60-00fa4a8a5eb4@xxxxxxx/
Reported-by: Andrea Righi <arighi@xxxxxxxxxx>
Suggested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
Suggested-by: Juri Lelli <juri.lelli@xxxxxxxxxx>
Signed-off-by: John Stultz <jstultz@xxxxxxxxxx>
---
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: K Prateek Nayak <kprateek.nayak@xxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Juri Lelli <juri.lelli@xxxxxxxxxx>
Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>
Cc: Valentin Schneider <vschneid@xxxxxxxxxx>
Cc: Suleiman Souhlal <suleiman@xxxxxxxxxx>
Cc: Andrea Righi <arighi@xxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Metin Kaya <Metin.Kaya@xxxxxxx>
Cc: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Zimuzo Ezeozue <zezeozue@xxxxxxxxxx>
Cc: Waiman Long <longman@xxxxxxxxxx>
Cc: Boqun Feng <boqun.feng@xxxxxxxxx>
Cc: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
Cc: Joel Fernandes <joelagnelf@xxxxxxxxxx>
Cc: Qais Yousef <qyousef@xxxxxxxxxxx>
Cc: Xuewen Yan <xuewen.yan94@xxxxxxxxx>
Cc: kuyo chang <kuyo.chang@xxxxxxxxxxxx>
Cc: hupu <hupu.gm@xxxxxxxxx>
Cc: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
Cc: zhidao su (Xiaomi) <soolaugust@xxxxxxxxx>
Cc: Hui Su <sh_def@xxxxxxx>
Cc: Shubhang Kaushik (Ampere) <sh@xxxxxxxxxx>
Cc: kernel-team@xxxxxxxxxxx
---
kernel/sched/deadline.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index dfae08625342e..f444cf31089eb 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2656,8 +2656,20 @@ static void migrate_task_rq_dl(struct task_struct *p, int new_cpu __maybe_unused
{
struct rq_flags rf;
struct rq *rq;
+ bool proxy_blocked = false;
- if (READ_ONCE(p->__state) != TASK_WAKING)
+ /*
+ * With proxy-exec we may have woken a sleeping lock owner, and are
+ * activating the blocked waiters that were enqueued upon the owner.
+ * These tasks' are still blocked, and not TASK_WAKING, but we still
+ * need to handle the migration logic to keep the bw sane.
+ * So make sure we don't bail out early if we are is_blocked and
+ * !task_on_rq_migrating()
+ */
+ if (sched_proxy_exec() && READ_ONCE(p->is_blocked) && !task_on_rq_migrating(p))
+ proxy_blocked = true;
+
+ if (READ_ONCE(p->__state) != TASK_WAKING && !proxy_blocked)
return;
rq = task_rq(p);
--
2.56.1.911.g883d8bcb20-goog