• P
    perf_counter: powerpc: only reserve PMU hardware when we need it · 7595d63b
    Paul Mackerras 提交于
    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: NPaul Mackerras <paulus@samba.org>
    Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
    Orig-LKML-Reference: <20090330171023.627912475@chello.nl>
    Signed-off-by: NIngo Molnar <mingo@elte.hu>
    7595d63b
perf_counter.c 20.4 KB