All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: Joseph Seigh <jseigh_02@xemaps.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: What does atomic_read actually do?
Date: Mon, 20 Dec 2004 13:52:23 +0100	[thread overview]
Message-ID: <20041220125223.GI4424@dualathlon.random> (raw)
In-Reply-To: <opsi94i4z0s29e3l@grunion>

On Sun, Dec 19, 2004 at 06:50:54PM -0500, Joseph Seigh wrote:
> What's the assurance that gcc supports this api correctly?   There was
> the  possibility since the C standard leaves it implementation
> dependent what constitutes volatile access, that gcc did something
> special there.  But the gcc  documentation says this for volatile,
> "There is no guarantee that these reads and writes  are atomic,
> especially for objects larger than int."

set_pte_atomic also requires atomicity in
asm-generic/pgtable.h:ptep_establish, but it's not even using volatile
and it's a 64bit pointer that we're writing to.  We're relaying on the
compiler to do the right thing for us. I don't think it's a good idea
for the long run, but Benjamin on ppc64 rejected my suggestion to
rewrite set_pte_atomic in asm, so I doubt you'll be able to rewrite
atomic_read with asm either (because at least atomic_read is an int and
not a long pointer, and at least atomic_read is a volatile unlike
set_pte).

My point is that even before worrying about the theoretical correctness
of atomic_read, I would suggest to worry about set_pte_atomic first,
which is a lot more likely to break if something. The compiler may truly
execute two separate writes if power of 2 bitshifts are involved, as the
optimal compilation of the C source.

  parent reply	other threads:[~2004-12-20 12:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-18 16:23 What does atomic_read actually do? Joseph Seigh
2004-12-18 17:11 ` Paolo Ornati
2004-12-18 18:14   ` Joseph Seigh
2004-12-18 18:34 ` Arjan van de Ven
2004-12-18 19:20   ` Joseph Seigh
2004-12-18 19:39     ` Joe Korty
2004-12-18 19:54     ` Arjan van de Ven
2004-12-18 20:43       ` Joseph Seigh
2004-12-18 21:03         ` Brian Gerst
2004-12-19 22:21         ` Robert Love
2004-12-19 23:50           ` Joseph Seigh
2004-12-20 11:51             ` Arjan van de Ven
2004-12-20 12:52             ` Andrea Arcangeli [this message]
2004-12-20 20:51               ` Joseph Seigh
2004-12-18 20:47 ` Brian Gerst

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=20041220125223.GI4424@dualathlon.random \
    --to=andrea@suse.de \
    --cc=jseigh_02@xemaps.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.