Skip to contentSkip to conversation

ftrace: add a 'dropped events' counter

PATCH In review Slava Pestov 1 participant 2 messages Jul 15, 2011 – Nov 14, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ftrace: add a 'dropped events' counter

The existing 'overrun' counter is incremented when the ring buffer wraps around, with overflow on (the default). We wanted a way to count requests lost from the buffer filling up with overflow off, too. I decided to add a new counter instead of retro-fitting the existing one because it seems like a different statistic to count conceptually, and also because of how the code was structured.

---
 include/linux/ring_buffer.h |    1 +
 kernel/trace/ring_buffer.c  |   43 ++++++++++++++++++++++++++++++++++++-------
 kernel/trace/trace.c        |    3 +++
 3 files changed, 40 insertions(+), 7 deletions(-)
include/linux/ring_buffer.h +1 -0
index ab38ac8..a6dea58 100644
@@ -159,6 +159,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer);
 unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu);
 unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu);
 unsigned long ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu);
+unsigned long ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu);
 
 u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu);
 void ring_buffer_normalize_time_stamp(struct ring_buffer *buffer,
kernel/trace/ring_buffer.c +36 -7

81 lines not on this page · raw message

kernel/trace/trace.c +3 -0
index ee9c921..fe8c1d3 100644
@@ -3939,6 +3939,9 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
 	cnt = ring_buffer_commit_overrun_cpu(tr->buffer, cpu);
 	trace_seq_printf(s, "commit overrun: %ld\n", cnt);
 
+	cnt = ring_buffer_dropped_events_cpu(tr->buffer, cpu);
+	trace_seq_printf(s, "dropped events: %ld\n", cnt);
+
 	count = simple_read_from_buffer(ubuf, count, ppos, s->buffer, s->len);
 
 	kfree(s);
Signature · 1 line
1.7.3.1
#1 lore raw

[tip:perf/core] ring-buffer: Add a 'dropped events' counter

Commit-ID:  884bfe89a462fcc85c8abd96171519cf2fe70929
Gitweb:     http://git.kernel.org/tip/884bfe89a462fcc85c8abd96171519cf2fe70929
Author:     Slava Pestov <[email protected]>
AuthorDate: Fri, 15 Jul 2011 14:23:58 -0700
Committer:  Steven Rostedt <[email protected]>
CommitDate: Wed, 31 Oct 2012 16:45:27 -0400

ring-buffer: Add a 'dropped events' counter

The existing 'overrun' counter is incremented when the ring buffer wraps around, with overflow on (the default). We wanted a way to count requests lost from the buffer filling up with overflow off, too. I decided to add a new counter instead of retro-fitting the existing one because it seems like a different statistic to count conceptually, and also because of how the code was structured.

---
 include/linux/ring_buffer.h |    1 +
 kernel/trace/ring_buffer.c  |   41 +++++++++++++++++++++++++++++++++++------
 kernel/trace/trace.c        |    3 +++
 3 files changed, 39 insertions(+), 6 deletions(-)
include/linux/ring_buffer.h +1 -0
index 6c8835f..2007375 100644
@@ -166,6 +166,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer);
 unsigned long ring_buffer_entries_cpu(struct ring_buffer *buffer, int cpu);
 unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu);
 unsigned long ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu);
+unsigned long ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu);
 
 u64 ring_buffer_time_stamp(struct ring_buffer *buffer, int cpu);
 void ring_buffer_normalize_time_stamp(struct ring_buffer *buffer,
kernel/trace/ring_buffer.c +35 -6

81 lines not on this page · raw message

kernel/trace/trace.c +3 -0
index f6928ed..36c213f 100644
@@ -4385,6 +4385,9 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
 	usec_rem = do_div(t, USEC_PER_SEC);
 	trace_seq_printf(s, "now ts: %5llu.%06lu\n", t, usec_rem);
 
+	cnt = ring_buffer_dropped_events_cpu(tr->buffer, cpu);
+	trace_seq_printf(s, "dropped events: %ld\n", cnt);
+
 	count = simple_read_from_buffer(ubuf, count, ppos, s->buffer, s->len);
 
 	kfree(s);