Re: [PATCH 4/6] sched/proxy: Switch proxy to use p->is_blocked
From: Peter Zijlstra
Date: Tue May 26 2026 - 11:11:24 EST
On Tue, May 26, 2026 at 01:16:13PM +0200, Peter Zijlstra wrote:
> 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.
>
> XXX: ttwu_runnable(): AFAICT this results in all delayed tasks getting blocked
> and send down the long wakeup-path -- and while there were some plans there
> [*], that was especially careful to not take all those locks.
>
> [*] https://lore.kernel.org/r/20250702114924.091581796@xxxxxxxxxxxxx
>
> Suggested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> ---
> kernel/sched/core.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3764,7 +3764,7 @@ static inline void proxy_reset_donor(str
> */
> static inline bool proxy_needs_return(struct rq *rq, struct task_struct *p)
> {
> - if (!task_is_blocked(p))
> + if (!p->is_blocked)
> return false;
Oh, I think we can solve things if we have a cpus_allowed check here. If
the task is on an allowed CPU, it don't need migration and we can carry
on without eating the overhead.
>
> scoped_guard(raw_spinlock, &p->blocked_lock) {
> @@ -6850,14 +6850,14 @@ find_proxy_task(struct rq *rq, struct ta
> 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;
> @@ -7128,7 +7128,7 @@ static void __sched notrace __schedule(i
>
> 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);
>
>