提交 fc3b86d6 编写于 作者: F Frederic Weisbecker 提交者: Ingo Molnar

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: NJiri Olsa <jolsa@redhat.com>
Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
Acked-by: NJiri 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: NPeter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1375460996-16329-2-git-send-email-fweisbec@gmail.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
上级 77b339bc
...@@ -116,10 +116,11 @@ int get_callchain_buffers(void) ...@@ -116,10 +116,11 @@ int get_callchain_buffers(void)
err = alloc_callchain_buffers(); err = alloc_callchain_buffers();
exit: exit:
mutex_unlock(&callchain_mutex);
if (err) if (err)
atomic_dec(&nr_callchain_events); atomic_dec(&nr_callchain_events);
mutex_unlock(&callchain_mutex);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册