From: Chris Snook <csnook@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: akpm@linux-foundation.org, ak@suse.de, heiko.carstens@de.ibm.com,
davem@davemloft.net, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, schwidefsky@de.ibm.com,
wensong@linux-vs.org, horms@verge.net.au, wjiang@resilience.com,
cfriesen@nortel.com, zlynx@acm.org
Subject: Re: [PATCH] make atomic_t volatile on all architectures
Date: Thu, 09 Aug 2007 03:31:10 -0400 [thread overview]
Message-ID: <46BAC2BE.1090106@redhat.com> (raw)
In-Reply-To: <alpine.LFD.0.999.0708082116060.25146@woody.linux-foundation.org>
Linus Torvalds wrote:
>
> On Wed, 8 Aug 2007, Chris Snook wrote:
>> Some architectures currently do not declare the contents of an atomic_t to be
>> volatile. This causes confusion since atomic_read() might not actually read
>> anything if an optimizing compiler re-uses a value stored in a register, which
>> can break code that loops until something external changes the value of an
>> atomic_t.
>
> I'd be *much* happier with "atomic_read()" doing the "volatile" instead.
>
> The fact is, volatile on data structures is a bug. It's a wart in the C
> language. It shouldn't be used.
>
> Volatile accesses in *code* can be ok, and if we have "atomic_read()"
> expand to a "*(volatile int *)&(x)->value", then I'd be ok with that.
>
> But marking data structures volatile just makes the compiler screw up
> totally, and makes code for initialization sequences etc much worse.
>
> Linus
Fair enough. Casting to (volatile int *) will give us the behavior people
expect when using atomic_t without needing to use inefficient barriers.
While we have the hood up, should we convert all the atomic_t's to non-volatile
and put volatile casts in all the atomic_reads? I don't know enough about the
various arches to say with confidence that those changes alone will preserve
existing behavior. We might need some arch-specific tweaking of the atomic
operations.
-- Chris
next prev parent reply other threads:[~2007-08-09 7:38 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-08 23:07 [PATCH] make atomic_t volatile on all architectures Chris Snook
2007-08-08 23:18 ` Jesper Juhl
2007-08-08 23:31 ` Chris Snook
2007-08-08 23:51 ` Jesper Juhl
2007-08-08 23:25 ` Lennert Buytenhek
2007-08-08 23:35 ` Chris Snook
2007-08-09 1:03 ` Herbert Xu
2007-08-09 1:48 ` David Miller
2007-08-09 3:47 ` Paul E. McKenney
2007-08-09 7:47 ` Chris Snook
2007-08-09 8:30 ` Herbert Xu
2007-08-09 11:44 ` Chris Snook
2007-08-09 4:18 ` Linus Torvalds
2007-08-09 4:59 ` Jerry Jiang
2007-08-09 7:31 ` Chris Snook [this message]
2007-08-09 8:14 ` Heiko Carstens
2007-08-09 17:36 ` Chuck Ebbert
2007-08-09 17:55 ` Linus Torvalds
2007-08-09 18:20 ` Martin Schwidefsky
2007-08-12 5:53 ` Segher Boessenkool
2007-08-12 6:09 ` Linus Torvalds
2007-08-12 9:48 ` Martin Schwidefsky
2007-08-12 9:54 ` Linus Torvalds
2007-08-12 16:30 ` Segher Boessenkool
2007-08-12 18:11 ` Linus Torvalds
2007-08-12 19:13 ` Segher Boessenkool
2007-08-12 10:27 ` Segher Boessenkool
2007-08-12 17:59 ` Linus Torvalds
2007-08-12 9:47 ` Martin Schwidefsky
2007-08-12 10:35 ` Segher Boessenkool
2007-08-09 17:57 ` Martin Schwidefsky
[not found] <8Q2Pg-8uV-23@gated-at.bofh.it>
[not found] ` <8Q7Fa-7rJ-1@gated-at.bofh.it>
[not found] ` <8Q8rD-hh-7@gated-at.bofh.it>
2007-08-09 9:10 ` Bodo Eggert
2007-08-09 9:18 ` Jerry Jiang
2007-08-09 15:00 ` Linus Torvalds
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=46BAC2BE.1090106@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=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=schwidefsky@de.ibm.com \
--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).