Commit efe231d
committed
sched_ext: Decouple locks in scx_ops_enable()
The enable path uses three big locks - scx_fork_rwsem, scx_cgroup_rwsem and
cpus_read_lock. Currently, the locks are grabbed together which is prone to
locking order problems.
For example, currently, there is a possible deadlock involving
scx_fork_rwsem and cpus_read_lock. cpus_read_lock has to nest inside
scx_fork_rwsem due to locking order existing in other subsystems. However,
there exists a dependency in the other direction during hotplug if hotplug
needs to fork a new task, which happens in some cases. This leads to the
following deadlock:
scx_ops_enable() hotplug
percpu_down_write(&cpu_hotplug_lock)
percpu_down_write(&scx_fork_rwsem)
block on cpu_hotplug_lock
kthread_create() waits for kthreadd
kthreadd blocks on scx_fork_rwsem
Note that this doesn't trigger lockdep because the hotplug side dependency
bounces through kthreadd.
With the preceding scx_cgroup_enabled change, this can be solved by
decoupling cpus_read_lock, which is needed for static_key manipulations,
from the other two locks.
- Move the first block of static_key manipulations outside of scx_fork_rwsem
and scx_cgroup_rwsem. This is now safe with the preceding
scx_cgroup_enabled change.
- Drop scx_cgroup_rwsem and scx_fork_rwsem between the two task iteration
blocks so that __scx_ops_enabled static_key enabling is outside the two
rwsems.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-and-tested-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
Link: http://lkml.kernel.org/r/8cd0ec0c4c7c1bc0119e61fbef0bee9d5e24022d.camel@linux.ibm.com1 parent 1602165 commit efe231d
1 file changed
Lines changed: 27 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5049 | 5049 | | |
5050 | 5050 | | |
5051 | 5051 | | |
5052 | | - | |
| 5052 | + | |
| 5053 | + | |
5053 | 5054 | | |
5054 | 5055 | | |
5055 | 5056 | | |
| |||
5092 | 5093 | | |
5093 | 5094 | | |
5094 | 5095 | | |
5095 | | - | |
5096 | | - | |
5097 | | - | |
5098 | | - | |
5099 | | - | |
5100 | | - | |
5101 | | - | |
5102 | | - | |
5103 | | - | |
5104 | | - | |
5105 | | - | |
5106 | | - | |
5107 | | - | |
5108 | | - | |
5109 | | - | |
5110 | | - | |
5111 | | - | |
5112 | | - | |
5113 | | - | |
5114 | | - | |
5115 | | - | |
5116 | | - | |
5117 | 5096 | | |
5118 | 5097 | | |
5119 | | - | |
| 5098 | + | |
5120 | 5099 | | |
5121 | 5100 | | |
5122 | | - | |
| 5101 | + | |
5123 | 5102 | | |
5124 | 5103 | | |
5125 | | - | |
| 5104 | + | |
5126 | 5105 | | |
5127 | | - | |
| 5106 | + | |
5128 | 5107 | | |
5129 | 5108 | | |
5130 | 5109 | | |
5131 | | - | |
| 5110 | + | |
5132 | 5111 | | |
5133 | | - | |
| 5112 | + | |
5134 | 5113 | | |
5135 | 5114 | | |
5136 | 5115 | | |
5137 | | - | |
5138 | | - | |
| 5116 | + | |
| 5117 | + | |
5139 | 5118 | | |
5140 | | - | |
5141 | | - | |
5142 | | - | |
| 5119 | + | |
5143 | 5120 | | |
5144 | 5121 | | |
5145 | 5122 | | |
| |||
5150 | 5127 | | |
5151 | 5128 | | |
5152 | 5129 | | |
| 5130 | + | |
| 5131 | + | |
| 5132 | + | |
| 5133 | + | |
| 5134 | + | |
| 5135 | + | |
5153 | 5136 | | |
| 5137 | + | |
| 5138 | + | |
| 5139 | + | |
| 5140 | + | |
| 5141 | + | |
5154 | 5142 | | |
5155 | 5143 | | |
5156 | 5144 | | |
| |||
5183 | 5171 | | |
5184 | 5172 | | |
5185 | 5173 | | |
| 5174 | + | |
| 5175 | + | |
5186 | 5176 | | |
5187 | 5177 | | |
5188 | 5178 | | |
5189 | 5179 | | |
5190 | 5180 | | |
5191 | 5181 | | |
5192 | | - | |
| 5182 | + | |
5193 | 5183 | | |
5194 | 5184 | | |
5195 | 5185 | | |
5196 | 5186 | | |
5197 | 5187 | | |
5198 | 5188 | | |
| 5189 | + | |
5199 | 5190 | | |
5200 | 5191 | | |
5201 | 5192 | | |
| |||
5213 | 5204 | | |
5214 | 5205 | | |
5215 | 5206 | | |
5216 | | - | |
5217 | | - | |
5218 | | - | |
5219 | 5207 | | |
| 5208 | + | |
5220 | 5209 | | |
5221 | 5210 | | |
5222 | 5211 | | |
| |||
5259 | 5248 | | |
5260 | 5249 | | |
5261 | 5250 | | |
5262 | | - | |
5263 | | - | |
5264 | 5251 | | |
5265 | 5252 | | |
5266 | 5253 | | |
| |||
0 commit comments