From: Nick Piggin <npiggin@suse.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>, David Howells <dhowells@redhat.com>,
Ulrich Drepper <drepper@redhat.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 0/3] 64-bit futexes: Intro
Date: Fri, 6 Jun 2008 13:53:05 +0200 [thread overview]
Message-ID: <20080606115305.GA20345@wotan.suse.de> (raw)
In-Reply-To: <alpine.LFD.1.10.0806052018440.3473@woody.linux-foundation.org>
On Thu, Jun 05, 2008 at 08:37:19PM -0700, Linus Torvalds wrote:
>
>
> On Fri, 6 Jun 2008, Nick Piggin wrote:
> >
> > What you *could* maybe do, to slightly speed up the reader fastpath, at
> > the expense of the writer fastpath, is to also have the active writer add
> > 4 to the count too, so your unlock can start with a lock xadd -4, count
> > in order to get the write-intent on the cacheline straight up.
>
> Yes, nice idea. It avoids the possible unnecessary S->M transition, but
> the downside is that it effectively slows down the write unlock by making
> it do two atomic ops even for the fastpath. So if I were to _only_ care
> about the reader path, I think it would be a great idea, but as it is, the
> current non-contended write case is actually pretty close to optimal, and
> doing the unconditional xaddl on the unlock path would slow that one down.
Yeah, it is a case of a large slowdown for write for a small speedup
for read (pity the API doesn't have explicit read and write unlocks
-- were they too lazy to type the last bit, or did they expect people
to lose track of whether they had a read or write lock? :P)
Anyway, it's obviously a tradeoff you'd just have to carefully
benchmark in real situations.
> > I'd be more interested to know why this code can't be evolved into a full
> > rwlock implementation? This is a rather standard (though neat) looking rwlock
> > -- so my question is what can the patented 64-bit futex locks do that this
> > can't, or what can they do faster?
>
> Quite frankly - and this was my argument the whole time - I do not believe
> consider things like timeouts etc. Timeouts are "hard" to handle because
> they mean that you cannot use any kind of trivially incrementing "ticket
> locks" with sequence numbers (because we may have to just avoid a sequence
> if it times out), so the sequence number approach that we now use for
> kernel spinlocks was not an option. I didn't actually *write* the timeout
> versions, of course, but given the structure of the locks they really
> should be very straightforward.
>
> [ Half-way subtle thing: a writer that times out needs to be very careful
> that it doesn't lose a wakeup event, but futexes actually make that part
> pretty easy - since FUTEX_WAIT returns whether you got woken up or not,
> you can just decide to wake up the next write-waiter if you cannot get
> the lock immediately and have to exit due to a timeout. ]
>
> But I really haven't tested my rwlocks very exhaustively, and I did not
> verify that they actualyl scale with lots of CPU's, for example. I
> literally only have dual-core CPU's in use at home, right now, nothing
> fancier. Somebody with dual-socket quads would be a lot better off, and
> the more the merrier, of course.
Well... a single lock is only going to be so scalable. I don't see how
it could be done really significantly better? Maybe a small factor of
improvement if you were to concentrate on the contended case (but you
wouldn't want to do that anyway)
next prev parent reply other threads:[~2008-06-06 11:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-31 1:27 Ulrich Drepper
2008-05-31 2:13 ` Linus Torvalds
2008-05-31 3:14 ` Ulrich Drepper
2008-05-31 3:44 ` Linus Torvalds
2008-05-31 4:04 ` Ulrich Drepper
2008-05-31 4:16 ` Linus Torvalds
2008-05-31 4:23 ` Linus Torvalds
2008-05-31 4:38 ` Ulrich Drepper
2008-05-31 4:58 ` Linus Torvalds
2008-05-31 22:25 ` Linus Torvalds
2008-05-31 22:32 ` Linus Torvalds
2008-06-02 18:54 ` Ingo Molnar
2008-06-02 20:22 ` Linus Torvalds
2008-06-02 23:03 ` Ingo Molnar
2008-06-03 3:24 ` Nick Piggin
2008-06-04 19:57 ` Linus Torvalds
2008-06-04 20:38 ` Linus Torvalds
2008-06-05 1:56 ` Nick Piggin
2008-06-05 1:58 ` Nick Piggin
2008-06-05 3:08 ` Linus Torvalds
2008-06-05 4:29 ` Nick Piggin
2008-06-05 1:45 ` Nick Piggin
2008-06-06 1:27 ` Nick Piggin
2008-06-06 3:37 ` Linus Torvalds
2008-06-06 11:53 ` Nick Piggin [this message]
2008-06-06 15:01 ` Linus Torvalds
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=20080606115305.GA20345@wotan.suse.de \
--to=npiggin@suse.de \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=drepper@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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
all inboxes | Powered by JetHome®