public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Arjan van de Ven <arjan@infradead.org>,
	Dong Feng <middle.fengdong@gmail.com>,
	ak@suse.de, Paul Mackerras <paulus@samba.org>,
	Christoph Lameter <clameter@sgi.com>,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	David Howells <dhowells@redhat.com>
Subject: Re: Why Semaphore Hardware-Dependent?
Date: Tue, 29 Aug 2006 11:05:27 +0100	[thread overview]
Message-ID: <11861.1156845927@warthog.cambridge.redhat.com> (raw)
In-Reply-To: <44F395DE.10804@yahoo.com.au>

Nick Piggin <nickpiggin@yahoo.com.au> wrote:

> I wonder if we can just start with the nice powerpc code that uses
> atomic_add_return and cmpxchg (should use atomic_cmpxchg)

Because i386 (and x86_64) can do better by using XADDL/XADDQ.

The problem with CMPXCHG is that it might fail and you might have to attempt
it again.  This may be unlikely - it depends on the circumstances.  The same
applies to LL/ST equivalents.

On i386, CMPXCHG also ties you to what registers you may use for what to some
extent.  OTOH, whilst XADD does less so, the slowpath function does instead,
though with the XADD version, we can make sure that the semaphore address is
in EAX, something we can't do with CMPXCHG.

For those archs where CMPXCHG is the best available, a better algorithm than
the XADD based one is available, though I haven't submitted it.  I may still
have the patch somewhere.

However!  If what you have is LL/ST equivalents than emulating CMPXCHG to
emulate the XADD algorithm probably isn't the most optimal way either.  Don't
get stuck on using LL/ST to emulate what other CPUs have available.

> and chuck out the "crappy" rwsem fallback implementation,

CMPXCHG is not available on all archs, and may not be implemented on all archs
through other atomic instructions.

> as well as all the arch specific code?

Using CMPXCHG is only optimal where that's the best available.

David

  parent reply	other threads:[~2006-08-29 10:05 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <a2ebde260608271222x2b51693fnaa600965fcfaa6d2@mail.gmail.com>
     [not found] ` <1156750249.3034.155.camel@laptopd505.fenrus.org>
2006-08-29  1:18   ` Why Semaphore Hardware-Dependent? Nick Piggin
2006-08-29  6:07     ` Andi Kleen
2006-09-13 17:54       ` Nick Piggin
2006-08-29 10:05     ` David Howells [this message]
2006-08-29 10:56       ` Andi Kleen
2006-08-29 17:40         ` Andrew Morton
2006-08-29 19:10         ` Benjamin LaHaise
2006-08-29 15:56       ` Christoph Lameter
2006-08-29 16:20         ` Ralf Baechle
2006-08-29 16:25           ` David Howells
2006-08-29 16:28             ` Christoph Lameter
2006-08-29 16:57               ` David Howells
2006-08-29 16:53             ` Ralf Baechle
2006-08-29 16:58               ` Geert Uytterhoeven
2006-08-29 17:22         ` Andi Kleen
2006-08-29 17:36           ` Christoph Lameter
2006-08-29 18:18             ` Andi Kleen
2006-08-29 18:30               ` David Howells
2006-08-29 18:33                 ` Andi Kleen
2006-08-29 18:56                   ` David Howells
2006-08-29 18:41               ` Christoph Lameter
2006-09-13 18:04       ` Nick Piggin
2006-09-13 18:07         ` Christoph Lameter
2006-09-13 18:13           ` Nick Piggin
2006-09-13 18:16             ` Christoph Lameter
2006-09-13 18:50         ` David Howells
2006-09-13 19:25           ` Nick Piggin
2006-09-14 11:41             ` David Howells
2006-09-14 15:27               ` Nick Piggin
2006-09-14 15:38                 ` Nick Piggin
2006-09-15  8:59                 ` David Howells

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=11861.1156845927@warthog.cambridge.redhat.com \
    --to=dhowells@redhat.com \
    --cc=ak@suse.de \
    --cc=arjan@infradead.org \
    --cc=clameter@sgi.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=middle.fengdong@gmail.com \
    --cc=nickpiggin@yahoo.com.au \
    --cc=paulus@samba.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