Skip to content

Commit

Permalink
tracing: protect ring_buffer_expanded with trace_types_lock
Browse files Browse the repository at this point in the history
Impact: prevent races with ring_buffer_expanded

This patch places the expanding of the tracing buffer under the
protection of the trace_types_lock mutex. It is highly unlikely
that there would be any contention, but better safe than sorry.

Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
  • Loading branch information
Steven Rostedt committed Mar 13, 2009
1 parent a123c52 commit 1027fcb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -2391,8 +2391,10 @@ int tracing_update_buffers(void)
{
int ret = 0;

mutex_lock(&trace_types_lock);
if (!ring_buffer_expanded)
ret = tracing_resize_ring_buffer(trace_buf_size);
mutex_unlock(&trace_types_lock);

return ret;
}
Expand All @@ -2412,14 +2414,15 @@ static int tracing_set_tracer(const char *buf)
struct tracer *t;
int ret = 0;

mutex_lock(&trace_types_lock);

if (!ring_buffer_expanded) {
ret = tracing_resize_ring_buffer(trace_buf_size);
if (ret < 0)
return ret;
ret = 0;
}

mutex_lock(&trace_types_lock);
for (t = trace_types; t; t = t->next) {
if (strcmp(t->name, buf) == 0)
break;
Expand Down

0 comments on commit 1027fcb

Please sign in to comment.