kernel-ark/arch/powerpc
Paul Mackerras 7595d63b3a perf_counter: powerpc: only reserve PMU hardware when we need it
Impact: cooperate with oprofile

At present, on PowerPC, if you have perf_counters compiled in, oprofile
doesn't work.  There is code to allow the PMU to be shared between
competing subsystems, such as perf_counters and oprofile, but currently
the perf_counter subsystem reserves the PMU for itself at boot time,
and never releases it.

This makes perf_counter play nicely with oprofile.  Now we keep a count
of how many perf_counter instances are counting hardware events, and
reserve the PMU when that count becomes non-zero, and release the PMU
when that count becomes zero.  This means that it is possible to have
perf_counters compiled in and still use oprofile, as long as there are
no hardware perf_counters active.  This also means that if oprofile is
active, sys_perf_counter_open will fail if the hw_event specifies a
hardware event.

To avoid races with other tasks creating and destroying perf_counters,
we use a mutex.  We use atomic_inc_not_zero and atomic_add_unless to
avoid having to take the mutex unless there is a possibility of the
count going between 0 and 1.

Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Orig-LKML-Reference: <20090330171023.627912475@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-04-06 09:30:39 +02:00
..
boot powerpc/83xx: add mmc-spi support via the device tree for MPC8323E-RDB 2009-04-01 08:59:23 -07:00
configs powerpc/85xx: Add support for the "socrates" board (MPC8544). 2009-03-27 06:42:08 -05:00
include/asm perf_counter: unify and fix delayed counter wakeup 2009-04-06 09:30:36 +02:00
kernel perf_counter: powerpc: only reserve PMU hardware when we need it 2009-04-06 09:30:39 +02:00
kvm KVM: ppc: e500: Fix the bug that KVM is unstable in SMP 2009-03-24 11:03:15 +02:00
lib Merge commit 'origin/master' into next 2009-03-11 17:10:07 +11:00
math-emu powerpc/math-emu: Fix efp dependence 2009-03-11 06:00:08 -05:00
mm perf_counter: provide major/minor page fault software events 2009-04-06 09:29:40 +02:00
oprofile powerpc/oprofile: G4 oprofile has variable number of counters 2009-03-11 17:10:16 +11:00
platforms Merge branch 'linus' into perfcounters/core-v2 2009-04-06 09:02:57 +02:00
sysdev Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2009-04-03 15:24:35 -07:00
xmon
Kconfig Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2009-04-03 15:24:35 -07:00
Kconfig.debug generic debug pagealloc: build fix 2009-04-02 19:04:48 -07:00
Makefile powerpc/math-emu: Fix efp dependence 2009-03-11 06:00:08 -05:00