From: Chris Snook <csnook@redhat.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: wjiang@resilience.com, wensong@linux-vs.org,
heiko.carstens@de.ibm.com, linux-kernel@vger.kernel.org,
ak@suse.de, cfriesen@nortel.com, netdev@vger.kernel.org,
horms@verge.net.au, akpm@linux-foundation.org,
linux-arch@vger.kernel.org, torvalds@linux-foundation.org,
schwidefsky@de.ibm.com, davem@davemloft.net, zlynx@acm.org,
rpjday@mindspring.com, jesper.juhl@gmail.com
Subject: Re: [PATCH 24/24] document volatile atomic_read() behavior
Date: Thu, 09 Aug 2007 12:26:37 -0400 [thread overview]
Message-ID: <46BB403D.10202@redhat.com> (raw)
In-Reply-To: <8f6bb8a9e4f2819a161d732bdb6c70c0@kernel.crashing.org>
Segher Boessenkool wrote:
>> Historically this has been
>> +accomplished by declaring the counter itself to be volatile, but the
>> +ambiguity of the C standard on the semantics of volatile make this
>> practice
>> +vulnerable to overly creative interpretation by compilers.
>
> It's even worse when accessing through a volatile casted pointer;
> see for example the recent(*) GCC bugs in that area.
>
> (*) Well, not _all_ that recent. No one should be using the 3.x
> series anymore, right?
>
>> Explicit
>> +casting in atomic_read() ensures consistent behavior across
>> architectures
>> +and compilers.
>
> Even modulo compiler bugs, what makes you believe that?
When you declare a variable volatile, you don't actually tell the compiler where
you want to override its default optimization behavior, giving it some freedom
to guess your intentions incorrectly. When you put the cast on the data access
itself, there is no question about precisely where in the code you want to
override the compiler's default optimization behavior. If the compiler doesn't
do what you want with a volatile declaration, it might have a plausible excuse
in the ambiguity of the C standard. If the compiler doesn't do what you want in
a cast specific to a single dereference, it's just plain broken. We try to be
compatible with plausibly correct compilers, but if they're completely broken,
we're screwed no matter what.
-- Chris
next prev parent reply other threads:[~2007-08-09 16:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-09 14:24 [PATCH 24/24] document volatile atomic_read() behavior Chris Snook
2007-08-09 15:59 ` Segher Boessenkool
2007-08-09 16:26 ` Chris Snook [this message]
2007-08-09 19:42 ` Segher Boessenkool
2007-08-09 20:05 ` Chris Snook
2007-08-09 22:34 ` Segher Boessenkool
2007-08-09 20:10 ` Chris Friesen
2007-08-09 22:23 ` Segher Boessenkool
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=46BB403D.10202@redhat.com \
--to=csnook@redhat.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=cfriesen@nortel.com \
--cc=davem@davemloft.net \
--cc=heiko.carstens@de.ibm.com \
--cc=horms@verge.net.au \
--cc=jesper.juhl@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rpjday@mindspring.com \
--cc=schwidefsky@de.ibm.com \
--cc=segher@kernel.crashing.org \
--cc=torvalds@linux-foundation.org \
--cc=wensong@linux-vs.org \
--cc=wjiang@resilience.com \
--cc=zlynx@acm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).