[tip: sched/core] sched/proxy: Switch proxy to use p->is_blocked

tip-bot2 for Peter Zijlstra posted 1 patch 3 days, 11 hours ago
kernel/sched/core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
[tip: sched/core] sched/proxy: Switch proxy to use p->is_blocked
Posted by tip-bot2 for Peter Zijlstra 3 days, 11 hours ago
The following commit has been merged into the sched/core branch of tip:

Commit-ID:     be365ce2bc20b8970bed350f82c3b760256b6945
Gitweb:        https://git.kernel.org/tip/be365ce2bc20b8970bed350f82c3b760256b6945
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Tue, 26 May 2026 11:42:29 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 02 Jun 2026 12:26:09 +02:00

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 <kprateek.nayak@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260526113322.477954312%40infradead.org
---
 kernel/sched/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b007b65..9b71031 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);