diff options
-rw-r--r-- | kernel/perf_event.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 027c4d33b4d3..98c5549c8e29 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -4917,24 +4917,26 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer) | |||
4917 | static void perf_swevent_start_hrtimer(struct perf_event *event) | 4917 | static void perf_swevent_start_hrtimer(struct perf_event *event) |
4918 | { | 4918 | { |
4919 | struct hw_perf_event *hwc = &event->hw; | 4919 | struct hw_perf_event *hwc = &event->hw; |
4920 | s64 period; | ||
4921 | |||
4922 | if (!is_sampling_event(event)) | ||
4923 | return; | ||
4920 | 4924 | ||
4921 | hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 4925 | hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
4922 | hwc->hrtimer.function = perf_swevent_hrtimer; | 4926 | hwc->hrtimer.function = perf_swevent_hrtimer; |
4923 | if (is_sampling_event(event)) { | ||
4924 | s64 period = local64_read(&hwc->period_left); | ||
4925 | 4927 | ||
4926 | if (period) { | 4928 | period = local64_read(&hwc->period_left); |
4927 | if (period < 0) | 4929 | if (period) { |
4928 | period = 10000; | 4930 | if (period < 0) |
4931 | period = 10000; | ||
4929 | 4932 | ||
4930 | local64_set(&hwc->period_left, 0); | 4933 | local64_set(&hwc->period_left, 0); |
4931 | } else { | 4934 | } else { |
4932 | period = max_t(u64, 10000, hwc->sample_period); | 4935 | period = max_t(u64, 10000, hwc->sample_period); |
4933 | } | 4936 | } |
4934 | __hrtimer_start_range_ns(&hwc->hrtimer, | 4937 | __hrtimer_start_range_ns(&hwc->hrtimer, |
4935 | ns_to_ktime(period), 0, | 4938 | ns_to_ktime(period), 0, |
4936 | HRTIMER_MODE_REL_PINNED, 0); | 4939 | HRTIMER_MODE_REL_PINNED, 0); |
4937 | } | ||
4938 | } | 4940 | } |
4939 | 4941 | ||
4940 | static void perf_swevent_cancel_hrtimer(struct perf_event *event) | 4942 | static void perf_swevent_cancel_hrtimer(struct perf_event *event) |