Re: [PATCH v34 14/14] sched/proxy: Add deactivated (sleeping) owner handling to find_proxy_task()
From: Zhan Xusheng
Date: Wed Dec 02 2026 - 03:31:25 EST
Hi John,
On Wed, Dec 02, 2026 at 03:52:42AM +0000, John Stultz wrote:
> ttwu_queue(p, cpu, wake_flags);
> }
> out:
> + if (woken)
> + activate_blocked_waiters(cpu_rq(task_cpu(p)), p, wake_flags);
When the owner goes through the wakelist, this can run before the
owner is activated, and a donor can then be queued on the owner after
the list was taken:
CPU0: ttwu(owner) CPU1: find_proxy_task(donor)
ttwu_queue_wakelist(owner)
activate_blocked_waiters()
blocked_head is empty
!owner->on_rq
lock owner->blocked_lock
!owner->on_rq
proxy_enqueue_on_owner()
CPU2: sched_ttwu_pending()
activate_task(owner)
activate_task() only takes the owner off its own sleeping owner, so
the donor stays on owner->blocked_head while the owner runs, until the
owner sleeps and is woken again or hands it the lock.
To check, I counted donors that the owner itself wakes while they are
still on its blocked_head, i.e. proxy_remove_from_sleeping_owner() with
owner == current (test only). One kthread takes a mutex and sleeps a
jiffy holding it, in a loop; six SCHED_FIFO kthreads take the same
mutex; 20s in QEMU, 19cc08c1a6a6 with this series, 3 runs each:
4 CPUs 2 CPUs
v34 221, 229, 216 141, 140, 154
+ resched_idle, TASK_WAKING owner 3, 0, 0 0, 0, 0
where the second line adds, test only, before the sleeping owner
branch enqueues anything:
if (READ_ONCE(owner->__state) == TASK_WAKING)
goto resched_idle;
The counter also catches a donor that the owner wakes before the
waker's activate_blocked_waiters() gets to it, which may be the 3. No
lockdep or KASAN reports in these runs.
Activating the blocked_head where the owner is actually activated
would cover it as well, but that runs under the rq lock.
Thanks,
Zhan Xusheng