History

mmiotrace: count events lost due to not recording

Impact: enhances lost events counting in mmiotrace The tracing framework, or the ring buffer facility it uses, has a switch to stop recording data. When recording is off, the trace events will be lost. The framework does not count these, so mmiotrace has to count them itself.

Pekka Paalanen committed 17 years ago

Commit 173ed241 parent fe6f90e1 file · +10 −4Browse files

Unified · Split

kernel/trace/trace_mmiotrace.c+10−4
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 #include <linux/kernel.h>
1010 #include <linux/mmiotrace.h>
1111 #include <linux/pci.h>
12+#include <asm/atomic.h>
1213
1314 #include "trace.h"
1415 #include "trace_output.h"
@@ -20,6 +21,7 @@ struct header_iter { · 5 unmodified lines
2021 static struct trace_array *mmio_trace_array;
2122 static bool overrun_detected;
2223 static unsigned long prev_overruns;
24+static atomic_t dropped_count;
2325
2426 static void mmio_reset_data(struct trace_array *tr)
2527 {
@@ -122,11 +124,11 @@ static void mmio_close(struct trace_iterator *iter) · 96 unmodified lines
122124
123125 static unsigned long count_overruns(struct trace_iterator *iter)
124126 {
125− unsigned long cnt = 0;
127+ unsigned long cnt = atomic_xchg(&dropped_count, 0);
126128 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
127129
128130 if (over > prev_overruns)
129− cnt = over - prev_overruns;
131+ cnt += over - prev_overruns;
130132 prev_overruns = over;
131133 return cnt;
132134 }
@@ -308,8 +310,10 @@ static void __trace_mmiotrace_rw(struct trace_array *tr, · 175 unmodified lines
308310
309311 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
310312 &irq_flags);
311− if (!event)
313+ if (!event) {
314+ atomic_inc(&dropped_count);
312315 return;
316+ }
313317 entry = ring_buffer_event_data(event);
314318 tracing_generic_entry_update(&entry->ent, 0, preempt_count());
315319 entry->ent.type = TRACE_MMIO_RW;
@@ -336,8 +340,10 @@ static void __trace_mmiotrace_map(struct trace_array *tr, · 20 unmodified lines
336340
337341 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
338342 &irq_flags);
339− if (!event)
343+ if (!event) {
344+ atomic_inc(&dropped_count);
340345 return;
346+ }
341347 entry = ring_buffer_event_data(event);
342348 tracing_generic_entry_update(&entry->ent, 0, preempt_count());
343349 entry->ent.type = TRACE_MMIO_MAP;