[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.0.999.0708171201130.30176@woody.linux-foundation.org>
Date: Fri, 17 Aug 2007 12:08:31 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Chris Friesen <cfriesen@...tel.com>
cc: Nick Piggin <piggin@...erone.com.au>,
Satyam Sharma <satyam@...radead.org>,
Herbert Xu <herbert@...dor.apana.org.au>,
Paul Mackerras <paulus@...ba.org>,
Christoph Lameter <clameter@....com>,
Chris Snook <csnook@...hat.com>,
Ilpo Jarvinen <ilpo.jarvinen@...sinki.fi>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Stefan Richter <stefanr@...6.in-berlin.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-arch@...r.kernel.org, Netdev <netdev@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>, ak@...e.de,
heiko.carstens@...ibm.com, David Miller <davem@...emloft.net>,
schwidefsky@...ibm.com, wensong@...ux-vs.org, horms@...ge.net.au,
wjiang@...ilience.com, zlynx@....org, rpjday@...dspring.com,
jesper.juhl@...il.com, segher@...nel.crashing.org
Subject: Re: [PATCH 0/24] make atomic_read() behave consistently across all
architectures
On Fri, 17 Aug 2007, Chris Friesen wrote:
>
> I assume you mean "except for IO-related code and 'random' values like
> jiffies" as you mention later on?
Yes. There *are* valid uses for "volatile", but they have remained the
same for the last few years:
- "jiffies"
- internal per-architecture IO implementations that can do them as normal
stores.
> I assume other values set in interrupt handlers would count as "random"
> from a volatility perspective?
I don't really see any valid case. I can imagine that you have your own
"jiffy" counter in a driver, but what's the point, really? I'd suggest not
using volatile, and using barriers instead.
>
> > So anybody who argues for "volatile" fixing bugs is fundamentally
> > incorrect. It does NO SUCH THING. By arguing that, such people only
> > show that you have no idea what they are talking about.
> What about reading values modified in interrupt handlers, as in your
> "random" case? Or is this a bug where the user of atomic_read() is
> invalidly expecting a read each time it is called?
Quite frankly, the biggest reason for using "volatile" on jiffies was
really historic. So even the "random" case is not really a very strong
one. You'll notice that anybody who is actually careful will be using
sequence locks for the jiffy accesses, if only because the *full* jiffy
count is actually a 64-bit value, and so you cannot get it atomically on a
32-bit architecture even on a single CPU (ie a timer interrupt might
happen in between reading the low and the high word, so "volatile" is only
used for the low 32 bits).
So even for jiffies, we actually have:
extern u64 __jiffy_data jiffies_64;
extern unsigned long volatile __jiffy_data jiffies;
where the *real* jiffies is not volatile: the volatile one is using linker
tricks to alias the low 32 bits:
- arch/i386/kernel/vmlinux.lds.S:
...
jiffies = jiffies_64;
...
and the only reason we do all these games is (a) it works and (b) it's
legacy.
Note how I do *not* say "(c) it's a good idea".
Linus
-
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