Skip to content

Commit

Permalink
mmiotrace: count events lost due to not recording
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Pekka Paalanen <pq@iki.fi>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Pekka Paalanen authored and Ingo Molnar committed Feb 15, 2009
1 parent d2f8d7e commit 391b170
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions kernel/trace/trace_mmiotrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <linux/mmiotrace.h>
#include <linux/pci.h>
#include <asm/atomic.h>

#include "trace.h"

Expand All @@ -19,6 +20,7 @@ struct header_iter {
static struct trace_array *mmio_trace_array;
static bool overrun_detected;
static unsigned long prev_overruns;
static atomic_t dropped_count;

static void mmio_reset_data(struct trace_array *tr)
{
Expand Down Expand Up @@ -121,11 +123,11 @@ static void mmio_close(struct trace_iterator *iter)

static unsigned long count_overruns(struct trace_iterator *iter)
{
unsigned long cnt = 0;
unsigned long cnt = atomic_xchg(&dropped_count, 0);
unsigned long over = ring_buffer_overruns(iter->tr->buffer);

if (over > prev_overruns)
cnt = over - prev_overruns;
cnt += over - prev_overruns;
prev_overruns = over;
return cnt;
}
Expand Down Expand Up @@ -310,8 +312,10 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,

event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
&irq_flags);
if (!event)
if (!event) {
atomic_inc(&dropped_count);
return;
}
entry = ring_buffer_event_data(event);
tracing_generic_entry_update(&entry->ent, 0, preempt_count());
entry->ent.type = TRACE_MMIO_RW;
Expand All @@ -338,8 +342,10 @@ static void __trace_mmiotrace_map(struct trace_array *tr,

event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry),
&irq_flags);
if (!event)
if (!event) {
atomic_inc(&dropped_count);
return;
}
entry = ring_buffer_event_data(event);
tracing_generic_entry_update(&entry->ent, 0, preempt_count());
entry->ent.type = TRACE_MMIO_MAP;
Expand Down

0 comments on commit 391b170

Please sign in to comment.