From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Jeremy Fitzhardinge <jeremy@goop.org>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>, Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [RFC PATCH] Writer-biased low-latency rwlock v8
Date: Thu, 21 Aug 2008 14:26:05 -0700 [thread overview]
Message-ID: <48ADDD6D.6000504@zytor.com> (raw)
In-Reply-To: <alpine.LFD.1.10.0808211356360.3487@nehalem.linux-foundation.org>
Linus Torvalds wrote:
>
> Because that is already crap.
>
> Go look at my code once more. Go look at how it has 128 bits of data,
> exactly so that it DOES NOT HAVE TO LIMIT THE NUMBER OF READERS.
>
> And then go look at it again.
>
> Look at it five times, and until you can understand that it still uses
> just a 32-bit word for the fast-path and no unnecessarily crap in it, but
> it actually has 128 bits of data for all the slow paths, don't bother
> emailing me any new versions.
>
> Please. You -still- apparently haven't looked at it, at least not enough
> to understand the _point_ of it. You still go on about trying to fit in
> three or four different numbers in that one word. Even though the whole
> point of my rwlock is that you need exactly _one_ count (active writers),
> and _one_ bit (active reader) and _one_ extra bit ("contention, go to slow
> path, look at the other bits ONLY IN THE SLOW PATH!")
>
> That leaves 30 bits for readers. If you still think you need to "limit the
> number of readers", then you aren't getting it.
>
First of all, let me say I don't pretend to understand formally how you
deal with overflow-after-the-fact, as unlikely as it is.
However, it seems to me to be an easy way to avoid it. Simply by
changing the read-test mask to $0x80000003, you will kick the code down
the slow path once the read counter reaches $0x80000004 (2^29+1
readers), where you can do any necessary fixup -- or BUG() -- at leisure.
This fastpath ends up being identical in size and performance to the one
you posted, although yours could be reduced by changing the test to a
testb instruction -- at the almost certainly unacceptable expense of
taking a partial-register stall on the CPUs that have those.
-hpa
next prev parent reply other threads:[~2008-08-21 21:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-16 7:39 [PATCH] x86_64 : support atomic ops with 64 bits integer values Mathieu Desnoyers
2008-08-16 15:04 ` H. Peter Anvin
2008-08-16 15:43 ` Mathieu Desnoyers
2008-08-16 17:30 ` Linus Torvalds
2008-08-16 21:19 ` [RFC PATCH] Fair rwlock Mathieu Desnoyers
2008-08-16 21:33 ` Linus Torvalds
2008-08-17 7:53 ` [RFC PATCH] Fair low-latency rwlock v3 Mathieu Desnoyers
2008-08-17 16:17 ` Linus Torvalds
2008-08-17 19:10 ` [RFC PATCH] Fair low-latency rwlock v5 Mathieu Desnoyers
2008-08-17 21:30 ` [RFC PATCH] Fair low-latency rwlock v5 (updated benchmarks) Mathieu Desnoyers
2008-08-18 18:59 ` [RFC PATCH] Fair low-latency rwlock v5 Linus Torvalds
2008-08-18 23:25 ` Paul E. McKenney
2008-08-19 6:04 ` Mathieu Desnoyers
2008-08-19 7:33 ` Mathieu Desnoyers
2008-08-19 9:06 ` Mathieu Desnoyers
2008-08-19 16:48 ` Linus Torvalds
2008-08-21 20:50 ` [RFC PATCH] Writer-biased low-latency rwlock v8 Mathieu Desnoyers
2008-08-21 21:00 ` Linus Torvalds
2008-08-21 21:15 ` Linus Torvalds
2008-08-21 22:22 ` Linus Torvalds
2008-08-23 5:09 ` Mathieu Desnoyers
2008-08-23 18:02 ` Linus Torvalds
2008-08-23 20:30 ` Mathieu Desnoyers
2008-08-23 21:40 ` Linus Torvalds
2008-08-21 21:26 ` H. Peter Anvin [this message]
2008-08-21 21:41 ` Linus Torvalds
2008-08-25 19:20 ` [RFC PATCH] Fair low-latency rwlock v5 Peter Zijlstra
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=48ADDD6D.6000504@zytor.com \
--to=hpa@zytor.com \
--cc=akpm@linux-foundation.org \
--cc=jeremy@goop.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.