From: Grant Grundler <grundler@parisc-linux.org>
To: John David Anglin <dave@hiauly1.hia.nrc.ca>
Cc: parisc-linux@lists.parisc-linux.org
Subject: Re: [parisc-linux] some other small bitops.h suggestion?
Date: Sat, 16 Apr 2005 11:27:21 -0600 [thread overview]
Message-ID: <20050416172721.GA11765@colo.lackof.org> (raw)
In-Reply-To: <200504152141.j3FLfMXi025954@hiauly1.hia.nrc.ca>
On Fri, Apr 15, 2005 at 05:41:22PM -0400, John David Anglin wrote:
> > My take is "volatile" is just a way to tell gcc something about the
> > code/data that it can't see. I'm not going to quibble with linus
> > about whether data is volatile or code is volatile. I think in some
> > cases it's one (e.g accessing memory mapped HW) or the other
> > (accessing shared data). Key thing is gcc be able to optimize code
> > but not remove it (especially in the latter case).
>
> The problem here is that there are some conventions regarding the use
> of "volatile" in GCC C that are rather poorly documented. You might
> look at this discussion regarding volatile and C++ to get a flavor
> for what I mean <http://gcc.gnu.org/ml/gcc/2005-04/msg00724.html>.
In this followup, I think Nathan Sidwell got at least one bit:
| It seems to me that threads require barriers _within_ the abstract machine,
| and currently there is no mechanism to specify just that. Volatile is all
| we have, and AFAICT those are only ordered WRT other volatile accesses
| separated by a sequence point.
(See http://gcc.gnu.org/ml/gcc/2005-04/msg00748.html)
And that's a difference: the kernel has defined a set of barriers.
Linux kernel generally doesn't depend on current semantics of volatile
for accessing memory mapped IO.
At least I don't think it does since ia64-linux is using ld.acq
and st.rel instructions today. While the compiler is observing
the ordering, the CPU may not. e.g. The CPU doesn't wait for a
regular store to complete before starting sucessive ld.acq.
This is a rare for IO drivers to do this. More discussion about
volatile and acq/rel semantics in "IA-64 Linux Kernel" by
David Mosberger and Stephane Eranian.
I learned one more thing about ia64 not in the book when trying
to understand how ld.rel works WRT to fixing posted write problems
(st.rel). I summarize it in my OLS2004 paper:
http://iou.parisc-linux.org/ols2004/www/
See http://iou.parisc-linux.org/ols2004/www/2_2_Eh_Memory_Reads.html
"Memory ordering imposes no constraint on non-load/store instructions."
This is critical for changing CPU state (enable/disable I-bit) or
reading CPU state (e.g. ITC).
ia64 has a weakly ordered memory subsystem but executes instructions
in order. parisc is strongly ordered for both and is less complicated
in this regard. I think because of this parisc could use volatile
keyword for telling the compiler certain instructions *must* be kept
in the stream, and then use memory barriers to constrain how the
optimizer can reorder the instruction stream.
But changing the semantics of volatile will break some code
in both the kernel and in multithreaded applications.
I strongly suspect this is going to need to fall into
the "use with caution" compiler flags (like -O4).
I'm glad they are having this discussion now *before*
widespread adoption of RDMA technologies.
hth,
grant
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
prev parent reply other threads:[~2005-04-16 17:27 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-03 14:32 [parisc-linux] pthread problems - test program Randolph Chung
2005-04-03 19:07 ` John David Anglin
2005-04-03 20:24 ` John David Anglin
2005-04-04 0:53 ` Randolph Chung
2005-04-03 20:41 ` John David Anglin
2005-04-04 0:50 ` Randolph Chung
2005-04-05 0:00 ` Carlos O'Donell
2005-04-05 0:02 ` Carlos O'Donell
2005-04-05 6:00 ` Carlos O'Donell
2005-04-06 20:12 ` John David Anglin
2005-04-06 20:25 ` Carlos O'Donell
2005-04-06 20:52 ` John David Anglin
2005-04-06 20:28 ` Carlos O'Donell
2005-04-07 2:45 ` John David Anglin
2005-04-08 2:56 ` John David Anglin
2005-04-08 21:29 ` Carlos O'Donell
2005-04-08 22:54 ` John David Anglin
[not found] ` <20050409055852.GM1833@baldric.uwo.ca>
2005-04-09 6:37 ` Carlos O'Donell
2005-04-09 14:44 ` John David Anglin
2005-04-09 14:48 ` Randolph Chung
2005-04-09 23:44 ` John David Anglin
2005-04-15 14:16 ` Carlos O'Donell
2005-04-15 15:48 ` John David Anglin
2005-04-09 0:13 ` John David Anglin
2005-04-09 6:38 ` Carlos O'Donell
2005-04-09 15:01 ` John David Anglin
2005-04-15 14:16 ` Carlos O'Donell
2005-04-06 1:21 ` John David Anglin
2005-04-06 4:59 ` Carlos O'Donell
2005-04-06 8:42 ` John David Anglin
2005-04-06 16:11 ` John David Anglin
2005-04-06 18:13 ` Carlos O'Donell
2005-04-06 18:37 ` John David Anglin
2005-04-06 19:36 ` Carlos O'Donell
2005-04-06 19:36 ` Carlos O'Donell
2005-04-05 9:28 ` [parisc-linux] some other small bitops.h suggestion? Joel Soete
2005-04-13 6:14 ` Grant Grundler
2005-04-13 6:58 ` Joel Soete
2005-04-13 17:47 ` Grant Grundler
[not found] ` <20050414013105.GB17749@tausq.org>
2005-04-14 1:33 ` Randolph Chung
2005-04-14 5:07 ` Grant Grundler
2005-04-14 14:39 ` John David Anglin
2005-04-15 19:27 ` Grant Grundler
2005-04-15 21:41 ` John David Anglin
2005-04-16 17:27 ` Grant Grundler [this message]
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=20050416172721.GA11765@colo.lackof.org \
--to=grundler@parisc-linux.org \
--cc=dave@hiauly1.hia.nrc.ca \
--cc=parisc-linux@lists.parisc-linux.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