perf/core: convert perf_event_context::refcount to refcount_t

We currently use atomic_t for perf_event_context::refcount, meaning that
we can silently miss overflow on increment, or decrement from zero.

We do have an explicit check in get_ctx() for an unexpected
increment-on-zero, but this is a generic WARN_ON(), and won't get the
usual refcount_t warning that better describes the issue.

Let's make it possible to catch these cases by using refcount_t, and
ensure that we get consistent warnings (regardless of REFCOUNT_FULL) by
using refcount_inc_checked() to check for increment-from-zero in
get_ctx().

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
2 files changed