perf_counter: powerpc: initialize cpuhw pointer before use
Commit 9e35ad38 ("perf_counter: Rework the perf counter disable/enable") added code to the powerpc hw_perf_enable (renamed from hw_perf_restore) to test cpuhw->disabled and return immediately if it is not set (i.e. if the PMU is already enabled).
Unfortunately the test got added before cpuhw was initialized, resulting in an oops the first time hw_perf_enable got called. This fixes it by moving the initialization of cpuhw to before cpuhw->disabled is tested.
[ Impact: fix oops-causing bug on powerpc ]
---
arch/powerpc/kernel/perf_counter.c +1 -2
@@ -450,12 +450,11 @@ void hw_perf_enable(void)int idx;local_irq_save (flags); + cpuhw = &__get_cpu_var (cpu_hw_counters);if (!cpuhw->disabled) {local_irq_restore (flags);return ; } - - cpuhw = &__get_cpu_var (cpu_hw_counters); cpuhw->disabled =0 ;/*
Commit-ID: c0daaf3f1f672defa3a45ca449b76d0e86c55892 Gitweb: http://git.kernel.org/tip/c0daaf3f1f672defa3a45ca449b76d0e86c55892 Author: Paul Mackerras <[email protected]> AuthorDate: Mon, 18 May 2009 14:02:12 +1000 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 18 May 2009 07:38:42 +0200
perf_counter: powerpc: initialize cpuhw pointer before use
Commit 9e35ad38 ("perf_counter: Rework the perf counter disable/enable") added code to the powerpc hw_perf_enable (renamed from hw_perf_restore) to test cpuhw->disabled and return immediately if it is not set (i.e. if the PMU is already enabled).
Unfortunately the test got added before cpuhw was initialized, resulting in an oops the first time hw_perf_enable got called. This fixes it by moving the initialization of cpuhw to before cpuhw->disabled is tested.
[ Impact: fix oops-causing bug on powerpc ]
LKML-Reference: <[email protected]>
--- arch/powerpc/kernel/perf_counter.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
arch/powerpc/kernel/perf_counter.c +1 -2
@@ -450,12 +450,11 @@ void hw_perf_enable(void)int idx;local_irq_save (flags); + cpuhw = &__get_cpu_var (cpu_hw_counters);if (!cpuhw->disabled) {local_irq_restore (flags);return ; } - - cpuhw = &__get_cpu_var (cpu_hw_counters); cpuhw->disabled =0 ;/*