From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Frederic Weisbecker <fweisbec@gmail.com>
Subject: [PATCH 06/11] ring-buffer: Add stats field for amount read from trace ring buffer
Date: Sat, 02 Feb 2013 09:18:48 -0500 [thread overview]
Message-ID: <20130202141955.701304493@goodmis.org> (raw)
In-Reply-To: 20130202141842.189550803@goodmis.org
[-- Attachment #1: Type: text/plain, Size: 2797 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
Add a stat about the number of events read from the ring buffer:
# cat /debug/tracing/per_cpu/cpu0/stats
entries: 39869
overrun: 870512
commit overrun: 0
bytes: 1449912
oldest event ts: 6561.368690
now ts: 6565.246426
dropped events: 0
read events: 112 <-- Added
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/linux/ring_buffer.h | 1 +
kernel/trace/ring_buffer.c | 18 ++++++++++++++++++
kernel/trace/trace.c | 3 +++
3 files changed, 22 insertions(+)
diff --git a/include/linux/ring_buffer.h b/include/linux/ring_buffer.h
index 519777e..1342e69 100644
--- a/include/linux/ring_buffer.h
+++ b/include/linux/ring_buffer.h
@@ -167,6 +167,7 @@ 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);
+unsigned long ring_buffer_read_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,
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 13950d9..7244acd 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3103,6 +3103,24 @@ ring_buffer_dropped_events_cpu(struct ring_buffer *buffer, int cpu)
EXPORT_SYMBOL_GPL(ring_buffer_dropped_events_cpu);
/**
+ * ring_buffer_read_events_cpu - get the number of events successfully read
+ * @buffer: The ring buffer
+ * @cpu: The per CPU buffer to get the number of events read
+ */
+unsigned long
+ring_buffer_read_events_cpu(struct ring_buffer *buffer, int cpu)
+{
+ struct ring_buffer_per_cpu *cpu_buffer;
+
+ if (!cpumask_test_cpu(cpu, buffer->cpumask))
+ return 0;
+
+ cpu_buffer = buffer->buffers[cpu];
+ return cpu_buffer->read;
+}
+EXPORT_SYMBOL_GPL(ring_buffer_read_events_cpu);
+
+/**
* ring_buffer_entries - get the number of entries in a buffer
* @buffer: The ring buffer
*
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index d399592..90a1c71 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -4430,6 +4430,9 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
cnt = ring_buffer_dropped_events_cpu(tr->buffer, cpu);
trace_seq_printf(s, "dropped events: %ld\n", cnt);
+ cnt = ring_buffer_read_events_cpu(tr->buffer, cpu);
+ trace_seq_printf(s, "read events: %ld\n", cnt);
+
count = simple_read_from_buffer(ubuf, count, ppos, s->buffer, s->len);
kfree(s);
--
1.7.10.4
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
next prev parent reply other threads:[~2013-02-02 14:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-02 14:18 [PATCH 00/11] [GIT PULL] tracing: Various tracing fixes and enhancements Steven Rostedt
2013-02-02 14:18 ` [PATCH 01/11] tracing: Mark tracing_dentry_percpu() static Steven Rostedt
2013-02-02 14:18 ` [PATCH 02/11] tracing: Remove tracepoint sample code Steven Rostedt
2013-02-02 14:18 ` [PATCH 03/11] tracing: Use __this_cpu_inc/dec operation instead of __get_cpu_var Steven Rostedt
2013-02-02 14:18 ` [PATCH 04/11] tracing: Remove second iterator initializer Steven Rostedt
2013-02-02 14:18 ` [PATCH 05/11] tracing/fgraph: Adjust fgraph depth before calling trace return callback Steven Rostedt
2013-02-02 14:18 ` Steven Rostedt [this message]
2013-02-02 14:18 ` [PATCH 07/11] tracing: Use sched_clock_cpu for trace_clock_global Steven Rostedt
2013-02-02 14:18 ` [PATCH 08/11] tracing: Replace static old_tracer check of tracer name Steven Rostedt
2013-02-02 14:18 ` [PATCH 09/11] tracing: Make a snapshot feature available from userspace Steven Rostedt
2013-02-02 14:18 ` [PATCH 10/11] tracing: Add documentation of snapshot utility Steven Rostedt
2013-02-02 14:18 ` [PATCH 11/11] tracing: Init current_trace to nop_trace and remove NULL checks Steven Rostedt
2013-02-03 10:15 ` [PATCH 00/11] [GIT PULL] tracing: Various tracing fixes and enhancements Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130202141955.701304493@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.