Skip to content

Commit

Permalink
perf_counter: powerpc: initialize cpuhw pointer before use
Browse files Browse the repository at this point in the history
Commit 9e35ad3 ("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 ]

Signed-off-by: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
LKML-Reference: <18960.56772.869734.304631@drongo.ozlabs.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Paul Mackerras authored and Ingo Molnar committed May 18, 2009
1 parent dc3f81b commit c0daaf3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions arch/powerpc/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
Expand Down

0 comments on commit c0daaf3

Please sign in to comment.