Skip to content

Commit 5d508e8

Browse files
fbuihuuIngo Molnar
authored andcommitted
perf: Don't bother to init the hrtimer for no SW sampling counters
Signed-off-by: Franck Bui-Huu <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 2e939d1 commit 5d508e8

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

kernel/perf_event.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4917,24 +4917,26 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
49174917
static void perf_swevent_start_hrtimer(struct perf_event *event)
49184918
{
49194919
struct hw_perf_event *hwc = &event->hw;
4920+
s64 period;
4921+
4922+
if (!is_sampling_event(event))
4923+
return;
49204924

49214925
hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
49224926
hwc->hrtimer.function = perf_swevent_hrtimer;
4923-
if (is_sampling_event(event)) {
4924-
s64 period = local64_read(&hwc->period_left);
49254927

4926-
if (period) {
4927-
if (period < 0)
4928-
period = 10000;
4928+
period = local64_read(&hwc->period_left);
4929+
if (period) {
4930+
if (period < 0)
4931+
period = 10000;
49294932

4930-
local64_set(&hwc->period_left, 0);
4931-
} else {
4932-
period = max_t(u64, 10000, hwc->sample_period);
4933-
}
4934-
__hrtimer_start_range_ns(&hwc->hrtimer,
4933+
local64_set(&hwc->period_left, 0);
4934+
} else {
4935+
period = max_t(u64, 10000, hwc->sample_period);
4936+
}
4937+
__hrtimer_start_range_ns(&hwc->hrtimer,
49354938
ns_to_ktime(period), 0,
49364939
HRTIMER_MODE_REL_PINNED, 0);
4937-
}
49384940
}
49394941

49404942
static void perf_swevent_cancel_hrtimer(struct perf_event *event)

0 commit comments

Comments
 (0)