aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.h
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <srostedt@redhat.com>2013-03-05 09:24:35 -0500
committerSteven Rostedt <rostedt@goodmis.org>2013-03-15 00:35:40 -0400
commit12883efb670c28dff57dcd7f4f995a1ffe153b2d (patch)
tree36dcb1c14aaf7afb6515ce9230a75d0602c7fab1 /kernel/trace/trace.h
parent22cffc2bb4a50d8c56f03c56f9f19dea85b78e30 (diff)
tracing: Consolidate max_tr into main trace_array structure
Currently, the way the latency tracers and snapshot feature works is to have a separate trace_array called "max_tr" that holds the snapshot buffer. For latency tracers, this snapshot buffer is used to swap the running buffer with this buffer to save the current max latency. The only items needed for the max_tr is really just a copy of the buffer itself, the per_cpu data pointers, the time_start timestamp that states when the max latency was triggered, and the cpu that the max latency was triggered on. All other fields in trace_array are unused by the max_tr, making the max_tr mostly bloat. This change removes the max_tr completely, and adds a new structure called trace_buffer, that holds the buffer pointer, the per_cpu data pointers, the time_start timestamp, and the cpu where the latency occurred. The trace_array, now has two trace_buffers, one for the normal trace and one for the max trace or snapshot. By doing this, not only do we remove the bloat from the max_trace but the instances of traces can now use their own snapshot feature and not have just the top level global_trace have the snapshot feature and latency tracers for itself. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r--kernel/trace/trace.h37
1 files changed, 30 insertions, 7 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index fa60b2977524..986834f1f4dd 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -167,16 +167,37 @@ struct trace_array_cpu {
167 167
168struct tracer; 168struct tracer;
169 169
170struct trace_buffer {
171 struct trace_array *tr;
172 struct ring_buffer *buffer;
173 struct trace_array_cpu __percpu *data;
174 cycle_t time_start;
175 int cpu;
176};
177
170/* 178/*
171 * The trace array - an array of per-CPU trace arrays. This is the 179 * The trace array - an array of per-CPU trace arrays. This is the
172 * highest level data structure that individual tracers deal with. 180 * highest level data structure that individual tracers deal with.
173 * They have on/off state as well: 181 * They have on/off state as well:
174 */ 182 */
175struct trace_array { 183struct trace_array {
176 struct ring_buffer *buffer;
177 struct list_head list; 184 struct list_head list;
178 char *name; 185 char *name;
179 int cpu; 186 struct trace_buffer trace_buffer;
187#ifdef CONFIG_TRACER_MAX_TRACE
188 /*
189 * The max_buffer is used to snapshot the trace when a maximum
190 * latency is reached, or when the user initiates a snapshot.
191 * Some tracers will use this to store a maximum trace while
192 * it continues examining live traces.
193 *
194 * The buffers for the max_buffer are set up the same as the trace_buffer
195 * When a snapshot is taken, the buffer of the max_buffer is swapped
196 * with the buffer of the trace_buffer and the buffers are reset for
197 * the trace_buffer so the tracing can continue.
198 */
199 struct trace_buffer max_buffer;
200#endif
180 int buffer_disabled; 201 int buffer_disabled;
181 struct trace_cpu trace_cpu; /* place holder */ 202 struct trace_cpu trace_cpu; /* place holder */
182#ifdef CONFIG_FTRACE_SYSCALLS 203#ifdef CONFIG_FTRACE_SYSCALLS
@@ -189,7 +210,6 @@ struct trace_array {
189 int clock_id; 210 int clock_id;
190 struct tracer *current_trace; 211 struct tracer *current_trace;
191 unsigned int flags; 212 unsigned int flags;
192 cycle_t time_start;
193 raw_spinlock_t start_lock; 213 raw_spinlock_t start_lock;
194 struct dentry *dir; 214 struct dentry *dir;
195 struct dentry *options; 215 struct dentry *options;
@@ -198,7 +218,6 @@ struct trace_array {
198 struct list_head systems; 218 struct list_head systems;
199 struct list_head events; 219 struct list_head events;
200 struct task_struct *waiter; 220 struct task_struct *waiter;
201 struct trace_array_cpu __percpu *data;
202}; 221};
203 222
204enum { 223enum {
@@ -345,9 +364,11 @@ struct tracer {
345 struct tracer *next; 364 struct tracer *next;
346 struct tracer_flags *flags; 365 struct tracer_flags *flags;
347 bool print_max; 366 bool print_max;
367 bool enabled;
368#ifdef CONFIG_TRACER_MAX_TRACE
348 bool use_max_tr; 369 bool use_max_tr;
349 bool allocated_snapshot; 370 bool allocated_snapshot;
350 bool enabled; 371#endif
351}; 372};
352 373
353 374
@@ -493,8 +514,8 @@ trace_buffer_iter(struct trace_iterator *iter, int cpu)
493 514
494int tracer_init(struct tracer *t, struct trace_array *tr); 515int tracer_init(struct tracer *t, struct trace_array *tr);
495int tracing_is_enabled(void); 516int tracing_is_enabled(void);
496void tracing_reset(struct trace_array *tr, int cpu); 517void tracing_reset(struct trace_buffer *buf, int cpu);
497void tracing_reset_online_cpus(struct trace_array *tr); 518void tracing_reset_online_cpus(struct trace_buffer *buf);
498void tracing_reset_current(int cpu); 519void tracing_reset_current(int cpu);
499void tracing_reset_all_online_cpus(void); 520void tracing_reset_all_online_cpus(void);
500int tracing_open_generic(struct inode *inode, struct file *filp); 521int tracing_open_generic(struct inode *inode, struct file *filp);
@@ -674,6 +695,8 @@ trace_array_vprintk(struct trace_array *tr,
674 unsigned long ip, const char *fmt, va_list args); 695 unsigned long ip, const char *fmt, va_list args);
675int trace_array_printk(struct trace_array *tr, 696int trace_array_printk(struct trace_array *tr,
676 unsigned long ip, const char *fmt, ...); 697 unsigned long ip, const char *fmt, ...);
698int trace_array_printk_buf(struct ring_buffer *buffer,
699 unsigned long ip, const char *fmt, ...);
677void trace_printk_seq(struct trace_seq *s); 700void trace_printk_seq(struct trace_seq *s);
678enum print_line_t print_trace_line(struct trace_iterator *iter); 701enum print_line_t print_trace_line(struct trace_iterator *iter);
679 702