From: David Howells <dhowells@redhat.com>
To: Nick Piggin <npiggin@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andi Kleen <ak@suse.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [patch] generic rwsems
Date: Fri, 13 Apr 2007 13:09:42 +0100 [thread overview]
Message-ID: <25821.1176466182@redhat.com> (raw)
In-Reply-To: <20070413100416.GC31487@wotan.suse.de>
Nick Piggin <npiggin@suse.de> wrote:
> This patch converts all architectures to a generic rwsem implementation,
> which will compile down to the same code for i386, or powerpc, for
> example,
> and will allow some (eg. x86-64) to move away from spinlock based rwsems.
Which are better on UP kernels because spinlocks degrade to nothing, and then
you're left with a single disable/enable interrupt pair per operation, and no
requirement for atomic ops at all.
What you propose may wind up with several per op because if the CPU does not
support atomic ops directly and cannot emulate them through other atomic ops,
then these have to be emulated by:
atomic_op() {
spin_lock_irqsave
do op
spin_unlock_irqrestore
}
> Move to an architecture independent rwsem implementation, using the
> better of the two rwsem implementations
That's not necessarily the case, as I said above.
Furthermore, the spinlock implementation struct is smaller on 64-bit machines,
and is less prone to counter overrun on 32-bit machines.
> Out-of-line the fastpaths, to bring rw-semaphores into line with
> mutexes and spinlocks WRT our icache vs function call policy.
That should depend on whether you optimise for space or for speed. Function
calls are relatively heavyweight.
Please re-inline and fix Ingo's mess if you must clean up. Take the i386
version, for instance, I'd made it so that the compiler didn't know it was
taking a function call when it went down the slow path, thus meaning the
compiler didn't have to deal with that. Furthermore, it only interpolated two
or three instructions into the calling code in the fastpath. It's a real shame
that gcc inline asm doesn't allow you to use status flags as boolean returns,
otherwise I could reduce that even further.
> Spinlock based rwsems are inferior to atomic based ones one most
> architectures that can do atomic ops without spinlocks:
Note the "most" in your statement...
Think about it. This algorithm is only optimal where XADD is available. If
you don't have XADD, but you do have LL/SC or CMPXCHG, you can do better.
If the only atomic op you have is XCHG, then this is a really poor choice;
similarly if you are using a UP-compiled kernel.
David
next prev parent reply other threads:[~2007-04-13 12:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-13 10:04 [patch] generic rwsems Nick Piggin
2007-04-13 10:19 ` fastcalls, was " Christoph Hellwig
2007-04-13 10:59 ` Nick Piggin
2007-04-13 10:25 ` Nick Piggin
2007-04-13 11:44 ` David Howells
2007-04-13 12:13 ` Christoph Hellwig
2007-04-13 10:53 ` Andi Kleen
2007-04-13 11:20 ` Nick Piggin
2007-04-13 12:09 ` David Howells [this message]
2007-04-13 12:43 ` Nick Piggin
2007-04-13 13:22 ` William Lee Irwin III
2007-04-13 13:31 ` David Howells
2007-04-13 14:03 ` Nick Piggin
2007-04-13 14:29 ` Eric Dumazet
2007-04-13 14:49 ` 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=25821.1176466182@redhat.com \
--to=dhowells@redhat.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@suse.de \
--cc=torvalds@linux-foundation.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