[PATCH 5/6] sched/proxy: Remove PROXY_WAKING

From: Peter Zijlstra

Date: Tue May 26 2026 - 07:37:38 EST


From: K Prateek Nayak <kprateek.nayak@xxxxxxx>

Now that the proxy path uses ->is_blocked, use the '->is_blocked &&
!->blocked_on' state instead of PROXY_WAKING. Notably, this is where a
blocked_on relation is broken but the donor task might still need a return
migration.

(Not-yet-)Signed-off-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
include/linux/sched.h | 50 +---------------------------------------------
kernel/locking/mutex.c | 4 +--
kernel/locking/ww_mutex.h | 4 +--
kernel/sched/core.c | 13 ++++++++++-
4 files changed, 17 insertions(+), 54 deletions(-)

--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2202,19 +2202,10 @@ extern int __cond_resched_rwlock_write(r

#ifndef CONFIG_PREEMPT_RT

-/*
- * With proxy exec, if a task has been proxy-migrated, it may be a donor
- * on a cpu that it can't actually run on. Thus we need a special state
- * to denote that the task is being woken, but that it needs to be
- * evaluated for return-migration before it is run. So if the task is
- * blocked_on PROXY_WAKING, return migrate it before running it.
- */
-#define PROXY_WAKING ((struct mutex *)(-1L))
-
static inline struct mutex *__get_task_blocked_on(struct task_struct *p)
{
lockdep_assert_held_once(&p->blocked_lock);
- return p->blocked_on == PROXY_WAKING ? NULL : p->blocked_on;
+ return p->blocked_on;
}

static inline void __set_task_blocked_on(struct task_struct *p, struct mutex *m)
@@ -2242,7 +2233,7 @@ static inline void __clear_task_blocked_
* blocked_on relationships, but make sure we are not
* clearing the relationship with a different lock.
*/
- WARN_ON_ONCE(m && p->blocked_on && p->blocked_on != m && p->blocked_on != PROXY_WAKING);
+ WARN_ON_ONCE(m && p->blocked_on && p->blocked_on != m);
p->blocked_on = NULL;
}

@@ -2251,35 +2242,6 @@ static inline void clear_task_blocked_on
guard(raw_spinlock_irqsave)(&p->blocked_lock);
__clear_task_blocked_on(p, m);
}
-
-static inline void __set_task_blocked_on_waking(struct task_struct *p, struct mutex *m)
-{
- /* Currently we serialize blocked_on under the task::blocked_lock */
- lockdep_assert_held_once(&p->blocked_lock);
-
- if (!sched_proxy_exec()) {
- __clear_task_blocked_on(p, m);
- return;
- }
-
- /* Don't set PROXY_WAKING if blocked_on was already cleared */
- if (!p->blocked_on)
- return;
- /*
- * There may be cases where we set PROXY_WAKING on tasks that were
- * already set to waking, but make sure we are not changing
- * the relationship with a different lock.
- */
- WARN_ON_ONCE(m && p->blocked_on != m && p->blocked_on != PROXY_WAKING);
- p->blocked_on = PROXY_WAKING;
-}
-
-static inline void set_task_blocked_on_waking(struct task_struct *p, struct mutex *m)
-{
- guard(raw_spinlock_irqsave)(&p->blocked_lock);
- __set_task_blocked_on_waking(p, m);
-}
-
#else
static inline void __clear_task_blocked_on(struct task_struct *p, struct rt_mutex *m)
{
@@ -2288,14 +2250,6 @@ static inline void __clear_task_blocked_
static inline void clear_task_blocked_on(struct task_struct *p, struct rt_mutex *m)
{
}
-
-static inline void __set_task_blocked_on_waking(struct task_struct *p, struct rt_mutex *m)
-{
-}
-
-static inline void set_task_blocked_on_waking(struct task_struct *p, struct rt_mutex *m)
-{
-}
#endif /* !CONFIG_PREEMPT_RT */

static __always_inline bool need_resched(void)
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -1043,7 +1043,7 @@ static noinline void __sched __mutex_unl
next_lock = __get_task_blocked_on(donor);
if (next_lock == lock) {
next = get_task_struct(donor);
- __set_task_blocked_on_waking(donor, next_lock);
+ __clear_task_blocked_on(next, lock);
current->blocked_donor = NULL;
}
raw_spin_unlock(&donor->blocked_lock);
@@ -1059,7 +1059,7 @@ static noinline void __sched __mutex_unl

raw_spin_lock_nested(&next->blocked_lock, SINGLE_DEPTH_NESTING);
debug_mutex_wake_waiter(lock, waiter);
- __set_task_blocked_on_waking(next, lock);
+ __clear_task_blocked_on(next, lock);
raw_spin_unlock(&next->blocked_lock);

}
--- a/kernel/locking/ww_mutex.h
+++ b/kernel/locking/ww_mutex.h
@@ -324,7 +324,7 @@ __ww_mutex_die(struct MUTEX *lock, struc
* blocked_on to PROXY_WAKING. Otherwise we can see
* circular blocked_on relationships that can't resolve.
*/
- set_task_blocked_on_waking(waiter->task, lock);
+ clear_task_blocked_on(waiter->task, lock);
wake_q_add(wake_q, waiter->task);
}

@@ -383,7 +383,7 @@ static bool __ww_mutex_wound(struct MUTE
* are waking the mutex owner, who may be currently
* blocked on a different mutex.
*/
- set_task_blocked_on_waking(owner, NULL);
+ clear_task_blocked_on(owner, NULL);
wake_q_add(wake_q, owner);
}
return true;
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6856,7 +6865,7 @@ find_proxy_task(struct rq *rq, struct ta
for (p = donor; p->is_blocked; p = owner) {
/* if its PROXY_WAKING, do return migration or run if current */
struct mutex *mutex = p->blocked_on;
- if (!mutex || mutex == PROXY_WAKING) {
+ if (!mutex) {
clear_task_blocked_on(p, mutex);
if (task_current(rq, p)) {
p->is_blocked = 0;