From owner-freebsd-alpha@FreeBSD.ORG Thu Aug 7 19:39:54 2003 Return-Path: Delivered-To: freebsd-alpha@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8116537B401; Thu, 7 Aug 2003 19:39:54 -0700 (PDT) Received: from alcanet.com.au (mail2.alcanet.com.au [203.62.196.17]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9404B43FB1; Thu, 7 Aug 2003 19:39:52 -0700 (PDT) (envelope-from peter.jeremy@alcatel.com.au) Received: from sydsmtp01.alcatel.com.au (IDENT:root@localhost.localdomain [127.0.0.1])h782doXk024150; Fri, 8 Aug 2003 12:39:50 +1000 Received: from gsmx07.alcatel.com.au ([139.188.20.247]) by sydsmtp01.alcatel.com.au (Lotus Domino Release 5.0.12) with ESMTP id 2003080812394959:39918 ; Fri, 8 Aug 2003 12:39:49 +1000 Received: from gsmx07.alcatel.com.au (localhost [127.0.0.1]) by gsmx07.alcatel.com.au (8.12.9/8.12.9) with ESMTP id h782dn7d042170; Fri, 8 Aug 2003 12:39:49 +1000 (EST) (envelope-from peter.jeremy@alcatel.com.au) Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.12.9/8.12.9/Submit) id h782dnBF042169; Fri, 8 Aug 2003 12:39:49 +1000 (EST) (envelope-from peter.jeremy@alcatel.com.au) Date: Fri, 8 Aug 2003 12:39:48 +1000 From: Peter Jeremy To: deischen@freebsd.org Message-ID: <20030808023948.GU430@gsmx07.alcatel.com.au> Mail-Followup-To: deischen@freebsd.org, David O'Brien , alpha@freebsd.org References: <20030808015321.GB44639@dragon.nuxi.com> Mime-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.4.1i X-MIMETrack: Itemize by SMTP Server on SYDSMTP01/AlcatelAustralia(Release 5.0.12 |February 13, 2003) at 08/08/2003 12:39:49 PM,|February 13, 2003) at 08/08/2003 12:39:50 PM, Serialize complete at 08/08/2003 12:39:50 PM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline cc: alpha@freebsd.org Subject: Re: Atomic swap X-BeenThere: freebsd-alpha@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the Alpha List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Aug 2003 02:39:54 -0000 On 2003-Aug-07 22:05:54 -0400, Daniel Eischen wrote: >On Thu, 7 Aug 2003, David O'Brien wrote: > >> On Thu, Aug 07, 2003 at 01:44:18PM -0400, Daniel Eischen wrote: >> > "beq %1, 2f\n\t" /* if the store failed, spin */ >> >> It is worth explaining why this is "beq" since it wasn't obvious to all >> readers. :-) > >Well, when you catch up on you're reading, you'll see the >forward branch is no longer there. But FYI, it was >supposedly there because it was thought that Alpha's >always predicted a backwards branch, so the common >case of the store succeeding wasn't optimized. To clarify slightly: Originally, the Alpha architecture predicted conditional branches based on the branch displacement - backward branches were predicted taken and forward branches were predicted not taken. Later Alpha versions will preferentially[*] use branch history information stored in the Icache. The latest AXP Architecture manual I have (Edition 4) states (A.2.2) that branch prediction is implementation specific but infrequent cases should be out-of-line (and out of cache if rare (<5%)). It further recommends that the implementation strategy should prioritise in the following order: 1) straight-line with no branch-takens 2) predict conditional branches based on the displacement (backward taken, forward not-taken) 3) keep a prediction stack for subroutine return addressses. The recommended code for atomic updates (5.5.2) still uses a forward conditional branch for the store-failed case. All the above said, the code should preferably include comments explaining why the branch configuration was chosen. Whilst it's not mandated by style(9), explaining why code is structured in a particular way, rather than a different apparently simpler way is generally a good idea. [*] The branch prediction strategy is user selectable on at least some chips. Peter