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

From: K Prateek Nayak

Date: Thu Sep 24 2026 - 04:12:09 EST


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;
> + }
> + }
>
> if (ctx->queued)
> enqueue_task(rq, p, ctx->flags);
--
Thanks and Regards,
Prateek