Skip to content

Commit

Permalink
perf_events: Fix sample_period transfer on inherit
Browse files Browse the repository at this point in the history
One problem with frequency driven counters is that we cannot
predict the rate at which they trigger, therefore we have to
start them at period=1, this causes a ramp up effect. However,
if we fail to propagate the stable state on fork each new child
will have to ramp up again. This can lead to significant
artifacts in sample data.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: eranian@google.com
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <1264752266.4283.2121.camel@laptop>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Jan 29, 2010
1 parent 18c01f8 commit 75c9f32
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -5002,8 +5002,15 @@ inherit_event(struct perf_event *parent_event,
else
child_event->state = PERF_EVENT_STATE_OFF;

if (parent_event->attr.freq)
child_event->hw.sample_period = parent_event->hw.sample_period;
if (parent_event->attr.freq) {
u64 sample_period = parent_event->hw.sample_period;
struct hw_perf_event *hwc = &child_event->hw;

hwc->sample_period = sample_period;
hwc->last_period = sample_period;

atomic64_set(&hwc->period_left, sample_period);
}

child_event->overflow_handler = parent_event->overflow_handler;

Expand Down

0 comments on commit 75c9f32

Please sign in to comment.