[RESEND][PATCH v31 9/9] sched: Distinguish proxy activations from wakeups
John Stultz <[email protected]>
| Newsgroups | org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Andrea Righi <[email protected]> Sleeping-owner handling reactivates blocked waiters with wakeup enqueue semantics so scheduling classes can restore their runnable accounting. Unlike a normal wakeup, the waiter remains blocked and is only made runnable to donate its scheduling context. Add ENQUEUE_PROXY to identify this activation and set it alongside ENQUEUE_WAKEUP. Consume the internal marker in sched_ext and suppress SCX_ENQ_WAKEUP before invoking BPF so the activation can be handled as a blocked proxy donor. Signed-off-by: Andrea Righi <[email protected]> Signed-off-by: John Stultz <[email protected]> --- Cc: Joel Fernandes <[email protected]> Cc: Qais Yousef <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Vincent Guittot <[email protected]> Cc: Dietmar Eggemann <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Ben Segall <[email protected]> Cc: Zimuzo Ezeozue <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Will Deacon <[email protected]> Cc: Waiman Long <[email protected]> Cc: Boqun Feng <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Cc: Metin Kaya <[email protected]> Cc: Xuewen Yan <[email protected]> Cc: K Prateek Nayak <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Daniel Lezcano <[email protected]> Cc: Suleiman Souhlal <[email protected]> Cc: Andrea Righi <[email protected]> Cc: kuyo chang <[email protected]> Cc: hupu <[email protected]> Cc: [email protected] --- kernel/sched/core.c | 2 +- kernel/sched/ext/ext.c | 8 ++++++++ kernel/sched/sched.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d813a9c2f0c35..c54e9fedc9cd8 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3900,7 +3900,7 @@ static void activate_blocked_waiters(struct rq *target_rq, { struct list_head bal_head; unsigned long flags; - int en_flags = ENQUEUE_WAKEUP | ENQUEUE_NOCLOCK; + int en_flags = ENQUEUE_WAKEUP | ENQUEUE_NOCLOCK | ENQUEUE_PROXY; if (!sched_proxy_exec()) return; diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c index e3fa7b2fac9df..834c8b6dae6c9 100644 --- a/kernel/sched/ext/ext.c +++ b/kernel/sched/ext/ext.c @@ -2021,6 +2021,14 @@ static void enqueue_task_scx(struct rq *rq, struct task_struct *p, int core_enq_ int sticky_cpu = p->scx.sticky_cpu; u64 enq_flags = core_enq_flags | rq->scx.extra_enq_flags; + /* + * Sleeping-owner activation uses wakeup semantics for the core + * scheduling classes, but the donor remains blocked. Expose it to BPF + * as a blocked-donor admission rather than a full wakeup. + */ + if (core_enq_flags & ENQUEUE_PROXY) + enq_flags &= ~(ENQUEUE_PROXY | SCX_ENQ_WAKEUP); + if (enq_flags & ENQUEUE_WAKEUP) rq->scx.flags |= SCX_RQ_IN_WAKEUP; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 56d9c09c485e6..e38988574cfa2 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2540,6 +2540,7 @@ extern const u32 sched_prio_to_wmult[40]; * ENQUEUE_REPLENISH - CBS (replenish runtime and postpone deadline) * ENQUEUE_MIGRATED - the task was migrated during wakeup * ENQUEUE_RQ_SELECTED - ->select_task_rq() was called + * ENQUEUE_PROXY - activate a blocked donor behind a waking owner * * XXX SAVE/RESTORE in combination with CLASS doesn't really make sense, but * SCHED_DEADLINE seems to rely on this for now. @@ -2571,6 +2572,7 @@ extern const u32 sched_prio_to_wmult[40]; #define ENQUEUE_MIGRATED 0x00040000 #define ENQUEUE_INITIAL 0x00080000 #define ENQUEUE_RQ_SELECTED 0x00100000 +#define ENQUEUE_PROXY 0x00200000 #define RETRY_TASK ((void *)-1UL) -- 2.55.0.654.g21b8a5bc05-goog