From: Sergei Organov <osv@javad.com>
To: "linux-os \(Dick Johnson\)" <linux-os@analogic.com>
Cc: "David Howells" <dhowells@redhat.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Document Linux's memory barriers [try #4]
Date: Wed, 15 Mar 2006 12:09:43 +0300 [thread overview]
Message-ID: <87bqw8axbc.fsf@javad.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0603141601550.9216@chaos.analogic.com> (linux-os@analogic.com's message of "Tue, 14 Mar 2006 16:11:36 -0500")
"linux-os \(Dick Johnson\)" <linux-os@analogic.com> writes:
> On Tue, 14 Mar 2006, David Howells wrote:
>
>> Sergei Organov <osv@javad.com> wrote:
>>
>>> "You can prevent an `asm' instruction from being deleted by writing the
>>> keyword `volatile' after the `asm'. [...]
>>> The `volatile' keyword indicates that the instruction has important
>>> side-effects. GCC will not delete a volatile `asm' if it is reachable.
>>> (The instruction can still be deleted if GCC can prove that
>>> control-flow will never reach the location of the instruction.) *Note
>>> that even a volatile `asm' instruction can be moved relative to other
>>> code, including across jump instructions.*"
>>
>> Ummm... If "asm volatile" statements don't form compiler barriers, then how do
>> you specify a compiler barrier? Or is that what the "memory" bit in:
>>
>> #define barrier() __asm__ __volatile__("": : :"memory")
>>
>> does?
>>
>> David
>
> Yeh. This is the problem (restated) that I mentioned the other
> day when you must do a dummy read of the PCI/Bus to flush all
> the writes, to some variable that gcc can't decide isn't
> important. That's why (void)readl(PCI_STATUS) won't work
> (with gcc 3.3.3 anyway).
If it indeed doesn't, then it's a bug in GCC. GCC shouldn't throw
away volatile accesses. I've already quoted the GCC manual for you:
" Less obvious expressions are where something which looks like an access
is used in a void context. An example would be,
volatile int *src = SOMEVALUE;
*src;
With C, such expressions are rvalues, and as rvalues cause a read of
the object, GCC interprets this as a read of the volatile being pointed
to. "
-- Sergei.
next prev parent reply other threads:[~2006-03-15 9:09 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-09 20:29 [PATCH] Document Linux's memory barriers [try #4] David Howells
2006-03-09 23:34 ` Paul Mackerras
2006-03-09 23:45 ` Michael Buesch
2006-03-09 23:56 ` Linus Torvalds
2006-03-10 0:07 ` Michael Buesch
2006-03-10 0:48 ` Alan Cox
2006-03-10 0:54 ` Paul Mackerras
2006-03-10 15:19 ` David Howells
2006-03-11 0:01 ` Paul Mackerras
2006-03-10 5:28 ` Nick Piggin
2006-03-15 11:10 ` David Howells
2006-03-15 11:51 ` Nick Piggin
2006-03-15 13:47 ` David Howells
2006-03-15 23:21 ` Nick Piggin
2006-03-12 17:15 ` Eric W. Biederman
2006-03-14 21:26 ` David Howells
2006-03-14 21:48 ` Paul Mackerras
2006-03-14 23:59 ` David Howells
2006-03-15 0:20 ` Linus Torvalds
2006-03-15 1:19 ` David Howells
2006-03-15 1:47 ` Linus Torvalds
2006-03-15 1:25 ` Nick Piggin
2006-03-15 0:54 ` Paul Mackerras
2006-03-13 12:32 ` Sergei Organov
2006-03-14 20:31 ` David Howells
2006-03-14 21:11 ` linux-os (Dick Johnson)
2006-03-15 9:09 ` Sergei Organov [this message]
2006-03-15 9:04 ` Sergei Organov
2006-03-14 20:35 ` David Howells
2006-03-15 9:11 ` Sergei Organov
2006-03-15 14:23 ` [PATCH] Document Linux's memory barriers [try #5] David Howells
[not found] ` <20060315200956.4a9e2cb3.akpm@osdl.org>
2006-03-16 11:50 ` David Howells
2006-03-16 17:18 ` Linus Torvalds
2006-03-17 1:20 ` Nick Piggin
2006-03-16 23:17 ` Paul E. McKenney
2006-03-16 23:55 ` Linus Torvalds
2006-03-17 1:29 ` Paul E. McKenney
2006-03-17 5:32 ` Linus Torvalds
2006-03-17 6:23 ` Paul E. McKenney
2006-03-23 18:34 ` David Howells
2006-03-23 19:28 ` Linus Torvalds
2006-03-23 22:26 ` Paul E. McKenney
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=87bqw8axbc.fsf@javad.com \
--to=osv@javad.com \
--cc=dhowells@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
/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