x86, mmiotrace: fix buffer overrun detection

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>

authored by Pekka Paalanen and committed by Ingo Molnar 7ee1768d 522a110b

+7 -9
+7 -9
kernel/trace/trace_mmiotrace.c
··· 18 18 19 19 static struct trace_array *mmio_trace_array; 20 20 static bool overrun_detected; 21 + static unsigned long prev_overruns; 21 22 22 23 static void mmio_reset_data(struct trace_array *tr) 23 24 { 24 25 int cpu; 25 26 26 27 overrun_detected = false; 28 + prev_overruns = 0; 27 29 tr->time_start = ftrace_now(tr->cpu); 28 30 29 31 for_each_online_cpu(cpu) ··· 130 128 131 129 static unsigned long count_overruns(struct trace_iterator *iter) 132 130 { 133 - int cpu; 134 131 unsigned long cnt = 0; 135 - /* FIXME: */ 136 - #if 0 137 - for_each_online_cpu(cpu) { 138 - cnt += iter->overrun[cpu]; 139 - iter->overrun[cpu] = 0; 140 - } 141 - #endif 142 - (void)cpu; 132 + unsigned long over = ring_buffer_overruns(iter->tr->buffer); 133 + 134 + if (over > prev_overruns) 135 + cnt = over - prev_overruns; 136 + prev_overruns = over; 143 137 return cnt; 144 138 } 145 139