[PATCH 08/18] sched: Introduce WF_ON_RQ wake flag

From: Andrea Righi

Date: Mon Aug 31 2026 - 11:54:34 EST


ttwu_runnable() handles wakeups for tasks which are already on the
runqueue, but scheduling classes cannot distinguish that path from a
full wakeup activation in wakeup_preempt().

Pass WF_ON_RQ to wakeup_preempt() from ttwu_runnable() so scheduling
classes can handle already-runnable wakeups separately.

This is a preparatory change to support proxy execution with sched_ext.
No functional change.

Signed-off-by: Andrea Righi <arighi@xxxxxxxxxx>
---
kernel/sched/core.c | 2 +-
kernel/sched/sched.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index d578dd635f2eb..f142ab455b797 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3908,7 +3908,7 @@ static int ttwu_runnable(struct task_struct *p, int wake_flags)
* When on_rq && !on_cpu the task is preempted, see if
* it should preempt the task that is current now.
*/
- wakeup_preempt(rq, p, wake_flags);
+ wakeup_preempt(rq, p, wake_flags | WF_ON_RQ);
}
ttwu_do_wakeup(p);
return 1;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 56ac104f1f825..f30d122909e7b 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2538,6 +2538,7 @@ static inline int task_on_rq_migrating(struct task_struct *p)
#define WF_MIGRATED 0x20 /* Internal use, task got migrated */
#define WF_CURRENT_CPU 0x40 /* Prefer to move the wakee to the current CPU. */
#define WF_RQ_SELECTED 0x80 /* ->select_task_rq() was called */
+#define WF_ON_RQ 0x100 /* Wakeup of an already runnable task */

static_assert(WF_EXEC == SD_BALANCE_EXEC);
static_assert(WF_FORK == SD_BALANCE_FORK);
--
2.55.0