Skip to content

Commit

Permalink
sched_ext: Test sched_class directly in scx_task_iter_next_filtered()
Browse files Browse the repository at this point in the history
scx_task_iter_next_filtered() is used to iterate all non-idle tasks in the
init and exit paths. Idle tasks are determined using is_idle_task().
Unfortunately, cff9b23 ("kernel/sched: Modify initial boot task idle
setup") changed idle task initialization so that %PF_IDLE is set during CPU
startup. So, CPUs that are not brought up during boot (such as CPUs which
can never be online in some AMD processors) don't have the flag set and thus
fails is_idle_task() test.

This makes sched_ext incorrectly try to operate on idle tasks in init/exit
paths leading to oopses. Fix it by directly testing p->sched_class against
idle_sched_class.
  • Loading branch information
htejun committed Nov 5, 2023
1 parent 41728bb commit a60668f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kernel/sched/ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,11 @@ scx_task_iter_next_filtered(struct scx_task_iter *iter)
struct task_struct *p;

while ((p = scx_task_iter_next(iter))) {
if (!is_idle_task(p))
/*
* is_idle_task() tests %PF_IDLE which may not be set for CPUs
* which haven't yet been onlined. Test sched_class directly.
*/
if (p->sched_class != &idle_sched_class)
return p;
}
return NULL;
Expand Down

0 comments on commit a60668f

Please sign in to comment.