Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 287456
b: refs/heads/master
c: f39d47f
h: refs/heads/master
v: v3
  • Loading branch information
Stephane Eranian authored and Ingo Molnar committed Feb 7, 2012
1 parent ba7811c commit 3e096af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 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: 136e0b8eabb2913b589fc7fbd418f4d6805dbb56
refs/heads/master: f39d47ff819ed52a2afbdbecbe35f23f7755f58d
3 changes: 3 additions & 0 deletions trunk/arch/x86/kernel/cpu/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,9 @@ static void x86_pmu_start(struct perf_event *event, int flags)
struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
int idx = event->hw.idx;

if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED)))
return;

if (WARN_ON_ONCE(idx == -1))
return;

Expand Down
19 changes: 14 additions & 5 deletions trunk/kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,7 @@ do { \
static DEFINE_PER_CPU(int, perf_throttled_count);
static DEFINE_PER_CPU(u64, perf_throttled_seq);

static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count)
static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count, bool disable)
{
struct hw_perf_event *hwc = &event->hw;
s64 period, sample_period;
Expand All @@ -2322,9 +2322,13 @@ static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count)
hwc->sample_period = sample_period;

if (local64_read(&hwc->period_left) > 8*sample_period) {
event->pmu->stop(event, PERF_EF_UPDATE);
if (disable)
event->pmu->stop(event, PERF_EF_UPDATE);

local64_set(&hwc->period_left, 0);
event->pmu->start(event, PERF_EF_RELOAD);

if (disable)
event->pmu->start(event, PERF_EF_RELOAD);
}
}

Expand All @@ -2350,6 +2354,7 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx,
return;

raw_spin_lock(&ctx->lock);
perf_pmu_disable(ctx->pmu);

list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
if (event->state != PERF_EVENT_STATE_ACTIVE)
Expand Down Expand Up @@ -2381,13 +2386,17 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx,
/*
* restart the event
* reload only if value has changed
* we have stopped the event so tell that
* to perf_adjust_period() to avoid stopping it
* twice.
*/
if (delta > 0)
perf_adjust_period(event, period, delta);
perf_adjust_period(event, period, delta, false);

event->pmu->start(event, delta > 0 ? PERF_EF_RELOAD : 0);
}

perf_pmu_enable(ctx->pmu);
raw_spin_unlock(&ctx->lock);
}

Expand Down Expand Up @@ -4562,7 +4571,7 @@ static int __perf_event_overflow(struct perf_event *event,
hwc->freq_time_stamp = now;

if (delta > 0 && delta < 2*TICK_NSEC)
perf_adjust_period(event, delta, hwc->last_period);
perf_adjust_period(event, delta, hwc->last_period, true);
}

/*
Expand Down

0 comments on commit 3e096af

Please sign in to comment.