All of lore.kernel.org
 help / color / mirror / Atom feed
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>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Theodore Tso <tytso@mit.edu>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Mathieu Desnoyers <compudj@krystal.dyndns.org>,
	Lai Jiangshan <laijs@cn.fujitsu.com>,
	"Martin J. Bligh" <mbligh@mbligh.org>,
	Christoph Hellwig <hch@infradead.org>,
	Li Zefan <lizf@cn.fujitsu.com>, Huang Ying <ying.huang@intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>,
	Masami Hiramatsu <mhiramat@redhat.com>
Subject: Re: [PATCH 3/3] ring-buffer: add design document
Date: Mon, 15 Jun 2009 02:05:58 +0200	[thread overview]
Message-ID: <20090615000557.GB7918@nowhere> (raw)
In-Reply-To: <alpine.DEB.2.00.0906140837370.16299@gandalf.stny.rr.com>

On Sun, Jun 14, 2009 at 08:39:03AM -0400, Steven Rostedt wrote:
> 
> On Sun, 14 Jun 2009, Frederic Weisbecker wrote:
> > > > > +
> > > > > +Now the writer can update the head page. This is also why the head page must
> > > > > +remain in UPDATE and only reset by the outer most writer. This prevents
> > > > > +the reader from seeing the incorrect head page.
> > > > > +
> > > > > +
> > > > > +(first writer)
> > > > > +
> > > > > +               A        B    tail page
> > > > > +               |        |        |
> > > > > +               v        v        v
> > > > > +    +---+    +---+    +---+    +---+
> > > > > +<---|   |--->|   |--->|   |--->|   |-H->
> > > > > +--->|   |<---|   |<---|   |<---|   |<---
> > > > > +    +---+    +---+    +---+    +---+
> > > > 
> > > > 
> > > > Even more tricky!
> > > > 
> > > > I just have a stupid question: why can't this be done
> > > > only through HEAD and NORMAL flags?
> > > > 
> > > > There is something certainly very obvious that I'm missing
> > > > with the point of the UPDATE flag.
> > > 
> > > If you can demonstrate how to do the above lockless with just HEAD and 
> > > NORMAL, then sure, I'm all ears ;-)
> > > 
> > > When we switch the HEAD to UPDATE, we stop the reader from moving forward 
> > > and being another thing to handle while we move the HEAD forward. A reader 
> > > does a cmpxchg to move the head too, and that cmpxchg will always fail if 
> > > the pointer is has UPDATE set. The reader will just spin until it 
> > > succeeds.
> > 
> > 
> > Aah, so it's here to protect against paralell readers from another cpu
> > reading the current cpu buffer, right?
> 
> Not readers, but reader. The reader side uses locks to serialize the
> accesses. The writer side is lockless.  But it is here to protect the 
> writers against a reader on another CPU.
> 
> -- Steve


Ok, my problem is that I've read this doc having in mind that the reader
we are talking about is always reading the buffer on the current cpu,
then a writer always preempt it. I forgot that a reader may also read
from another cpu.

Now I understand.

Thanks.


  reply	other threads:[~2009-06-15  0:06 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-10 19:53 [PATCH 0/3] [GIT PULL][for 2.6.32] lockless ring buffer Steven Rostedt
2009-06-10 19:53 ` [PATCH 1/3] ring-buffer: make the buffer a true circular link list Steven Rostedt
2009-06-11  1:12   ` Lai Jiangshan
2009-06-11  2:00     ` Steven Rostedt
2009-06-11  3:25       ` Lai Jiangshan
2009-06-11  3:35         ` Steven Rostedt
2009-06-10 19:53 ` [PATCH 2/3] ring-buffer: make lockless Steven Rostedt
2009-06-10 19:53 ` [PATCH 3/3] ring-buffer: add design document Steven Rostedt
2009-06-10 22:13   ` Mathieu Desnoyers
2009-06-11  1:55     ` Steven Rostedt
2009-06-11  3:51       ` Mathieu Desnoyers
2009-06-11  3:59         ` Mathieu Desnoyers
2009-06-11  4:15           ` Steven Rostedt
2009-06-11 18:09             ` Mathieu Desnoyers
2009-06-11  0:51   ` Huang Ying
2009-06-11  0:54     ` H. Peter Anvin
2009-06-11  1:58     ` Steven Rostedt
2009-06-11  2:33       ` Huang Ying
2009-06-11  2:38         ` Mathieu Desnoyers
2009-06-12  3:13           ` Huang Ying
2009-06-12  3:46             ` H. Peter Anvin
2009-06-11  3:15   ` Hidetoshi Seto
2009-06-11  3:25     ` Steven Rostedt
2009-06-13  1:54   ` Frederic Weisbecker
2009-06-13  2:16     ` Steven Rostedt
2009-06-13 22:36       ` Frederic Weisbecker
2009-06-14 12:39         ` Steven Rostedt
2009-06-15  0:05           ` Frederic Weisbecker [this message]
2009-06-15  0:56   ` Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2009-07-08 20:13 [PATCH 0/3] [GIT PULL] rebase of lockless ring buffer Steven Rostedt
2009-07-08 20:13 ` [PATCH 3/3] ring-buffer: add design document 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=20090615000557.GB7918@nowhere \
    --to=fweisbec@gmail.com \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=compudj@krystal.dyndns.org \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mbligh@mbligh.org \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=seto.hidetoshi@jp.fujitsu.com \
    --cc=tglx@linutronix.de \
    --cc=tytso@mit.edu \
    --cc=ying.huang@intel.com \
    /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.