Re: [PATCH] sched/fair: Clear throttle state when leaving the fair class

From: K Prateek Nayak

Date: Wed Oct 28 2026 - 23:39:28 EST


Hello Ben,

On 10/29/2026 3:54 AM, Benjamin Segall wrote:
> Yep, sched_class switch lets you smuggle ->throttled into
> !cfs_bandwidth_used(), and then that check on enqueue_throttled lets you
> smuggle it onto actually being enqueued, which leads to corruption.
> That's fun.
>
> I think we need to use switched_from_fair though - if we are currently
> TASK_ON_RQ_MIGRATING, sched_class changes will skip going into
> dequeue_task_fair at all, so we will not see the DEQUEUE_CLASS.
> Triggering a migration on a throttled task can still happen I'm fairly
> sure.

We cannot grab the task_rq_lock() when the task is ON_RQ_MIGRATING and
guard(sched_change) should never see TASK_ON_RQ_MIGRATING - the task is
either fully blocked (!p->on_rq) or is queued (p->on_rq = 1) on a CPU
when we are doing a class change.

--
Thanks and Regards,
Prateek