Skip to content

Commit e6d3c4e

Browse files
committed
Merge tag 'sched_ext-for-6.14-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext
Pull sched_ext fix from Tejun Heo: "pick_task_scx() has a workaround to avoid stalling when the fair class's balance() says yes but pick_task() says no. The workaround was incorrectly deciding to keep the prev taks running if the task is on SCX even when the task is in a sleeping state, which can lead to several confusing failure modes. Fix it by testing the prev task is currently queued on SCX instead" * tag 'sched_ext-for-6.14-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext: sched_ext: Fix pick_task_scx() picking non-queued tasks when it's called without balance()
2 parents 5394eea + 8fef0a3 commit e6d3c4e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

kernel/sched/ext.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,6 @@ static struct task_struct *pick_task_scx(struct rq *rq)
31173117
{
31183118
struct task_struct *prev = rq->curr;
31193119
struct task_struct *p;
3120-
bool prev_on_scx = prev->sched_class == &ext_sched_class;
31213120
bool keep_prev = rq->scx.flags & SCX_RQ_BAL_KEEP;
31223121
bool kick_idle = false;
31233122

@@ -3137,14 +3136,18 @@ static struct task_struct *pick_task_scx(struct rq *rq)
31373136
* if pick_task_scx() is called without preceding balance_scx().
31383137
*/
31393138
if (unlikely(rq->scx.flags & SCX_RQ_BAL_PENDING)) {
3140-
if (prev_on_scx) {
3139+
if (prev->scx.flags & SCX_TASK_QUEUED) {
31413140
keep_prev = true;
31423141
} else {
31433142
keep_prev = false;
31443143
kick_idle = true;
31453144
}
3146-
} else if (unlikely(keep_prev && !prev_on_scx)) {
3147-
/* only allowed during transitions */
3145+
} else if (unlikely(keep_prev &&
3146+
prev->sched_class != &ext_sched_class)) {
3147+
/*
3148+
* Can happen while enabling as SCX_RQ_BAL_PENDING assertion is
3149+
* conditional on scx_enabled() and may have been skipped.
3150+
*/
31483151
WARN_ON_ONCE(scx_ops_enable_state() == SCX_OPS_ENABLED);
31493152
keep_prev = false;
31503153
}

0 commit comments

Comments
 (0)