public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Joseph Seigh" <jseigh_02@xemaps.com>
To: linux-kernel@vger.kernel.org
Subject: Re: What does atomic_read actually do?
Date: Mon, 20 Dec 2004 15:51:37 -0500	[thread overview]
Message-ID: <opsjbqwbz6s29e3l@grunion> (raw)
In-Reply-To: 20041220125223.GI4424@dualathlon.random

On Mon, 20 Dec 2004 13:52:23 +0100, Andrea Arcangeli <andrea@suse.de>  
wrote:
>
> 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.

Actually, I'm programming out in user space.  I was looking at the atomic.h
stuff to see how much would be usable.  But I have to look at reading
and writing pointers atomically also since that is heavily used in  
lock-free
programming, e.g. RCU for preemptive user threads which I have a couple of
implementations for.  I remember a discussion a while back about dependent
load memory ordering (alpha doesn't have it) for RCU but I don't recall any
discussion of the requirement for gcc to do atomic loads and stores.  I  
guess
it's just assumed.

It would be nice to have macros tied to the linux ones, ie. check the  
current
linux versions when porting them.  But I can always use asm if I have to.   
I'll
probably have to modify the conditions of use to say "no warranty is  
implied
and we really do mean it" and add a compiler flag to select between the  
safe asm
version and the "Do you feel lucky?" C macro version.

Joe Seigh


  reply	other threads:[~2004-12-20 20:46 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
2004-12-20 20:51               ` Joseph Seigh [this message]
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=opsjbqwbz6s29e3l@grunion \
    --to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox