linux-mips
[Top] [All Lists]

Re: PATCH: Fix ll/sc for mips (take 3)

To: Justin Carlson <justinca@ri.cmu.edu>
Subject: Re: PATCH: Fix ll/sc for mips (take 3)
From: Ralf Baechle <ralf@oss.sgi.com>
Date: Mon, 4 Feb 2002 07:46:19 +0100
Cc: Daniel Jacobowitz <dan@debian.org>, "H . J . Lu" <hjl@lucon.org>, "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>, Hiroyuki Machida <machida@sm.sony.co.jp>, libc-alpha@sources.redhat.com, linux-mips@oss.sgi.com
In-reply-to: <1012676003.1563.6.camel@xyzzy.stargate.net>; from justinca@ri.cmu.edu on Sat, Feb 02, 2002 at 01:53:23PM -0500
References: <20020131231714.E32690@lucon.org> <Pine.GSO.3.96.1020201124328.26449A-100000@delta.ds2.pg.gda.pl> <20020201102943.A11146@lucon.org> <20020201180126.A23740@nevyn.them.org> <20020201151513.A15913@lucon.org> <20020201222657.A13339@nevyn.them.org> <1012676003.1563.6.camel@xyzzy.stargate.net>
Sender: owner-linux-mips@oss.sgi.com
User-agent: Mutt/1.2.5i
On Sat, Feb 02, 2002 at 01:53:23PM -0500, Justin Carlson wrote:

> 2)  More importantly, most implementations don't use any sort of dynamic
> branch prediction on branch likelies.  They predict taken, always, since
> that's the specified intent (it's a branch *likely* to be taken).

CPU guys hate branch likely and would probably love if whoever invented
them hires at Intel ;-)

> For most spin locks, the normal behaviour is a fall through, not taking
> that branch, so you're inflicting a branch mispredict penalty on every
> lock grabbed without contention.  Even for locks which the general case
> is contention, giving the processor branch predictor a chance to learn
> that is a Good Idea.

I was thinking about spinlocks like

retry:  la      addrreg, retry
        ll      reg, lockvar
        ...
        sc      reg, lockvar
        teq     $0, reg

That would depend on the price of a trap instruction when it's not taken
and the probability of the lock being congested.

  Ralf

<Prev in Thread] Current Thread [Next in Thread>