Skip to content

Commit ff5860f

Browse files
author
Peter Zijlstra
committed
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: eb3182e ("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>
1 parent 9ace475 commit ff5860f

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

kernel/events/core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11906,6 +11906,11 @@ static void perf_swevent_cancel_hrtimer(struct perf_event *event)
1190611906
}
1190711907
}
1190811908

11909+
static void perf_swevent_destroy_hrtimer(struct perf_event *event)
11910+
{
11911+
hrtimer_cancel(&event->hw.hrtimer);
11912+
}
11913+
1190911914
static void perf_swevent_init_hrtimer(struct perf_event *event)
1191011915
{
1191111916
struct hw_perf_event *hwc = &event->hw;
@@ -11914,6 +11919,7 @@ static void perf_swevent_init_hrtimer(struct perf_event *event)
1191411919
return;
1191511920

1191611921
hrtimer_setup(&hwc->hrtimer, perf_swevent_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD);
11922+
event->destroy = perf_swevent_destroy_hrtimer;
1191711923

1191811924
/*
1191911925
* Since hrtimers have a fixed rate, we can do a static freq->period

0 commit comments

Comments
 (0)