Commit 1d7f856
Peter Zijlstra
jump_label: Fix static_key_slow_dec() yet again
While commit 83ab38e ("jump_label: Fix concurrency issues in
static_key_slow_dec()") fixed one problem, it created yet another,
notably the following is now possible:
slow_dec
if (try_dec) // dec_not_one-ish, false
// enabled == 1
slow_inc
if (inc_not_disabled) // inc_not_zero-ish
// enabled == 2
return
guard((mutex)(&jump_label_mutex);
if (atomic_cmpxchg(1,0)==1) // false, we're 2
slow_dec
if (try-dec) // dec_not_one, true
// enabled == 1
return
else
try_dec() // dec_not_one, false
WARN
Use dec_and_test instead of cmpxchg(), like it was prior to
83ab38e. Add a few WARNs for the paranoid.
Fixes: 83ab38e ("jump_label: Fix concurrency issues in static_key_slow_dec()")
Reported-by: "Darrick J. Wong" <[email protected]>
Tested-by: Klara Modin <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>1 parent fe513c2 commit 1d7f856
1 file changed
+27
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
277 | 285 | | |
278 | 286 | | |
279 | 287 | | |
| |||
284 | 292 | | |
285 | 293 | | |
286 | 294 | | |
| 295 | + | |
287 | 296 | | |
288 | | - | |
| 297 | + | |
289 | 298 | | |
290 | 299 | | |
291 | 300 | | |
292 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
293 | 315 | | |
294 | | - | |
295 | | - | |
296 | 316 | | |
297 | 317 | | |
298 | 318 | | |
| |||
329 | 349 | | |
330 | 350 | | |
331 | 351 | | |
332 | | - | |
| 352 | + | |
333 | 353 | | |
334 | 354 | | |
335 | 355 | | |
| |||
0 commit comments