The following commit has been merged into the sched/core branch of tip:
Commit-ID: 56e50ff567810db208cc37d9e17b8df044a9158c
Gitweb: https://git.kernel.org/tip/56e50ff567810db208cc37d9e17b8df044a9158c
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Tue, 26 May 2026 12:00:59 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 02 Jun 2026 12:26:10 +02:00
sched: Simplify ttwu_runnable()
Note that both proxy and delayed tasks have ->is_blocked set. Use this one
condition to guard both paths.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260526113322.714832584%40infradead.org
---
kernel/sched/core.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d579518..5a317f6 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3764,9 +3764,6 @@ static inline void proxy_reset_donor(struct rq *rq)
*/
static inline bool proxy_needs_return(struct rq *rq, struct task_struct *p)
{
- if (!p->is_blocked)
- return false;
-
/*
* Typically per __set_task_cpu(), task_cpu(p) == p->wake_cpu.
*
@@ -3875,10 +3872,12 @@ static int ttwu_runnable(struct task_struct *p, int wake_flags)
return 0;
update_rq_clock(rq);
- if (p->se.sched_delayed)
- enqueue_task(rq, p, ENQUEUE_NOCLOCK | ENQUEUE_DELAYED);
- if (proxy_needs_return(rq, p))
- return 0;
+ if (p->is_blocked) {
+ if (p->se.sched_delayed)
+ enqueue_task(rq, p, ENQUEUE_NOCLOCK | ENQUEUE_DELAYED);
+ if (proxy_needs_return(rq, p))
+ return 0;
+ }
if (!task_on_cpu(rq, p)) {
/*
* When on_rq && !on_cpu the task is preempted, see if