Re: [PATCH v3] sched/fair: Rebuild load weight when switching to fair

From: Tejun Heo

Date: Thu May 28 2026 - 10:35:14 EST


On Thu, May 28, 2026 at 09:12:38PM +0800, quzicheng315@xxxxxxxxx wrote:
> From: Zicheng Qu <quzicheng@xxxxxxxxxx>
>
> Tasks that run outside fair may not keep p->se.load in sync with their
> current scheduling policy and static priority. sched_ext, for example,
> uses p->scx.weight as the active scheduling weight, so p->se.load can be
> stale when a task moves back to fair.
>
> The fair_sched_class expects the sched_entity load weight to be valid
> before the task is enqueued. Rebuild it from fair's switching_to hook,
> which runs after the class has been changed to fair and before enqueue,
> so both sched_ext disable and SCHED_EXT to SCHED_NORMAL transitions get
> a native fair load weight.
>
> Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
>
> Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Signed-off-by: Zicheng Qu <quzicheng@xxxxxxxxxx>

Acked-by: Tejun Heo <tj@xxxxxxxxxx>

Thanks.

--
tejun