Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf: Ensure swevent hrtimer is properly destroyed

With the change to hrtimer_try_to_cancel() in
perf_swevent_cancel_hrtimer() it appears possible for the hrtimer to
still be active by the time the event gets freed.

Make sure the event does a full hrtimer_cancel() on the free path by
installing a perf_event::destroy handler.

Fixes: eb3182ef0405 ("perf/core: Fix system hang caused by cpu-clock usage")
Reported-by: CyberUnicorns <a101e_iotvul@163.com>
Tested-by: CyberUnicorns <a101e_iotvul@163.com>
Debugged-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>

+6
+6
kernel/events/core.c
··· 11906 11906 } 11907 11907 } 11908 11908 11909 + static void perf_swevent_destroy_hrtimer(struct perf_event *event) 11910 + { 11911 + hrtimer_cancel(&event->hw.hrtimer); 11912 + } 11913 + 11909 11914 static void perf_swevent_init_hrtimer(struct perf_event *event) 11910 11915 { 11911 11916 struct hw_perf_event *hwc = &event->hw; ··· 11919 11914 return; 11920 11915 11921 11916 hrtimer_setup(&hwc->hrtimer, perf_swevent_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); 11917 + event->destroy = perf_swevent_destroy_hrtimer; 11922 11918 11923 11919 /* 11924 11920 * Since hrtimers have a fixed rate, we can do a static freq->period