]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched/proxy: Remove PROXY_WAKING
authorK Prateek Nayak <kprateek.nayak@amd.com>
Tue, 26 May 2026 09:43:02 +0000 (11:43 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 2 Jun 2026 10:26:09 +0000 (12:26 +0200)
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.

Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260526113322.596522894%40infradead.org
include/linux/sched.h
kernel/locking/mutex.c
kernel/locking/ww_mutex.h
kernel/sched/core.c

index e2f127a7ca0d3e379f2a5581bb4ff9c5003513cb..35e6183ef61564ab17f8fd74e92f078df2dc7449 100644 (file)
@@ -2205,19 +2205,10 @@ extern int __cond_resched_rwlock_write(rwlock_t *lock) __must_hold(lock);
 
 #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)
@@ -2245,7 +2236,7 @@ static inline void __clear_task_blocked_on(struct task_struct *p, struct mutex *
         * 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;
 }
 
@@ -2254,35 +2245,6 @@ static inline void clear_task_blocked_on(struct task_struct *p, struct mutex *m)
        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)
 {
@@ -2291,14 +2253,6 @@ static inline void __clear_task_blocked_on(struct task_struct *p, struct rt_mute
 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)
index 28677165785f754b0f60dd94fb2d017a24f00bb1..89d01f7889736b8fbcfe7aab0d1239a7230579ca 100644 (file)
@@ -1044,7 +1044,7 @@ static noinline void __sched __mutex_unlock_slowpath(struct mutex *lock, unsigne
                        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);
@@ -1060,7 +1060,7 @@ static noinline void __sched __mutex_unlock_slowpath(struct mutex *lock, unsigne
 
                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);
 
        }
index 6c12452097e1188da19465b3b7f6780c58b851a1..d62b49b53ec3f805e28cdb1b3dbbf19ee57078d6 100644 (file)
@@ -324,7 +324,7 @@ __ww_mutex_die(struct MUTEX *lock, struct MUTEX_WAITER *waiter,
                 * 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 MUTEX *lock,
                         * 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;
index 9b710313dfb34b5999ab7e0eee251b1dd93b5e15..cec2c164fab17bf0fa524a5cc0e584324095027e 100644 (file)
@@ -6872,7 +6872,7 @@ find_proxy_task(struct rq *rq, struct task_struct *donor, struct rq_flags *rf)
        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;