Commit f2b4286
MIPS: perf: fix deadlock
mipsxx_pmu_handle_shared_irq() calls irq_work_run() while holding the
pmuint_rwlock for read. irq_work_run() can, via perf_pending_event(),
call try_to_wake_up() which can try to take rq->lock.
However, perf can also call perf_pmu_enable() (and thus take the
pmuint_rwlock for write) while holding the rq->lock, from
finish_task_switch() via perf_event_context_sched_in().
This leads to an ABBA deadlock:
PID: 3855 TASK: 8f7ce288 CPU: 2 COMMAND: "process"
#0 [89c39ac8] __delay at 803b5be4
rib#1 [89c39ac8] do_raw_spin_lock at 8008fdcc
rib#2 [89c39af8] try_to_wake_up at 8006e47c
rib#3 [89c39b38] pollwake at 8018eab0
rib#4 [89c39b68] __wake_up_common at 800879f4
rib#5 [89c39b98] __wake_up at 800880e4
rib#6 [89c39bc8] perf_event_wakeup at 8012109
rib#7 [89c39be8] perf_pending_event at 80121184
rib#8 [89c39c08] irq_work_run_list at 801151f0
rib#9 [89c39c38] irq_work_run at 80115274
rib#10 [89c39c50] mipsxx_pmu_handle_shared_irq at 8002cc7c
PID: 1481 TASK: 8eaac6a8 CPU: 3 COMMAND: "process"
#0 [8de7f90] do_raw_write_lock at 800900e0
rib#1 [8de7f918] perf_event_context_sched_in at 80122310
rib#2 [8de7f938] __perf_event_task_sched_in at 80122608
rib#3 [8de7f958] finish_task_switch at 8006b8a4
rib#4 [8de7f998] __schedule at 805e4dc4
rib#5 [8de7f9f8] schedule at 805e5558
rib#6 [8de7fa10] schedule_hrtimeout_range_clock at 805e9984
rib#7 [8de7fa70] poll_schedule_timeout at 8018e8f8
rib#8 [8de7fa88] do_select at 8018f338
rib#9 [8de7fd88] core_sys_select at 8018f5cc
rib#10 [8de7fee0] sys_select at 8018f854
rib#11 [8de7ff28] syscall_common at 80028fc8
The lock seems to be there to protect the hardware counters so there is
no need to hold it across irq_work_run().
Signed-off-by: Rabin Vincent <rabinv@axis.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>1 parent 9eec1c0 commit f2b4286
1 file changed
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1446 | 1446 | | |
1447 | 1447 | | |
1448 | 1448 | | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
1449 | 1454 | | |
1450 | 1455 | | |
1451 | 1456 | | |
| |||
1454 | 1459 | | |
1455 | 1460 | | |
1456 | 1461 | | |
1457 | | - | |
1458 | | - | |
1459 | | - | |
1460 | | - | |
1461 | 1462 | | |
1462 | 1463 | | |
1463 | 1464 | | |
| |||
0 commit comments