From: Frederic Weisbecker Date: Fri, 2 Aug 2013 16:29:54 +0000 (+0200) Subject: perf: Roll back callchain buffer refcount under the callchain mutex X-Git-Tag: upstream/snapshot3+hdmi~4458^3~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fc3b86d673e41ac66b4ba5b75a90c2fcafb90089;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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 Signed-off-by: Frederic Weisbecker Acked-by: Jiri Olsa Cc: Namhyung Kim Cc: Arnaldo Carvalho de Melo Cc: Stephane Eranian Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1375460996-16329-2-git-send-email-fweisbec@gmail.com Signed-off-by: Ingo Molnar --- diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c index 76a8bc5..97b67df 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; }