From: Frederic Weisbecker <fweisbec@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 2/3] tracing: export stats of ring buffers to userspace
Date: Fri, 1 May 2009 05:08:49 +0200 [thread overview]
Message-ID: <20090501030848.GA19883@nowhere> (raw)
In-Reply-To: <20090501022402.302620162@goodmis.org>
On Thu, Apr 30, 2009 at 10:22:12PM -0400, Steven Rostedt wrote:
> From: Steven Rostedt <srostedt@redhat.com>
>
> This patch adds stats to the ftrace ring buffers:
>
> # cat /debugfs/tracing/per_cpu/cpu0/stats
> entries: 42360
> overrun: 30509326
> commit overrun: 0
> nmi dropped: 0
>
> Where entries are the total number of data entries in the buffer.
>
> overrun is the number of entries not consumed and were overwritten by
> the writer.
>
> commit overrun is the number of entries dropped due to nested writers
> wrapping the buffer before the initial writer finished the commit.
I feel a bit confused with this one.
How such a thing can happen? The write page and the commit page
are not the same. So is that because we can have (ring-buffer inspires
all of us to try ascii-art):
Write page Commit page (which becomes new write page)
------------------------------------ -----------------
| | | | |
Writer 1 | Writer 2 | Writer n | | Writer n + 1 | .....
reserved | reserved | reserved | | reserved |
----------------------------------- ----------------
| ^
| |
---------------- Was supposed to commit here--|
I know this is silly, my picture seem to show a data copy whereas
the ring buffer deals with page pointers.
But the commit page on the ring buffer is a mistery for me.
Just because you haven't drawn in in ascii in your comments :)
Thanks.
Frederic.
> nmi dropped is the number of entries dropped due to the ring buffer
> lock being held when an nmi was going to write to the ring buffer.
> Note, this field will be meaningless and will go away when the ring
> buffer becomes lockless.
>
> [ Impact: let userspace know what is happening in the ring buffers ]
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> kernel/trace/trace.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 42 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index f5427e0..74df029 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -3595,6 +3595,45 @@ static const struct file_operations tracing_buffers_fops = {
> .llseek = no_llseek,
> };
>
> +static ssize_t
> +tracing_stats_read(struct file *filp, char __user *ubuf,
> + size_t count, loff_t *ppos)
> +{
> + unsigned long cpu = (unsigned long)filp->private_data;
> + struct trace_array *tr = &global_trace;
> + struct trace_seq *s;
> + unsigned long cnt;
> +
> + s = kmalloc(sizeof(*s), GFP_ATOMIC);
> + if (!s)
> + return ENOMEM;
> +
> + trace_seq_init(s);
> +
> + cnt = ring_buffer_entries_cpu(tr->buffer, cpu);
> + trace_seq_printf(s, "entries: %ld\n", cnt);
> +
> + cnt = ring_buffer_overrun_cpu(tr->buffer, cpu);
> + trace_seq_printf(s, "overrun: %ld\n", cnt);
> +
> + cnt = ring_buffer_commit_overrun_cpu(tr->buffer, cpu);
> + trace_seq_printf(s, "commit overrun: %ld\n", cnt);
> +
> + cnt = ring_buffer_nmi_dropped_cpu(tr->buffer, cpu);
> + trace_seq_printf(s, "nmi dropped: %ld\n", cnt);
> +
> + count = simple_read_from_buffer(ubuf, count, ppos, s->buffer, s->len);
> +
> + kfree(s);
> +
> + return count;
> +}
> +
> +static const struct file_operations tracing_stats_fops = {
> + .open = tracing_open_generic,
> + .read = tracing_stats_read,
> +};
> +
> #ifdef CONFIG_DYNAMIC_FTRACE
>
> int __weak ftrace_arch_read_dyn_info(char *buf, int size)
> @@ -3708,6 +3747,9 @@ static void tracing_init_debugfs_percpu(long cpu)
>
> trace_create_file("trace_pipe_raw", 0444, d_cpu,
> (void *) cpu, &tracing_buffers_fops);
> +
> + trace_create_file("stats", 0444, d_cpu,
> + (void *) cpu, &tracing_stats_fops);
> }
>
> #ifdef CONFIG_FTRACE_SELFTEST
> --
> 1.6.2.1
>
> --
next prev parent reply other threads:[~2009-05-01 3:09 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-01 2:22 [PATCH 0/3] [GIT PULL] tracing/ringbuffer: updates for tip Steven Rostedt
2009-05-01 2:22 ` [PATCH 1/3] ring-buffer: add counters for commit overrun and nmi dropped entries Steven Rostedt
2009-05-01 3:00 ` Andrew Morton
2009-05-01 3:11 ` Steven Rostedt
2009-05-01 3:22 ` Andrew Morton
2009-05-01 3:33 ` Steven Rostedt
2009-05-01 3:38 ` Andrew Morton
2009-05-01 3:55 ` Steven Rostedt
2009-05-01 2:22 ` [PATCH 2/3] tracing: export stats of ring buffers to userspace Steven Rostedt
2009-05-01 3:08 ` Frederic Weisbecker [this message]
2009-05-01 3:23 ` Steven Rostedt
2009-05-01 12:43 ` Frederic Weisbecker
2009-05-01 2:22 ` [PATCH 3/3] ring-buffer: make cpu buffer entries counter atomic Steven Rostedt
2009-05-01 3:06 ` Andrew Morton
2009-05-01 3:28 ` Steven Rostedt
2009-05-01 11:50 ` Ingo Molnar
2009-05-01 13:42 ` Frederic Weisbecker
2009-05-01 14:28 ` Steven Rostedt
2009-05-01 22:10 ` Frederic Weisbecker
2009-05-01 14:23 ` Steven Rostedt
2009-05-01 16:14 ` Steven Rostedt
2009-05-01 16:20 ` Ingo Molnar
2009-05-01 16:31 ` Steven Rostedt
2009-05-01 16:32 ` Steven Rostedt
2009-05-01 16:52 ` Ingo Molnar
2009-05-01 17:11 ` Steven Rostedt
2009-05-01 17:14 ` Ingo Molnar
2009-05-01 17:36 ` Steven Rostedt
2009-05-01 17:42 ` Ingo Molnar
2009-05-01 17:56 ` Steven Rostedt
2009-05-01 21:17 ` Steven Rostedt
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=20090501030848.GA19883@nowhere \
--to=fweisbec@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.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.