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 14:43:24 +0200 [thread overview]
Message-ID: <20090501124317.GA6011@nowhere> (raw)
In-Reply-To: <alpine.DEB.2.00.0904302313120.20374@gandalf.stny.rr.com>
On Thu, Apr 30, 2009 at 11:23:52PM -0400, Steven Rostedt wrote:
>
> On Fri, 1 May 2009, Frederic Weisbecker wrote:
>
> > 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 :)
> >
>
> I have a bunch of ascii art that explains all this in my documentation
> that details the lockless version.
>
> The commit page is the page that holds the last full commit.
>
> ring_buffer_unlock_commit()
>
> On ring_buffer_lock_reserve() we reserve some data after the last commit.
>
> commit
> |
> V
> +---+ +---+ +---+ +---+
> <---| |--->| |--->| |--->| |--->
> --->| |<---| |<---| |<---| |<---
> +---+ +---+ +---+ +---+
> ^
> |
> tail (writer)
>
> We do not disable interrupts (or softirqs) between
> ring_buffer_lock_reserve and ring_buffer_unlock_commit. If we get
> preempted by an interrupt or softirq, and it writes to the ring buffer, it
> will move the tail, but not the commit. Only the outer most writer (non
> nested) can do that:
>
> commit
> |
> V
> +---+ +---+ +---+ +---+
> <---| |--->| |--->| |--->| |--->
> --->| |<---| |<---| |<---| |<---
> +---+ +---+ +---+ +---+
> ^
> |
> tail (writer)
Aah, now I understand what does rb_set_commit_to_write()
>
> But lets say we are running the function graph tracer along with the event
> tracer. And to save space, we shrunk the ring buffer down to a few pages.
> (more than 2) We are writing an event and get preempted by an interrupt
> followed by several softirqs, and these softirqs perform a lot of
> functions. It can push the tail all around the buffer:
>
> commit
> |
> V
> +---+ +---+ +---+ +---+
> <---| |--->| |--->| |--->| |--->
> --->| |<---| |<---| |<---| |<---
> +---+ +---+ +---+ +---+
> ^
> |
> tail (writer)
>
>
> This happens before we even finish the original write. But the tail can
> not push the commit forward, because when we fall out of this stack of
> writers, that original writer is in the process of writing into the ring
> buffer. Thus we need to drop any more entries that want to push the tail
> pointer onto the commit pointer.
>
> Thus, when this happens we record it with commit_overrun.
>
> -- Steve
Ok thanks for these explanations!
I hope your lockless ring buffer will be posted soon (any news about
the patent?) :-)
next prev parent reply other threads:[~2009-05-01 12:43 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
2009-05-01 3:23 ` Steven Rostedt
2009-05-01 12:43 ` Frederic Weisbecker [this message]
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=20090501124317.GA6011@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.