aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Weisbecker <[email protected]>2013-08-02 18:29:54 +0200
committerIngo Molnar <[email protected]>2013-08-16 17:55:50 +0200
commitfc3b86d673e41ac66b4ba5b75a90c2fcafb90089 (patch)
tree9fe09945405a9fc0a63b1481a7f943308156ca1e
parent77b339bce3e21f7a069447fc25a414b18e36fa2e (diff)
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 <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Stephane Eranian <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
-rw-r--r--kernel/events/callchain.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c
index 76a8bc5f6265..97b67df8fbfe 100644
--- a/kernel/events/callchain.c
+++ b/kernel/events/callchain.c
@@ -116,10 +116,11 @@ int get_callchain_buffers(void)
err = alloc_callchain_buffers();
exit:
- mutex_unlock(&callchain_mutex);
if (err)
atomic_dec(&nr_callchain_events);
+ mutex_unlock(&callchain_mutex);
+
return err;
}