Commit 6b8c512
perf/core: Fix system hang caused by cpu-clock usage
commit eb3182ef0405ff2f6668fd3e5ff9883f60ce8801 upstream.
cpu-clock usage by the async-profiler tool can trigger a system hang,
which got bisected back to the following commit by Octavia Togami:
18dbcbf ("perf: Fix the POLL_HUP delivery breakage") causes this issue
The root cause of the hang is that cpu-clock is a special type of SW
event which relies on hrtimers. The __perf_event_overflow() callback
is invoked from the hrtimer handler for cpu-clock events, and
__perf_event_overflow() tries to call cpu_clock_event_stop()
to stop the event, which calls htimer_cancel() to cancel the hrtimer.
But that's a recursion into the hrtimer code from a hrtimer handler,
which (unsurprisingly) deadlocks.
To fix this bug, use hrtimer_try_to_cancel() instead, and set
the PERF_HES_STOPPED flag, which causes perf_swevent_hrtimer()
to stop the event once it sees the PERF_HES_STOPPED flag.
[ mingo: Fixed the comments and improved the changelog. ]
Closes: https://lore.kernel.org/all/CAHPNGSQpXEopYreir+uDDEbtXTBvBvi8c6fYXJvceqtgTPao3Q@mail.gmail.com/
Fixes: 18dbcbf ("perf: Fix the POLL_HUP delivery breakage")
Reported-by: Octavia Togami <[email protected]>
Suggested-by: Peter Zijlstra <[email protected]>
Signed-off-by: Dapeng Mi <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Tested-by: Octavia Togami <[email protected]>
Cc: [email protected]
Link: lucko/spark#530
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent bdb596c commit 6b8c512
1 file changed
Lines changed: 15 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11757 | 11757 | | |
11758 | 11758 | | |
11759 | 11759 | | |
11760 | | - | |
| 11760 | + | |
| 11761 | + | |
11761 | 11762 | | |
11762 | 11763 | | |
11763 | 11764 | | |
| |||
11803 | 11804 | | |
11804 | 11805 | | |
11805 | 11806 | | |
11806 | | - | |
11807 | | - | |
11808 | | - | |
| 11807 | + | |
| 11808 | + | |
| 11809 | + | |
| 11810 | + | |
| 11811 | + | |
| 11812 | + | |
| 11813 | + | |
| 11814 | + | |
11809 | 11815 | | |
11810 | 11816 | | |
11811 | 11817 | | |
11812 | 11818 | | |
11813 | 11819 | | |
11814 | | - | |
| 11820 | + | |
11815 | 11821 | | |
11816 | 11822 | | |
11817 | 11823 | | |
| |||
11855 | 11861 | | |
11856 | 11862 | | |
11857 | 11863 | | |
| 11864 | + | |
11858 | 11865 | | |
11859 | 11866 | | |
11860 | 11867 | | |
11861 | 11868 | | |
11862 | 11869 | | |
11863 | 11870 | | |
| 11871 | + | |
11864 | 11872 | | |
11865 | 11873 | | |
11866 | 11874 | | |
| |||
11934 | 11942 | | |
11935 | 11943 | | |
11936 | 11944 | | |
| 11945 | + | |
11937 | 11946 | | |
11938 | 11947 | | |
11939 | 11948 | | |
11940 | 11949 | | |
11941 | 11950 | | |
11942 | 11951 | | |
| 11952 | + | |
11943 | 11953 | | |
11944 | 11954 | | |
11945 | 11955 | | |
| |||
0 commit comments