From: Peter Zijlstra Date: Tue, 26 May 2026 09:42:29 +0000 (+0200) Subject: sched/proxy: Switch proxy to use p->is_blocked X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=be365ce2bc20b8970bed350f82c3b760256b6945;p=thirdparty%2Flinux.git sched/proxy: Switch proxy to use p->is_blocked Rather than gate the proxy paths with p->blocked_on, use p->is_blocked. This opens up the state: '->is_blocked && !->blocked_on' for future use. Notably, only proxy and delayed tasks can be ->on_rq && ->is_blocked, and it is guaranteed that sched_class::pick_task() will never return a delayed task. Therefore any task returned from pick_next_task() that has ->is_blocked set, must be a proxy task. Suggested-by: K Prateek Nayak Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260526113322.477954312%40infradead.org --- diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b007b65d9c88f..9b710313dfb34 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3764,7 +3764,7 @@ static inline void proxy_reset_donor(struct rq *rq) */ static inline bool proxy_needs_return(struct rq *rq, struct task_struct *p) { - if (!task_is_blocked(p)) + if (!p->is_blocked) return false; /* @@ -6866,14 +6866,14 @@ find_proxy_task(struct rq *rq, struct task_struct *donor, struct rq_flags *rf) bool curr_in_chain = false; int this_cpu = cpu_of(rq); struct task_struct *p; - struct mutex *mutex; int owner_cpu; /* Follow blocked_on chain. */ - for (p = donor; (mutex = p->blocked_on); p = owner) { + for (p = donor; p->is_blocked; p = owner) { /* if its PROXY_WAKING, do return migration or run if current */ - if (mutex == PROXY_WAKING) { - clear_task_blocked_on(p, PROXY_WAKING); + struct mutex *mutex = p->blocked_on; + if (!mutex || mutex == PROXY_WAKING) { + clear_task_blocked_on(p, mutex); if (task_current(rq, p)) { p->is_blocked = 0; return p; @@ -7147,7 +7147,7 @@ pick_again: rq_set_donor(rq, next); next->blocked_donor = NULL; - if (unlikely(next->is_blocked && next->blocked_on)) { + if (unlikely(next->is_blocked)) { next = find_proxy_task(rq, next, &rf); if (!next) { zap_balance_callbacks(rq);