diff options
author | Matt Evans <matt@ozlabs.org> | 2010-07-05 13:36:32 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2010-07-08 04:11:37 -0400 |
commit | 219a92a4c40db2fac604f63bce9a5a3fe1967879 (patch) | |
tree | a02b36dca8a413ca6793b316afbd7e5592d7ae7b /arch | |
parent | 2aa72f612144a0a7d4b0b22ae7c122692ac6a013 (diff) |
powerpc/perf_event: Fix for power_pmu_disable()
When power_pmu_disable() removes the given event from a particular index into
cpuhw->event[], it shuffles down higher event[] entries. But, this array is
paired with cpuhw->events[] and cpuhw->flags[] so should shuffle them
similarly.
If these arrays get out of sync, code such as power_check_constraints() will
fail. This caused a bug where events were temporarily disabled and then failed
to be re-enabled; subsequent code tried to write_pmc() with its (disabled) idx
of 0, causing a message "oops trying to write PMC0". This triggers this bug on
POWER7, running a miss-heavy test:
perf record -e L1-dcache-load-misses -e L1-dcache-store-misses ./misstest
Signed-off-by: Matt Evans <matt@ozlabs.org>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kernel/perf_event.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/perf_event.c b/arch/powerpc/kernel/perf_event.c index 43b83c35cf54..5c14ffe51258 100644 --- a/arch/powerpc/kernel/perf_event.c +++ b/arch/powerpc/kernel/perf_event.c | |||
@@ -791,8 +791,11 @@ static void power_pmu_disable(struct perf_event *event) | |||
791 | cpuhw = &__get_cpu_var(cpu_hw_events); | 791 | cpuhw = &__get_cpu_var(cpu_hw_events); |
792 | for (i = 0; i < cpuhw->n_events; ++i) { | 792 | for (i = 0; i < cpuhw->n_events; ++i) { |
793 | if (event == cpuhw->event[i]) { | 793 | if (event == cpuhw->event[i]) { |
794 | while (++i < cpuhw->n_events) | 794 | while (++i < cpuhw->n_events) { |
795 | cpuhw->event[i-1] = cpuhw->event[i]; | 795 | cpuhw->event[i-1] = cpuhw->event[i]; |
796 | cpuhw->events[i-1] = cpuhw->events[i]; | ||
797 | cpuhw->flags[i-1] = cpuhw->flags[i]; | ||
798 | } | ||
796 | --cpuhw->n_events; | 799 | --cpuhw->n_events; |
797 | ppmu->disable_pmc(event->hw.idx - 1, cpuhw->mmcr); | 800 | ppmu->disable_pmc(event->hw.idx - 1, cpuhw->mmcr); |
798 | if (event->hw.idx) { | 801 | if (event->hw.idx) { |