Commit 134874e
committed
workqueue: Allow cancel_work_sync() and disable_work() from atomic contexts on BH work items
Now that work_grab_pending() can always grab the PENDING bit without
sleeping, the only thing that prevents allowing cancel_work_sync() of a BH
work item from an atomic context is the flushing of the in-flight instance.
When we're flushing a BH work item for cancel_work_sync(), we know that the
work item is not queued and must be executing in a BH context, which means
that it's safe to busy-wait for its completion from a non-hardirq atomic
context.
This patch updates __flush_work() so that it busy-waits when flushing a BH
work item for cancel_work_sync(). might_sleep() is pushed from
start_flush_work() to its callers - when operating on a BH work item,
__cancel_work_sync() now enforces !in_hardirq() instead of might_sleep().
This allows cancel_work_sync() and disable_work() to be called from
non-hardirq atomic contexts on BH work items.
v3: In __flush_work(), test WORK_OFFQ_BH to tell whether a work item being
canceled can be busy waited instead of making start_flush_work() return
the pool. (Lai)
v2: Lai pointed out that __flush_work() was accessing pool->flags outside
the RCU critical section protecting the pool pointer. Fix it by testing
and remembering the result inside the RCU critical section.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Lai Jiangshan <jiangshanlai@gmail.com>1 parent 456a78e commit 134874e
1 file changed
+55
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4105 | 4105 | | |
4106 | 4106 | | |
4107 | 4107 | | |
4108 | | - | |
4109 | | - | |
4110 | 4108 | | |
4111 | 4109 | | |
4112 | 4110 | | |
| |||
4158 | 4156 | | |
4159 | 4157 | | |
4160 | 4158 | | |
| 4159 | + | |
4161 | 4160 | | |
4162 | 4161 | | |
4163 | 4162 | | |
4164 | 4163 | | |
4165 | 4164 | | |
4166 | 4165 | | |
4167 | 4166 | | |
4168 | | - | |
4169 | | - | |
4170 | | - | |
4171 | | - | |
4172 | | - | |
| 4167 | + | |
4173 | 4168 | | |
| 4169 | + | |
| 4170 | + | |
| 4171 | + | |
| 4172 | + | |
| 4173 | + | |
| 4174 | + | |
| 4175 | + | |
| 4176 | + | |
| 4177 | + | |
| 4178 | + | |
| 4179 | + | |
| 4180 | + | |
| 4181 | + | |
| 4182 | + | |
| 4183 | + | |
| 4184 | + | |
| 4185 | + | |
| 4186 | + | |
| 4187 | + | |
| 4188 | + | |
| 4189 | + | |
| 4190 | + | |
| 4191 | + | |
| 4192 | + | |
| 4193 | + | |
| 4194 | + | |
| 4195 | + | |
| 4196 | + | |
| 4197 | + | |
4174 | 4198 | | |
| 4199 | + | |
| 4200 | + | |
| 4201 | + | |
4175 | 4202 | | |
4176 | 4203 | | |
4177 | 4204 | | |
| |||
4187 | 4214 | | |
4188 | 4215 | | |
4189 | 4216 | | |
| 4217 | + | |
4190 | 4218 | | |
4191 | 4219 | | |
4192 | 4220 | | |
| |||
4276 | 4304 | | |
4277 | 4305 | | |
4278 | 4306 | | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
4279 | 4312 | | |
4280 | 4313 | | |
4281 | 4314 | | |
| |||
4302 | 4335 | | |
4303 | 4336 | | |
4304 | 4337 | | |
4305 | | - | |
4306 | | - | |
4307 | | - | |
4308 | | - | |
| 4338 | + | |
| 4339 | + | |
| 4340 | + | |
| 4341 | + | |
4309 | 4342 | | |
4310 | | - | |
4311 | | - | |
| 4343 | + | |
| 4344 | + | |
4312 | 4345 | | |
4313 | | - | |
4314 | | - | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
4315 | 4349 | | |
4316 | | - | |
4317 | | - | |
| 4350 | + | |
4318 | 4351 | | |
4319 | 4352 | | |
4320 | 4353 | | |
| |||
4384 | 4417 | | |
4385 | 4418 | | |
4386 | 4419 | | |
4387 | | - | |
4388 | | - | |
| 4420 | + | |
| 4421 | + | |
| 4422 | + | |
| 4423 | + | |
| 4424 | + | |
4389 | 4425 | | |
4390 | 4426 | | |
4391 | 4427 | | |
| |||
0 commit comments