From: Nick Piggin <nickpiggin@yahoo.com.au>
To: David Howells <dhowells@redhat.com>
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
Subject: Re: Why Semaphore Hardware-Dependent?
Date: Thu, 14 Sep 2006 05:25:37 +1000 [thread overview]
Message-ID: <45085B31.3080504@yahoo.com.au> (raw)
In-Reply-To: <22461.1158173455@warthog.cambridge.redhat.com>
David Howells wrote:
> Nick Piggin <nickpiggin@yahoo.com.au> wrote:
>
>
>>+ while ((tmp = atomic_read(&sem->count)) >= 0) {
>>+ if (tmp == atomic_cmpxchg(&sem->count, tmp,
>>+ tmp + RWSEM_ACTIVE_READ_BIAS)) {
>
>
> NAK for FRV. Do not use atomic_cmpxchg() there as it isn't strictly atomic
> (FRV only has one strictly atomic operation: SWAP). Please leave FRV as using
> the spinlock version which is more efficient on UP.
From what I can read of the asm and the documentation, it is atomic. If
it were not atomic then it is badly broken.
BTW. if atomic_cmpxchg is slower than a local_irq_disable+local_irq_enable
on your architecture then you have probably not implemented cmpxchg well
because you may as well just implement it with local_irq_disable.
> Please also show benchmarks to show the performance difference between your
> version and the old version before Ingo messed it up and made everything
> unconditionally out of line without cleaning the inline asm up.
I'm not so interested in counting cycles so much as consolidating duplicated
code and reduce complexity and icache footprint. I'll leave you to benchmark
Ingo's changes if you're concerned about them.
Of course I will benchmark the end results when I finish the patch, though.
> If you are going to generalise, you should get rid of everything barring the
> spinlock-based version and stick with that. It will cost you performance
> under some circumstances, but it's better under others than attempting to use
> atomic_cmpxchg() which may not really exist on all archs.
atomic_cmpxchg exists on all architectures.
I'm happy to go with the spinlock version (it is even simpler), but I will
have to benchmark that. I have seen small slowdowns there in high contention
situations but it was improved with my rwsem scalability patch. If
performance is no different between the two, then the spinlock version is a
no brainer.
> You've also caused another problem: the spinlock based version permits up to
> 2^31 - 1 readers at one time, the inline optimised version, on a 32-bit arch,
> will only permit up to 2^16 - 1 at most. By doing this to x86_64, you've
> reduced the number of processes it can support.
Yep, Christoph pointed this out. I'll fix it.
--
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com
next prev parent reply other threads:[~2006-09-13 19:25 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-27 19:22 Why Semaphore Hardware-Dependent? Dong Feng
2006-08-27 20:52 ` Andi Kleen
2006-08-27 21:05 ` Christoph Lameter
2006-08-27 21:39 ` Andi Kleen
2006-08-27 22:14 ` Christoph Lameter
2006-08-28 0:18 ` Paul Mackerras
2006-08-28 5:14 ` Chris Wedgwood
2006-08-28 5:21 ` Christoph Lameter
2006-08-28 5:56 ` Jan Engelhardt
2006-08-28 12:35 ` linux-os (Dick Johnson)
2006-08-28 7:23 ` Andi Kleen
2006-08-29 1:00 ` Paul Mackerras
2006-08-28 7:30 ` Arjan van de Ven
2006-08-29 1:18 ` Nick Piggin
2006-08-29 6:07 ` Andi Kleen
2006-09-13 17:54 ` Nick Piggin
2006-08-29 10:05 ` David Howells
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 [this message]
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=45085B31.3080504@yahoo.com.au \
--to=nickpiggin@yahoo.com.au \
--cc=ak@suse.de \
--cc=arjan@infradead.org \
--cc=clameter@sgi.com \
--cc=dhowells@redhat.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=middle.fengdong@gmail.com \
--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