[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <36155.1223535138@turing-police.cc.vt.edu>
Date: Thu, 09 Oct 2008 02:52:18 -0400
From: Valdis.Kletnieks@...edu
To: Nick Piggin <nickpiggin@...oo.com.au>
Cc: Randy Dunlap <randy.dunlap@...cle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Ben Hutchings <bhutchings@...arflare.com>,
Mikulas Patocka <mpatocka@...hat.com>,
linux-kernel@...r.kernel.org, linux-mm@...r.kernel.org
Subject: Re: [PATCH] documentation: explain memory barriers
On Fri, 10 Oct 2008 04:35:47 +1100, Nick Piggin said:
> On Thursday 09 October 2008 12:50, Valdis.Kletnieks@...edu wrote:
> > On Wed, 08 Oct 2008 18:12:23 PDT, Randy Dunlap said:
> > > +
> > > +24: All memory barriers {e.g., barrier(), rmb(), wmb()} need a comment
> > > in the + source code that explains the logic of what they are doing
> > > and why.
> >
> > "what they are doing" will almost always be "flush value to RAM" or
> > similar.
>
> Memory barriers don't flush anything anywhere.
That's what I get for commenting on stuff when I'm into a 40-hour week by
Wednesday. :)
I was speaking of the generic programmer who does stuff like:
x = 10; /* set x to 10 */
for "what they are doing". You know the type. ;)
"flush value to RAM", "force memory barrier operation", and I think I've seen
a few kzalloc()'s that have "allocate zero'ed memory" on them. "what they are
doing" is usually not worth writing down, but being verbose for the *why*
is almost always good, especially for things like memory barriers that
almost nobody can get their brains wrapped around (how many flame-fests per
year do we have about "volatile"? ;)
> /*
> * If we don't do a wmb() here, the store to the RBFROBNIZ,
> * above, might reach the device before the store X, below.
> *
> * If that happens, then the XU293 card will get confused
> * and wedge the hardware...
> */
> wmb();
>
> If you don't comment like that, then how does the reader know that the wmb
> is not *also* supposed to order the store with any other of the limitless
> subsequent stores until the next memory ordering operation? Or any of the
> previous stores since the last one?
Even better (as I missed the "also supposed to know" case). My general point
was that a concrete example would improve Randy's original patch by showing
what sort of things should be in the comment, and your correction pointed
out *why* a concrete example was needed. ;)
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists