diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2008-05-12 15:21:01 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-05-23 15:56:02 -0400 |
commit | 53d0aa773053ab18287781e25d52c5faf9e0e09e (patch) | |
tree | c0e268cb22a0416efca8709c677d41b513af04d3 | |
parent | 72b59d67f80983f7bb587b086fb4cb1bc95263a4 (diff) |
ftrace: add logic to record overruns
This patch sets up the infrastructure to record overruns of the tracing
buffer.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | kernel/trace/trace.c | 16 | ||||
-rw-r--r-- | kernel/trace/trace.h | 6 |
2 files changed, 16 insertions, 6 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 1281969103b8..b9126ef46a9e 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -609,6 +609,7 @@ void unregister_tracer(struct tracer *type) | |||
609 | void tracing_reset(struct trace_array_cpu *data) | 609 | void tracing_reset(struct trace_array_cpu *data) |
610 | { | 610 | { |
611 | data->trace_idx = 0; | 611 | data->trace_idx = 0; |
612 | data->overrun = 0; | ||
612 | data->trace_head = data->trace_tail = head_page(data); | 613 | data->trace_head = data->trace_tail = head_page(data); |
613 | data->trace_head_idx = 0; | 614 | data->trace_head_idx = 0; |
614 | data->trace_tail_idx = 0; | 615 | data->trace_tail_idx = 0; |
@@ -750,6 +751,7 @@ tracing_get_trace_entry(struct trace_array *tr, struct trace_array_cpu *data) | |||
750 | if (data->trace_head == data->trace_tail && | 751 | if (data->trace_head == data->trace_tail && |
751 | idx_next == data->trace_tail_idx) { | 752 | idx_next == data->trace_tail_idx) { |
752 | /* overrun */ | 753 | /* overrun */ |
754 | data->overrun++; | ||
753 | data->trace_tail_idx++; | 755 | data->trace_tail_idx++; |
754 | if (data->trace_tail_idx >= ENTRIES_PER_PAGE) { | 756 | if (data->trace_tail_idx >= ENTRIES_PER_PAGE) { |
755 | data->trace_tail = | 757 | data->trace_tail = |
@@ -2353,8 +2355,6 @@ tracing_read_pipe(struct file *filp, char __user *ubuf, | |||
2353 | { | 2355 | { |
2354 | struct trace_iterator *iter = filp->private_data; | 2356 | struct trace_iterator *iter = filp->private_data; |
2355 | struct trace_array_cpu *data; | 2357 | struct trace_array_cpu *data; |
2356 | struct trace_array *tr = iter->tr; | ||
2357 | struct tracer *tracer = iter->trace; | ||
2358 | static cpumask_t mask; | 2358 | static cpumask_t mask; |
2359 | static int start; | 2359 | static int start; |
2360 | unsigned long flags; | 2360 | unsigned long flags; |
@@ -2433,10 +2433,11 @@ tracing_read_pipe(struct file *filp, char __user *ubuf, | |||
2433 | if (cnt >= PAGE_SIZE) | 2433 | if (cnt >= PAGE_SIZE) |
2434 | cnt = PAGE_SIZE - 1; | 2434 | cnt = PAGE_SIZE - 1; |
2435 | 2435 | ||
2436 | memset(iter, 0, sizeof(*iter)); | 2436 | /* reset all but tr, trace, and overruns */ |
2437 | iter->tr = tr; | ||
2438 | iter->trace = tracer; | ||
2439 | iter->pos = -1; | 2437 | iter->pos = -1; |
2438 | memset(&iter->seq, 0, | ||
2439 | sizeof(struct trace_iterator) - | ||
2440 | offsetof(struct trace_iterator, seq)); | ||
2440 | 2441 | ||
2441 | /* | 2442 | /* |
2442 | * We need to stop all tracing on all CPUS to read the | 2443 | * We need to stop all tracing on all CPUS to read the |
@@ -2465,6 +2466,11 @@ tracing_read_pipe(struct file *filp, char __user *ubuf, | |||
2465 | for_each_cpu_mask(cpu, mask) { | 2466 | for_each_cpu_mask(cpu, mask) { |
2466 | data = iter->tr->data[cpu]; | 2467 | data = iter->tr->data[cpu]; |
2467 | __raw_spin_lock(&data->lock); | 2468 | __raw_spin_lock(&data->lock); |
2469 | |||
2470 | if (data->overrun > iter->last_overrun[cpu]) | ||
2471 | iter->overrun[cpu] += | ||
2472 | data->overrun - iter->last_overrun[cpu]; | ||
2473 | iter->last_overrun[cpu] = data->overrun; | ||
2468 | } | 2474 | } |
2469 | 2475 | ||
2470 | while (find_next_entry_inc(iter) != NULL) { | 2476 | while (find_next_entry_inc(iter) != NULL) { |
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 8991c5efcc74..c1ec134ac356 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -97,6 +97,7 @@ struct trace_array_cpu { | |||
97 | void *trace_head; /* producer */ | 97 | void *trace_head; /* producer */ |
98 | void *trace_tail; /* consumer */ | 98 | void *trace_tail; /* consumer */ |
99 | unsigned long trace_idx; | 99 | unsigned long trace_idx; |
100 | unsigned long overrun; | ||
100 | unsigned long saved_latency; | 101 | unsigned long saved_latency; |
101 | unsigned long critical_start; | 102 | unsigned long critical_start; |
102 | unsigned long critical_end; | 103 | unsigned long critical_end; |
@@ -157,10 +158,13 @@ struct trace_seq { | |||
157 | * results to users and which routines might sleep, etc: | 158 | * results to users and which routines might sleep, etc: |
158 | */ | 159 | */ |
159 | struct trace_iterator { | 160 | struct trace_iterator { |
160 | struct trace_seq seq; | ||
161 | struct trace_array *tr; | 161 | struct trace_array *tr; |
162 | struct tracer *trace; | 162 | struct tracer *trace; |
163 | long last_overrun[NR_CPUS]; | ||
164 | long overrun[NR_CPUS]; | ||
163 | 165 | ||
166 | /* The below is zeroed out in pipe_read */ | ||
167 | struct trace_seq seq; | ||
164 | struct trace_entry *ent; | 168 | struct trace_entry *ent; |
165 | int cpu; | 169 | int cpu; |
166 | 170 | ||