Skip to content

Commit da330f5

Browse files
committed
sched_ext: Temporarily work around pick_task_scx() being called without balance_scx()
pick_task_scx() must be preceded by balance_scx() but there currently is a bug where fair could say yes on balance() but no on pick_task(), which then ends up calling pick_task_scx() without preceding balance_scx(). Work around by dropping WARN_ON_ONCE() and ignoring cases which don't make sense. This isn't great and can theoretically lead to stalls. However, for switch_all cases, this happens only while a BPF scheduler is being loaded or unloaded, and, for partial cases, fair will likely keep triggering this CPU. This will be reverted once the fair behavior is fixed. Signed-off-by: Tejun Heo <[email protected]> Cc: Peter Zijlstra <[email protected]>
1 parent 649e980 commit da330f5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

kernel/sched/ext.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2909,9 +2909,24 @@ static struct task_struct *pick_task_scx(struct rq *rq)
29092909
* If balance_scx() is telling us to keep running @prev, replenish slice
29102910
* if necessary and keep running @prev. Otherwise, pop the first one
29112911
* from the local DSQ.
2912+
*
2913+
* WORKAROUND:
2914+
*
2915+
* %SCX_RQ_BAL_KEEP should be set iff $prev is on SCX as it must just
2916+
* have gone through balance_scx(). Unfortunately, there currently is a
2917+
* bug where fair could say yes on balance() but no on pick_task(),
2918+
* which then ends up calling pick_task_scx() without preceding
2919+
* balance_scx().
2920+
*
2921+
* For now, ignore cases where $prev is not on SCX. This isn't great and
2922+
* can theoretically lead to stalls. However, for switch_all cases, this
2923+
* happens only while a BPF scheduler is being loaded or unloaded, and,
2924+
* for partial cases, fair will likely keep triggering this CPU.
2925+
*
2926+
* Once fair is fixed, restore WARN_ON_ONCE().
29122927
*/
29132928
if ((rq->scx.flags & SCX_RQ_BAL_KEEP) &&
2914-
!WARN_ON_ONCE(prev->sched_class != &ext_sched_class)) {
2929+
prev->sched_class == &ext_sched_class) {
29152930
p = prev;
29162931
if (!p->scx.slice)
29172932
p->scx.slice = SCX_SLICE_DFL;

0 commit comments

Comments
 (0)