Re: [PATCHSET v14 sched_ext/for-7.4] sched: Make proxy execution compatible with sched_ext

From: Peter Zijlstra

Date: Thu Sep 24 2026 - 05:15:29 EST


On Thu, Sep 24, 2026 at 01:40:27PM +0530, K Prateek Nayak wrote:
> On 9/24/2026 1:29 PM, Peter Zijlstra wrote:
> >> 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().
> >
> > And I wonder, would something like so work?
> >
> > ---
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index adcc9264c0c6..3e7691d24930 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -11215,8 +11215,13 @@ void sched_change_end(struct sched_change_ctx *ctx)
> > */
> > WARN_ON_ONCE(p->sched_class != ctx->class && !(ctx->flags & ENQUEUE_CLASS));
> >
> > - if ((ctx->flags & ENQUEUE_CLASS) && p->sched_class->switching_to)
> > - p->sched_class->switching_to(rq, p);
> > + if ((ctx->flags & ENQUEUE_CLASS) && p->sched_class->switching_to) {
> > + bool block = p->sched_class->switching_to(rq, p);
> > + if (block && p->is_blocked) {
>
> Shouldn't this also check for "ctx->queued"?
>
> > + block_task(rq, p, READ_ONCE(p->__state));
>
> Otherwise we may block an already off rq task.
>
> > + ctx->queued = false;
> > + }
> > + }

Yes.