Commit eb3182e
perf/core: Fix system hang caused by cpu-clock usage
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 <octavia.togami@gmail.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Octavia Togami <octavia.togami@gmail.com>
Cc: stable@vger.kernel.org
Link: lucko/spark#530
Link: https://patch.msgid.link/20251015051828.12809-1-dapeng1.mi@linux.intel.com1 parent 6146a0f commit eb3182e
1 file changed
+15
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11773 | 11773 | | |
11774 | 11774 | | |
11775 | 11775 | | |
11776 | | - | |
| 11776 | + | |
| 11777 | + | |
11777 | 11778 | | |
11778 | 11779 | | |
11779 | 11780 | | |
| |||
11819 | 11820 | | |
11820 | 11821 | | |
11821 | 11822 | | |
11822 | | - | |
11823 | | - | |
11824 | | - | |
| 11823 | + | |
| 11824 | + | |
| 11825 | + | |
| 11826 | + | |
| 11827 | + | |
| 11828 | + | |
| 11829 | + | |
| 11830 | + | |
11825 | 11831 | | |
11826 | 11832 | | |
11827 | 11833 | | |
11828 | 11834 | | |
11829 | 11835 | | |
11830 | | - | |
| 11836 | + | |
11831 | 11837 | | |
11832 | 11838 | | |
11833 | 11839 | | |
| |||
11871 | 11877 | | |
11872 | 11878 | | |
11873 | 11879 | | |
| 11880 | + | |
11874 | 11881 | | |
11875 | 11882 | | |
11876 | 11883 | | |
11877 | 11884 | | |
11878 | 11885 | | |
11879 | 11886 | | |
| 11887 | + | |
11880 | 11888 | | |
11881 | 11889 | | |
11882 | 11890 | | |
| |||
11950 | 11958 | | |
11951 | 11959 | | |
11952 | 11960 | | |
| 11961 | + | |
11953 | 11962 | | |
11954 | 11963 | | |
11955 | 11964 | | |
11956 | 11965 | | |
11957 | 11966 | | |
11958 | 11967 | | |
| 11968 | + | |
11959 | 11969 | | |
11960 | 11970 | | |
11961 | 11971 | | |
| |||
0 commit comments