perf: Roll back callchain buffer refcount under the callchain mutex
authorFrederic Weisbecker <fweisbec@gmail.com>
Fri, 2 Aug 2013 16:29:54 +0000 (18:29 +0200)
committerIngo Molnar <mingo@kernel.org>
Fri, 16 Aug 2013 15:55:50 +0000 (17:55 +0200)
commitfc3b86d673e41ac66b4ba5b75a90c2fcafb90089
tree9fe09945405a9fc0a63b1481a7f943308156ca1e
parent77b339bce3e21f7a069447fc25a414b18e36fa2e
perf: Roll back callchain buffer refcount under the callchain mutex

When we fail to allocate the callchain buffers, we roll back the refcount
we did and return from get_callchain_buffers().

However we take the refcount and allocate under the callchain lock
but the rollback is done outside the lock.

As a result, while we roll back, some concurrent callchain user may
call get_callchain_buffers(), see the non-zero refcount and give up
because the buffers are NULL without itself retrying the allocation.

The consequences aren't that bad but that behaviour looks weird enough and
it's better to give their chances to the following callchain users where
we failed.

Reported-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1375460996-16329-2-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/events/callchain.c