Commit 4269c60
committed
sched_ext: Enable scx_ops_init_task() separately
scx_ops_init_task() and the follow-up scx_ops_enable_task() in the fork path
were gated by scx_enabled() test and thus __scx_ops_enabled had to be turned
on before the first scx_ops_init_task() loop in scx_ops_enable(). However,
if an external entity causes sched_class switch before the loop is complete,
tasks which are not initialized could be switched to SCX.
The following can be reproduced by running a program which keeps toggling a
process between SCHED_OTHER and SCHED_EXT using sched_setscheduler(2).
sched_ext: Invalid task state transition 0 -> 3 for fish[1623]
WARNING: CPU: 1 PID: 1650 at kernel/sched/ext.c:3392 scx_ops_enable_task+0x1a1/0x200
...
Sched_ext: simple (enabling)
RIP: 0010:scx_ops_enable_task+0x1a1/0x200
...
switching_to_scx+0x13/0xa0
__sched_setscheduler+0x850/0xa50
do_sched_setscheduler+0x104/0x1c0
__x64_sys_sched_setscheduler+0x18/0x30
do_syscall_64+0x7b/0x140
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Fix it by gating scx_ops_init_task() separately using
scx_ops_init_task_enabled. __scx_ops_enabled is now set after all tasks are
finished with scx_ops_init_task().
Signed-off-by: Tejun Heo <[email protected]>1 parent 9753358 commit 4269c60
1 file changed
+10
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
853 | 853 | | |
854 | 854 | | |
855 | 855 | | |
| 856 | + | |
856 | 857 | | |
857 | 858 | | |
858 | 859 | | |
| |||
3565 | 3566 | | |
3566 | 3567 | | |
3567 | 3568 | | |
3568 | | - | |
| 3569 | + | |
3569 | 3570 | | |
3570 | 3571 | | |
3571 | 3572 | | |
3572 | 3573 | | |
3573 | 3574 | | |
3574 | 3575 | | |
3575 | 3576 | | |
3576 | | - | |
| 3577 | + | |
3577 | 3578 | | |
3578 | 3579 | | |
3579 | 3580 | | |
| |||
4453 | 4454 | | |
4454 | 4455 | | |
4455 | 4456 | | |
| 4457 | + | |
| 4458 | + | |
4456 | 4459 | | |
4457 | 4460 | | |
4458 | 4461 | | |
| |||
5132 | 5135 | | |
5133 | 5136 | | |
5134 | 5137 | | |
5135 | | - | |
| 5138 | + | |
| 5139 | + | |
5136 | 5140 | | |
5137 | 5141 | | |
5138 | 5142 | | |
| |||
5175 | 5179 | | |
5176 | 5180 | | |
5177 | 5181 | | |
5178 | | - | |
| 5182 | + | |
| 5183 | + | |
5179 | 5184 | | |
5180 | 5185 | | |
| 5186 | + | |
5181 | 5187 | | |
5182 | 5188 | | |
5183 | 5189 | | |
| |||
0 commit comments