Re: [PATCHSET v14 sched_ext/for-7.4] sched: Make proxy execution compatible with sched_ext
From: Andrea Righi
Date: Fri Sep 25 2026 - 03:46:59 EST
Hi Peter,
On Thu, Sep 24, 2026 at 09:52:37AM +0200, Peter Zijlstra wrote:
> On Tue, Sep 22, 2026 at 06:51:39PM +0200, Andrea Righi wrote:
>
> > Andrea Righi (16):
> > sched/core: Drop mutex locks before proxy rescheduling
> > sched/core: Dequeue waking proxy donors before reset
> > sched/core: Mark wakeups completed through ttwu_runnable()
> > sched: Add helper to block retained proxy donors
> > sched: Add sched_ext hooks for proxy execution
>
> Right, so these add:
>
> WF_TTWU_RQ:
>
> Used like ENQUEUE_DELAYED; could be fixed by generalizing that to cover all
> of p->is_blocked.
>
> scx_allow_proxy_exec():
>
> Hook to kill proxy exec for scx
>
> scx_proxy_reenqueue_retry():
>
> Like put_prev_task(), but for current. Ensures current gets put back on a DSQ
> once its done running.
>
> scx_proxy_donor_start():
>
> Delayed set_next_task(), confirms donor will be used.
>
> sched_proxy_block_task():
>
> Almost like switching_to_scx(), except it needs to change ctx->queued in case
> of p->is_blocked. Hence a new callback ran before sched_change_begin().
Yes, that matches the intent, with one small clarification:
scx_proxy_reenqueue_retry() doesn't directly put current back on a DSQ, a task
that couldn't be reenqueued remains on the reject DSQ and the hook schedules a
deferred retry after proxy resolution.
>
>
>
> Now, I have:
>
> https://patch.msgid.link/20260917-sched-fair-hrtick-restart-v4-1-4dd1414da81a@xxxxxxxxxx,
>
> pending, would something like the below on top of both this work?
>
> (although I'm not convinced SC_CONFIRM is actually making it better)
Yes, this works.
I applied Shubhang's v4 hrtick patch as a preliminary commit, then added the
SNT_CONFIRM callback and reworked the proxy-exec series to use it. sched_ext now
confirms the donor in set_next_task_scx() and scx_proxy_donor_start() is gone.
I tested the updated series and it passed all my scx proxy exec tests. The
branch is available here:
git://git.kernel.org/pub/scm/linux/kernel/git/arighi/linux.git scx-proxy-exec-next
It's not an obvious simplification, but if we want to go this way, we can
express both the provisional pick and donor confirmation through the sched class
callback.
Thanks,
-Andrea
>
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1876,7 +1876,7 @@ static inline void uclamp_rq_inc(struct
> if (!uclamp_is_used())
> return;
>
> - if (unlikely(!p->sched_class->uclamp_enabled))
> + if (unlikely(!(p->sched_class->flags & SC_UCLAMP)))
> return;
>
> /* Only inc the delayed task which being woken up. */
> @@ -1904,7 +1904,7 @@ static inline void uclamp_rq_dec(struct
> if (!uclamp_is_used())
> return;
>
> - if (unlikely(!p->sched_class->uclamp_enabled))
> + if (unlikely(!(p->sched_class->flags & SC_UCLAMP)))
> return;
>
> if (p->se.sched_delayed)
> @@ -7268,9 +7268,10 @@ static void __sched notrace __schedule(i
> rq->next_class = next->sched_class;
> if (sched_proxy_exec()) {
> struct task_struct *prev_donor = rq->donor;
> + struct task_struct *donor = next;
>
> - rq_set_donor(rq, next);
> - next->blocked_donor = NULL;
> + rq_set_donor(rq, donor);
> + donor->blocked_donor = NULL;
> if (unlikely(next->is_blocked)) {
> next = find_proxy_task(rq, next, &rf);
> if (!next) {
> @@ -7283,8 +7284,7 @@ static void __sched notrace __schedule(i
> goto keep_resched;
> }
> }
> - if (rq->donor == prev_donor && prev != next) {
> - struct task_struct *donor = rq->donor;
> + if (donor == prev_donor && prev != next) {
> /*
> * When transitioning like:
> *
> @@ -7298,9 +7298,10 @@ static void __sched notrace __schedule(i
> * on_cpu.
> */
> donor->sched_class->put_prev_task(rq, donor, donor);
> - donor->sched_class->set_next_task(rq, donor, true);
> + donor->sched_class->set_next_task(rq, donor, SNT_PICK);
> }
> - scx_proxy_donor_start(rq);
> + if (donor->sched_class->flags & SC_CONFIRM)
> + donor->sched_class->set_next_task(rq, donor, SNT_CONFIRM);
> scx_proxy_reenqueue_retry(rq, next);
> } else {
> rq_set_donor(rq, next);
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -5069,8 +5069,12 @@ DEFINE_SCHED_CLASS(ext) = {
>
> .update_curr = update_curr_scx,
>
> + .flags = 0
> #ifdef CONFIG_UCLAMP_TASK
> - .uclamp_enabled = 1,
> + | SC_UCLAMP
> +#endif
> +#ifdef CONFIG_SCHED_PROXY_EXEC
> + | SC_CONFIRM
> #endif
> };
>
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -15887,7 +15887,7 @@ DEFINE_SCHED_CLASS(fair) = {
> #endif
>
> #ifdef CONFIG_UCLAMP_TASK
> - .uclamp_enabled = 1,
> + .flags = SC_UCLAMP,
> #endif
> };
>
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2636,7 +2636,7 @@ DEFINE_SCHED_CLASS(rt) = {
> #endif
>
> #ifdef CONFIG_UCLAMP_TASK
> - .uclamp_enabled = 1,
> + .flags = SC_UCLAMP,
> #endif
> };
>
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -2641,13 +2641,17 @@ enum snt_e {
> SNT_NORMAL, /* set_next_task() */
> SNT_PICK, /* put_prev_set_next_task(): prev != next */
> SNT_REPICK, /* put_prev_set_next_task(): prev == next */
> + SNT_CONFIRM, /* confirm pick */
> +};
> +
> +enum {
> + SC_UCLAMP = 1<<0,
> + SC_CONFIRM = 1<<1,
> };
>
> struct sched_class {
>
> -#ifdef CONFIG_UCLAMP_TASK
> - int uclamp_enabled;
> -#endif
> + unsigned int flags;
>
> /*
> * move_queued_task/activate_task/enqueue_task: rq->lock