Commit 16228ef
committed
itimer: resolve timer disarm deadlocks
Lockdep reports:
<4>[ 180.883141] git/435 is trying to acquire lock:
<5>[ 180.883538] 0xffffd0010366c010 (&s->signal_lock#2){+.-.}-{2:2}, at: kernel_raise_signal+0x6f/0x19f
<4>[ 180.883538] but task is already holding lock:
<5>[ 180.883982] 0xffff800507931e40 (&ev#2){+.-.}-{0:0}, at: _Z19timer_handle_eventsP5timer+0x160/0x2fa
<4>[ 180.883982]
<5>[ 180.900180] Possible unsafe locking scenario:
<5>[ 180.900180] CPU0 CPU1
<5>[ 180.900180] ---- ----
<5>[ 180.900180] lock(&ev#2);
<5>[ 180.900180] lock(&it.lock);
<5>[ 180.900181] lock(&ev#2);
<5>[ 180.900181] lock(&s->signal_lock#2);
<5>[ 180.900181]
*** DEADLOCK ***
This happens because itimers firing require the signal lock (to send a
signal). Having the signal_lock (or something in its chain of
dependencies) while trying to cancel the timer results in a deadlock,
and a loud complaint from lockdep.
Fix it by finally adding a proper timer_cancel_try() which fails if the
timer is running. itimer_disarm() requires a back-out loop now, which in
exit's case needs to unlock+lock signal_lock.
Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>1 parent 617c750 commit 16228ef
4 files changed
Lines changed: 52 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
33 | 42 | | |
34 | 43 | | |
35 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
818 | 832 | | |
819 | 833 | | |
820 | 834 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
235 | 247 | | |
236 | 248 | | |
237 | 249 | | |
| |||
419 | 431 | | |
420 | 432 | | |
421 | 433 | | |
422 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
423 | 443 | | |
424 | 444 | | |
425 | 445 | | |
426 | | - | |
| 446 | + | |
427 | 447 | | |
428 | | - | |
| 448 | + | |
429 | 449 | | |
430 | 450 | | |
431 | 451 | | |
| |||
460 | 480 | | |
461 | 481 | | |
462 | 482 | | |
463 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
464 | 487 | | |
465 | 488 | | |
466 | 489 | | |
| |||
0 commit comments