linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Simon Richter <Simon.Richter@hogyros.de>
To: linuxppc-dev@ozlabs.org
Subject: Re: Is volatile always verboten for FSL QE structures?
Date: Sat, 3 Oct 2009 11:55:37 +0200	[thread overview]
Message-ID: <20091003095537.GA15992@honey.hogyros.de> (raw)
In-Reply-To: <20091002200848.06be4c5a@xilun.lan.proformatique.com>

Hi,

> > >> 'volatile' just doesn't really do what you think it should do.  The
> > >> PowerPC architecture is too complicated w.r.t. ordering of reads and
> > >> writes.  In other words, you can't trust it.

It's not sufficient on PowerPC.

It might be necessary, depending on the compiler's mood for moving stuff
out of loops.

Consider:

| unsigned int *foo = (unsigned int *)0x12345678;
| void bar(void) { while(*foo != 0) asm("eieio"); }

gcc 4.3.4 with -O3 compiles this to

00000000 <bar>:
   0:   3d 20 00 00     lis     r9,0
                        2: R_PPC_ADDR16_HA      foo
   4:   81 69 00 00     lwz     r11,0(r9)
                        6: R_PPC_ADDR16_LO      foo
   8:   80 0b 00 00     lwz     r0,0(r11)
   c:   2f 80 00 00     cmpwi   cr7,r0,0
  10:   4d 9e 00 20     beqlr   cr7
  14:   7c 00 06 ac     eieio
  18:   7c 00 06 ac     eieio
  1c:   4b ff ff f8     b       14 <bar+0x14>

Making the target of foo volatile properly rechecks the condition on
each iteration.

OTOH my PPC box runs fine, so I'm probably missing something obvious.

   Simon

  reply	other threads:[~2009-10-03 10:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-02 14:14 Is volatile always verboten for FSL QE structures? Michael Barkowski
2009-10-02 14:46 ` Timur Tabi
2009-10-02 16:41   ` Kumar Gala
2009-10-02 16:57     ` Michael Barkowski
2009-10-02 18:08       ` Guillaume Knispel
2009-10-03  9:55         ` Simon Richter [this message]
2009-10-03 11:20           ` Benjamin Herrenschmidt

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=20091003095537.GA15992@honey.hogyros.de \
    --to=simon.richter@hogyros.de \
    --cc=linuxppc-dev@ozlabs.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).