lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 15 Jun 2009 02:05:58 +0200
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...e.hu>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Peter Zijlstra <peterz@...radead.org>,
	Theodore Tso <tytso@....edu>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Mathieu Desnoyers <compudj@...stal.dyndns.org>,
	Lai Jiangshan <laijs@...fujitsu.com>,
	"Martin J. Bligh" <mbligh@...igh.org>,
	Christoph Hellwig <hch@...radead.org>,
	Li Zefan <lizf@...fujitsu.com>,
	Huang Ying <ying.huang@...el.com>,
	"H. Peter Anvin" <hpa@...or.com>,
	Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>,
	Masami Hiramatsu <mhiramat@...hat.com>
Subject: Re: [PATCH 3/3] ring-buffer: add design document

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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ