[RFC PATCH 0/3] sched/core: Allow proxy execution to work with core scheduling

K Prateek Nayak posted 3 patches 1 week ago
kernel/sched/core.c  | 129 ++++++++++++++++++++++++++++++++++++++-----
kernel/sched/sched.h |   4 ++
2 files changed, 119 insertions(+), 14 deletions(-)
[RFC PATCH 0/3] sched/core: Allow proxy execution to work with core scheduling
Posted by K Prateek Nayak 1 week ago
Proxy execution runs the lock owner in place of blocked donor returned
by pick_next_task() but the lock owner can have a different core-cookie
compared to the blocked donor and simply running the lock owner under
those circumstances breaks the guarantees of core scheduling.

Allow proxy execution to exist alognside core scheduling by forcing a
re-pick once the blocked_on chain is found to be stable in __schedule()
and then swapping the rq->core_pick with the lock owner allowing the
execution context to dictate the core-cookie.

Lightly tested with John's priority-inversion-demo [1] patched with
"coresched new -t pid --" and the plotted chart seems to suggest proxy
is working [2]. Your mileage may vary :-)

I'll update the thread if I find any nasty bugs over the weekend run.
Patches are prepared on top of:

  https://github.com/johnstultz-work/linux-dev.git proxy-exec-v30-7.2-rc1

at commit abb09adc985b ("HACK: scx: Add scx_prio_inversion test
scheduler") with commit 93bd6418a6ea ("sched/core: Skip
put_prev_task/set_next_task re-entry for sched_ext donors") reverted on
top to make !EXT builds happy.

This is essentially a formal version of [3] broken down to be slightly
more readable. Comments and feedback are always appreciated!

References
==========

[1] https://github.com/johnstultz-work/priority-inversion-demo/
[2] https://imgur.com/NsgWqRx
[3] https://lore.kernel.org/lkml/9ceb2af0-33c6-40ca-b855-5167a9c5ae0f@amd.com/

-- 
K Prateek Nayak (3):
  sched/core: Track the core-wide pick leader
  sched/core: Fix forceidle when lock owner has mismatchd cookie
  sched/core: Swap to lock owner for core-wide pick on core-cookie
    mismatch

 kernel/sched/core.c  | 129 ++++++++++++++++++++++++++++++++++++++-----
 kernel/sched/sched.h |   4 ++
 2 files changed, 119 insertions(+), 14 deletions(-)

-- 
2.43.0
Re: [RFC PATCH 0/3] sched/core: Allow proxy execution to work with core scheduling
Posted by John Stultz 6 days, 21 hours ago
On Fri, Jul 17, 2026 at 4:16 AM K Prateek Nayak <kprateek.nayak@amd.com> wrote:
>
> Proxy execution runs the lock owner in place of blocked donor returned
> by pick_next_task() but the lock owner can have a different core-cookie
> compared to the blocked donor and simply running the lock owner under
> those circumstances breaks the guarantees of core scheduling.
>
> Allow proxy execution to exist alognside core scheduling by forcing a
> re-pick once the blocked_on chain is found to be stable in __schedule()
> and then swapping the rq->core_pick with the lock owner allowing the
> execution context to dictate the core-cookie.
>
> Lightly tested with John's priority-inversion-demo [1] patched with
> "coresched new -t pid --" and the plotted chart seems to suggest proxy
> is working [2]. Your mileage may vary :-)
>
> I'll update the thread if I find any nasty bugs over the weekend run.
> Patches are prepared on top of:
>
>   https://github.com/johnstultz-work/linux-dev.git proxy-exec-v30-7.2-rc1
>
> at commit abb09adc985b ("HACK: scx: Add scx_prio_inversion test
> scheduler") with commit 93bd6418a6ea ("sched/core: Skip
> put_prev_task/set_next_task re-entry for sched_ext donors") reverted on
> top to make !EXT builds happy.
>
> This is essentially a formal version of [3] broken down to be slightly
> more readable. Comments and feedback are always appreciated!

This is very cool! Thank you so much for sending this out!

I unfortunately didn't get a chance to queue it up in my tree for
testing today, but I'm eager to do so monday!

Hopefully I can get my tree cleaned up and get v31 sent out, as
there's been a number of issues fixed since v30. And between you,
Andrea and Suleiman, there's a lot of cool new functionality to
include in the full series!

thanks
-john