Commit b06ccba
committed
sched_ext: Fix starvation of scx_enable() under fair-class saturation
During scx_enable(), the READY -> ENABLED task switching loop changes the
calling thread's sched_class from fair to ext. Since fair has higher
priority than ext, saturating fair-class workloads can indefinitely starve
the enable thread, hanging the system. This was introduced when the enable
path switched from preempt_disable() to scx_bypass() which doesn't protect
against fair-class starvation. Note that the original preempt_disable()
protection wasn't complete either - in partial switch modes, the calling
thread could still be starved after preempt_enable() as it may have been
switched to ext class.
Fix it by offloading the enable body to a dedicated system-wide RT
(SCHED_FIFO) kthread which cannot be starved by either fair or ext class
tasks. scx_enable() lazily creates the kthread on first use and passes the
ops pointer through a struct scx_enable_cmd containing the kthread_work,
then synchronously waits for completion.
The workfn runs on a different kthread from sch->helper (which runs
disable_work), so it can safely flush disable_work on the error path
without deadlock.
Fixes: 8c2090c ("sched_ext: Initialize in bypass mode")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Tejun Heo <tj@kernel.org>1 parent 1336b57 commit b06ccba
1 file changed
+56
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4975 | 4975 | | |
4976 | 4976 | | |
4977 | 4977 | | |
4978 | | - | |
| 4978 | + | |
| 4979 | + | |
| 4980 | + | |
| 4981 | + | |
| 4982 | + | |
| 4983 | + | |
| 4984 | + | |
| 4985 | + | |
| 4986 | + | |
| 4987 | + | |
| 4988 | + | |
| 4989 | + | |
| 4990 | + | |
| 4991 | + | |
4979 | 4992 | | |
| 4993 | + | |
| 4994 | + | |
| 4995 | + | |
4980 | 4996 | | |
4981 | 4997 | | |
4982 | 4998 | | |
4983 | 4999 | | |
4984 | 5000 | | |
4985 | 5001 | | |
4986 | | - | |
4987 | | - | |
4988 | | - | |
4989 | | - | |
4990 | | - | |
4991 | | - | |
4992 | 5002 | | |
4993 | 5003 | | |
4994 | 5004 | | |
| |||
5205 | 5215 | | |
5206 | 5216 | | |
5207 | 5217 | | |
5208 | | - | |
| 5218 | + | |
| 5219 | + | |
5209 | 5220 | | |
5210 | 5221 | | |
5211 | 5222 | | |
5212 | 5223 | | |
5213 | 5224 | | |
5214 | | - | |
| 5225 | + | |
| 5226 | + | |
5215 | 5227 | | |
5216 | 5228 | | |
5217 | 5229 | | |
| |||
5230 | 5242 | | |
5231 | 5243 | | |
5232 | 5244 | | |
5233 | | - | |
| 5245 | + | |
| 5246 | + | |
| 5247 | + | |
| 5248 | + | |
| 5249 | + | |
| 5250 | + | |
| 5251 | + | |
| 5252 | + | |
| 5253 | + | |
| 5254 | + | |
| 5255 | + | |
| 5256 | + | |
| 5257 | + | |
| 5258 | + | |
| 5259 | + | |
| 5260 | + | |
| 5261 | + | |
| 5262 | + | |
| 5263 | + | |
| 5264 | + | |
| 5265 | + | |
| 5266 | + | |
| 5267 | + | |
| 5268 | + | |
| 5269 | + | |
| 5270 | + | |
| 5271 | + | |
| 5272 | + | |
| 5273 | + | |
| 5274 | + | |
| 5275 | + | |
| 5276 | + | |
| 5277 | + | |
| 5278 | + | |
| 5279 | + | |
5234 | 5280 | | |
5235 | 5281 | | |
5236 | 5282 | | |
| |||
0 commit comments