[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.1.10.0808211433091.3487@nehalem.linux-foundation.org>
Date: Thu, 21 Aug 2008 14:41:57 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: "H. Peter Anvin" <hpa@...or.com>
cc: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Jeremy Fitzhardinge <jeremy@...p.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>, Joe Perches <joe@...ches.com>,
linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [RFC PATCH] Writer-biased low-latency rwlock v8
On Thu, 21 Aug 2008, H. Peter Anvin wrote:
>
> 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.
Just make sure it can't overflow. With spinlocks, you are guaranteed that
you won't have more than NR_CPU's thing, so 20 bits is pretty safe. 30
bits is ridiculously safe.
> 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.
Sure, you could do things like that, but that sounds like a separate
"debugging" version, not the main one.
> 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.
Well, you could just change the "testl $3,%eax" into an "andl $3,%eax",
and it will be two bytes shorter with no partial register stall.
I forgot that "testl" doesn't have the byte immediate version.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists