Skip to content

Commit 12883ef

Browse files
Steven Rostedt (Red Hat)rostedt
authored andcommitted
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>
1 parent 22cffc2 commit 12883ef

14 files changed

Lines changed: 365 additions & 286 deletions

‎include/linux/ftrace_event.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/perf_event.h>
99

1010
struct trace_array;
11+
struct trace_buffer;
1112
struct tracer;
1213
struct dentry;
1314

@@ -67,6 +68,7 @@ struct trace_entry {
6768
struct trace_iterator {
6869
struct trace_array *tr;
6970
struct tracer *trace;
71+
struct trace_buffer *trace_buffer;
7072
void *private;
7173
int cpu_file;
7274
struct mutex mutex;

‎kernel/trace/blktrace.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static void trace_note(struct blk_trace *bt, pid_t pid, int action,
7272
bool blk_tracer = blk_tracer_enabled;
7373

7474
if (blk_tracer) {
75-
buffer = blk_tr->buffer;
75+
buffer = blk_tr->trace_buffer.buffer;
7676
pc = preempt_count();
7777
event = trace_buffer_lock_reserve(buffer, TRACE_BLK,
7878
sizeof(*t) + len,
@@ -218,7 +218,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
218218
if (blk_tracer) {
219219
tracing_record_cmdline(current);
220220

221-
buffer = blk_tr->buffer;
221+
buffer = blk_tr->trace_buffer.buffer;
222222
pc = preempt_count();
223223
event = trace_buffer_lock_reserve(buffer, TRACE_BLK,
224224
sizeof(*t) + pdu_len,

0 commit comments

Comments
 (0)