Skip to content

Commit

Permalink
perf: Roll back callchain buffer refcount under the callchain mutex
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
fweisbec authored and Ingo Molnar committed Aug 16, 2013
1 parent 77b339b commit fc3b86d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/events/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit fc3b86d

Please sign in to comment.