[PATCH RFC] sched/proxy: Defer donor commit until proxy resolution

From: Xukai Wang

Date: Tue Jul 07 2026 - 11:47:35 EST


Hi,

This RFC tries to decouple proxy candidate selection from donor commit in the
scheduler core.

Currently pick_next_task() does not only select a task. It also commits the
selected task into the scheduling class state through put_prev_set_next_task().
With proxy execution enabled, the selected task may be a blocked donor,
and __schedule() then calls find_proxy_task() to resolve the proxy chain and
find the task that should actually run.

If find_proxy_task() returns NULL, __schedule() goes back to pick_again.
However, the picked donor has already been committed into the class current state.
This means the scheduler may first set_next() a blocked donor and then immediately
abandon that choice when proxy resolution fails.

I tested this using a small misc driver which creates controlled contention on a
kernel struct mutex, so that tasks block on the kernel mutex path rather than
only on userspace futexes.

Before this change, one run showed:

total case:
find_call 75
find_success 9
find_idle 23
find_null 43
null_rate: 57.33%

null case:
null_chain_changed 0
null_owner_race 0
null_deactivate_no_mutex 0
null_deactivate_no_owner 0
null_deactivate_owner_not_runnable 21
null_migrate 22

Most NULL returns came from migration/deactivation paths. In those cases, the
initially picked donor was not the final scheduling decision, but it had already
gone through the class put_prev/set_next transition.

This patch changes the model so that pick_next_task() only returns a candidate.
The actual class commit is moved to __schedule(), after proxy resolution.

After this change, no scheduler WARN_ON_ONCE() was triggered in this test,
including temporary debug checks around rq->dl_server and migration/deactivation
of tasks found while walking the proxy chain.

The main point I would like feedback on is whether this is the right boundary:
pick a proxy candidate first, resolve the proxy chain, then commit the donor
only after the final donor/execution pair is known.

Signed-off-by: Xukai Wang <kingxukai@xxxxxxxxxxxx>
---
Xukai Wang (1):
sched/proxy: Defer donor commit until after proxy resolution

kernel/sched/core.c | 70 ++++++++++++++++++++++++++++++-----------------------
1 file changed, 40 insertions(+), 30 deletions(-)
---
base-commit: 19b7bdc3a1550ab2550427c33395bec7caeaf72d
change-id: 20260707-sched-proxy-4404b6e97ad9

Best regards,
--
Xukai Wang <kingxukai@xxxxxxxxxxxx>