aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-02-25 00:13:16 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-25 07:40:58 -0500
commitd7350c3f45694104e820041969c8185c5f99e57c (patch)
tree7aaed9e59f6d33c82e0b62c21f9d1bda9f094b4e /kernel/trace/trace.h
parentb04cc6b1f6398b0e0b60d37e27ce51b4899672ec (diff)
tracing/core: make the read callbacks reentrants
Now that several per-cpu files can be read or spliced at the same, we want the read/splice callbacks for tracing files to be reentrants. Until now, a single global mutex (trace_types_lock) serialized the access to tracing_read_pipe(), tracing_splice_read_pipe(), and the seq helpers. Ie: it means that if a user tries to read trace_pipe0 and trace_pipe1 at the same time, the access to the function tracing_read_pipe() is contended and one reader must wait for the other to finish its read call. The trace_type_lock mutex is mostly here to serialize the access to the global current tracer (current_trace), which can be changed concurrently. Although the iter struct keeps a private pointer to this tracer, its callbacks can be changed by another function. The method used here is to not keep anymore private reference to the tracer inside the iterator but to make a copy of it inside the iterator. Then it checks on subsequents read calls if the tracer has changed. This is not costly because the current tracer is not expected to be changed often, so we use a branch prediction for that. Moreover, we add a private mutex to the iterator (there is one iterator per file descriptor) to serialize the accesses in case of multiple consumers per file descriptor (which would be a silly idea from the user). Note that this is not to protect the ring buffer, since the ring buffer already serializes the readers accesses. This is to prevent from traces weirdness in case of concurrent consumers. But these mutexes can be dropped anyway, that would not result in any crash. Just tell me what you think about it. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r--kernel/trace/trace.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 508235a39da6..632191770aac 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -405,8 +405,9 @@ struct trace_iterator {
405 struct trace_array *tr; 405 struct trace_array *tr;
406 struct tracer *trace; 406 struct tracer *trace;
407 void *private; 407 void *private;
408 struct ring_buffer_iter *buffer_iter[NR_CPUS];
409 int cpu_file; 408 int cpu_file;
409 struct mutex mutex;
410 struct ring_buffer_iter *buffer_iter[NR_CPUS];
410 411
411 /* The below is zeroed out in pipe_read */ 412 /* The below is zeroed out in pipe_read */
412 struct trace_seq seq; 413 struct trace_seq seq;