From: "Paul E. McKenney" <paulmck@us.ibm.com>
To: David Howells <dhowells@redhat.com>
Cc: akpm@osdl.org, linux-arch@vger.kernel.org,
linux-kernel@vger.kernel.org, torvalds@osdl.org,
davem@redhat.com, linuxppc64-dev@ozlabs.org
Subject: Re: [PATCH] Document Linux's memory barriers [try #5]
Date: Thu, 23 Mar 2006 14:26:45 -0800 [thread overview]
Message-ID: <20060323222645.GA1298@us.ibm.com> (raw)
In-Reply-To: <895.1143138867@warthog.cambridge.redhat.com>
On Thu, Mar 23, 2006 at 06:34:27PM +0000, David Howells wrote:
> Paul E. McKenney <paulmck@us.ibm.com> wrote:
>
> > smp_mb__before_atomic_dec() and friends as well?
>
> These seem to be something Sparc64 related; or, at least, Sparc64 seems to do
> something weird with them.
>
> What are these meant to achieve anyway? They seems to just be barrier() on a
> lot of systems, even SMP ones.
On architectures such as x86 where atomic_dec() implies an smp_mb(),
they do nothing. On other architectures, they supply whatever memory
barrier is required.
So, on x86:
smp_mb();
atomic_dec(&my_atomic_counter);
would result in -two- atomic instructions, but the smp_mb() would be
absolutely required on CPUs with weaker memory-consistency models.
So your choice is to (1) be inefficient on x86 or (2) be unsafe on
weak-memory-consistency systems. What we can do instead is:
smp_mb__before_atomic_dec();
atomic_dec(&my_atomic_counter);
This allows x86 to generate efficient code -and- allows weak-memory
machines (e.g., Alpha, MIPS, PA-RISC(!), ppc, s390, SPARC64) to generate
safe code.
Thanx, Paul
prev parent reply other threads:[~2006-03-23 22:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20060316231723.GB1323@us.ibm.com>
[not found] ` <16835.1141936162@warthog.cambridge.redhat.com>
[not found] ` <18351.1142432599@warthog.cambridge.redhat.com>
2006-03-23 18:34 ` [PATCH] Document Linux's memory barriers [try #5] David Howells
2006-03-23 19:28 ` Linus Torvalds
2006-03-23 22:26 ` Paul E. McKenney [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=20060323222645.GA1298@us.ibm.com \
--to=paulmck@us.ibm.com \
--cc=akpm@osdl.org \
--cc=davem@redhat.com \
--cc=dhowells@redhat.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc64-dev@ozlabs.org \
--cc=torvalds@osdl.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).