All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_ext: Rebuild fair weight when disabling BPF scheduler
@ 2026-05-26 13:52 Zicheng Qu
  2026-05-26 15:18 ` sashiko-bot
  2026-05-26 17:20 ` Andrea Righi
  0 siblings, 2 replies; 14+ messages in thread
From: Zicheng Qu @ 2026-05-26 13:52 UTC (permalink / raw)
  To: tj, void, arighi, changwoo, mingo, peterz, juri.lelli,
	vincent.guittot, dietmar.eggemann, rostedt, bsegall, mgorman,
	vschneid, kprateek.nayak, haoluo, joshdon, brho, sched-ext,
	linux-kernel
  Cc: tanghui20, zhangqiao22, quzicheng, quzicheng315

From: Zicheng Qu <quzicheng@huawei.com>

When a BPF scheduler is disabled, scx_root_disable() switches tasks
from ext_sched_class back to fair_sched_class directly. This does not
go through __setscheduler_params(), so p->se.load is not rebuilt for
tasks returning to fair.

For example, after enabling a sched_ext BPF scheduler and creating
CPU-bound tasks with different nice values, disabling the BPF scheduler
can leave them running under fair with stale p->se.load. They may then
split CPU time according to the stale weight instead of their current
nice weights.

Rebuild the fair load weight when scx_root_disable() switches a task
from ext_sched_class to fair_sched_class. Use set_load_weight(p, false)
so CFS gets a native load_weight derived from the task's current
policy/static_prio before the task is enqueued on fair.

Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
---
 kernel/sched/ext.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 65631e577ee9..e5b8509ce7ee 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -5967,6 +5967,10 @@ static void scx_root_disable(struct scx_sched *sch)
 
 		scoped_guard (sched_change, p, queue_flags) {
 			p->sched_class = new_class;
+
+			if (old_class == &ext_sched_class &&
+			    new_class == &fair_sched_class)
+				set_load_weight(p, false);
 		}
 
 		scx_disable_and_exit_task(scx_task_sched(p), p);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-06-24 11:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 13:52 [PATCH] sched_ext: Rebuild fair weight when disabling BPF scheduler Zicheng Qu
2026-05-26 15:18 ` sashiko-bot
2026-05-26 17:20 ` Andrea Righi
2026-05-27  9:40   ` [PATCH v2] sched_ext: Rebuild fair weight on ext to fair switches quzicheng315
2026-05-27 11:26     ` Peter Zijlstra
2026-05-28  2:53       ` Zicheng Qu
2026-05-28  9:25         ` Peter Zijlstra
2026-05-28 13:12           ` [PATCH v3] sched/fair: Rebuild load weight when switching to fair quzicheng315
2026-05-28 14:27             ` Tejun Heo
2026-05-30  5:06             ` sashiko-bot
2026-06-24  9:16               ` [PATCH v4 0/2] sched/fair: Fix fair load state " Zicheng Qu
2026-06-24  9:16                 ` [PATCH v4 1/2] sched/fair: Rebuild load weight " Zicheng Qu
2026-06-24  9:16                 ` [PATCH v4 2/2] sched/fair: Keep load_avg in sync after reweighting Zicheng Qu
2026-06-24 11:57                 ` [PATCH v4 0/2] sched/fair: Fix fair load state when switching to fair Andrea Righi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.