x86, mmiotrace: fix buffer overrun detection
authorPekka Paalanen <pq@iki.fi>
Sun, 23 Nov 2008 19:24:30 +0000 (21:24 +0200)
committerIngo Molnar <mingo@elte.hu>
Sun, 23 Nov 2008 19:33:23 +0000 (20:33 +0100)
Impact: fix mmiotrace overrun tracing

When ftrace framework moved to use the ring buffer facility, the buffer
overrun detection was broken after 2.6.27 by commit

| commit 3928a8a2d98081d1bc3c0a84a2d70e29b90ecf1c
| Author: Steven Rostedt <rostedt@goodmis.org>
| Date:   Mon Sep 29 23:02:41 2008 -0400
|
|     ftrace: make work with new ring buffer
|
|     This patch ports ftrace over to the new ring buffer.

The detection is now fixed by using the ring buffer API.

When mmiotrace detects a buffer overrun, it will report the number of
lost events. People reading an mmiotrace log must know if something was
missed, otherwise the data may not make sense.

Signed-off-by: Pekka Paalanen <pq@iki.fi>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/trace/trace_mmiotrace.c

index f28484618ff0de99b0c9d5062f23fe8eec25070a..e62cbf78eab6d6a6270a2a5c97f4ffc7ac443525 100644 (file)
@@ -18,12 +18,14 @@ struct header_iter {
 
 static struct trace_array *mmio_trace_array;
 static bool overrun_detected;
+static unsigned long prev_overruns;
 
 static void mmio_reset_data(struct trace_array *tr)
 {
        int cpu;
 
        overrun_detected = false;
+       prev_overruns = 0;
        tr->time_start = ftrace_now(tr->cpu);
 
        for_each_online_cpu(cpu)
@@ -128,16 +130,12 @@ static void mmio_close(struct trace_iterator *iter)
 
 static unsigned long count_overruns(struct trace_iterator *iter)
 {
-       int cpu;
        unsigned long cnt = 0;
-/* FIXME: */
-#if 0
-       for_each_online_cpu(cpu) {
-               cnt += iter->overrun[cpu];
-               iter->overrun[cpu] = 0;
-       }
-#endif
-       (void)cpu;
+       unsigned long over = ring_buffer_overruns(iter->tr->buffer);
+
+       if (over > prev_overruns)
+               cnt = over - prev_overruns;
+       prev_overruns = over;
        return cnt;
 }