diff options
author | Franck Bui-Huu <fbuihuu@gmail.com> | 2010-11-23 10:21:45 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-11-26 09:14:55 -0500 |
commit | 5d508e820a23d9b6e8a149dfaa8ba5cbedf3d95c (patch) | |
tree | f11741710e4a2bb6b5c50e0d0b8c8cea0e6d9d6d /kernel/perf_event.c | |
parent | 2e939d1da9b5628642314c1e68b4319e61263c94 (diff) |
perf: Don't bother to init the hrtimer for no SW sampling counters
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <1290525705-6265-3-git-send-email-fbuihuu@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_event.c')
-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) |