Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234429
b: refs/heads/master
c: ba3dd36
h: refs/heads/master
i:
  234427: e8a0807
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Feb 16, 2011
1 parent bbe6aa2 commit 5291a4d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 163ec4354a5135c6c38c3f4a9b46a31900ebdf48
refs/heads/master: ba3dd36c6775264ee6e7354ba1aabcd6e86d7298
35 changes: 32 additions & 3 deletions trunk/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -5602,6 +5602,10 @@ static enum hrtimer_restart perf_swevent_hrtimer(struct hrtimer *hrtimer)
u64 period;

event = container_of(hrtimer, struct perf_event, hw.hrtimer);

if (event->state != PERF_EVENT_STATE_ACTIVE)
return HRTIMER_NORESTART;

event->pmu->read(event);

perf_sample_data_init(&data, 0);
Expand All @@ -5628,9 +5632,6 @@ static void perf_swevent_start_hrtimer(struct perf_event *event)
if (!is_sampling_event(event))
return;

hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hwc->hrtimer.function = perf_swevent_hrtimer;

period = local64_read(&hwc->period_left);
if (period) {
if (period < 0)
Expand All @@ -5657,6 +5658,30 @@ static void perf_swevent_cancel_hrtimer(struct perf_event *event)
}
}

static void perf_swevent_init_hrtimer(struct perf_event *event)
{
struct hw_perf_event *hwc = &event->hw;

if (!is_sampling_event(event))
return;

hrtimer_init(&hwc->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
hwc->hrtimer.function = perf_swevent_hrtimer;

/*
* Since hrtimers have a fixed rate, we can do a static freq->period
* mapping and avoid the whole period adjust feedback stuff.
*/
if (event->attr.freq) {
long freq = event->attr.sample_freq;

event->attr.sample_period = NSEC_PER_SEC / freq;
hwc->sample_period = event->attr.sample_period;
local64_set(&hwc->period_left, hwc->sample_period);
event->attr.freq = 0;
}
}

/*
* Software event: cpu wall time clock
*/
Expand Down Expand Up @@ -5709,6 +5734,8 @@ static int cpu_clock_event_init(struct perf_event *event)
if (event->attr.config != PERF_COUNT_SW_CPU_CLOCK)
return -ENOENT;

perf_swevent_init_hrtimer(event);

return 0;
}

Expand Down Expand Up @@ -5787,6 +5814,8 @@ static int task_clock_event_init(struct perf_event *event)
if (event->attr.config != PERF_COUNT_SW_TASK_CLOCK)
return -ENOENT;

perf_swevent_init_hrtimer(event);

return 0;
}

Expand Down

0 comments on commit 5291a4d

Please sign in to comment.